aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-27 01:05:10 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-27 01:05:10 +0000
commit3da59db637a887474c1b1346c1f3ccf53b6c4663 (patch)
treeb061e2133efdb9ea9bb334c1b15ceea881bb88f8 /test/CodeGen/X86
parent5fed9b90447a9a95a1f670ccd9c23aea8c937451 (diff)
downloadexternal_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.zip
external_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.gz
external_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.bz2
For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM to replace the cast instruction. Corresponding changes throughout LLVM are provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the exception of 175.vpr which fails only on a slight floating point output difference. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86')
-rw-r--r--test/CodeGen/X86/trunc-to-bool.ll32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/CodeGen/X86/trunc-to-bool.ll b/test/CodeGen/X86/trunc-to-bool.ll
new file mode 100644
index 0000000..693b94c
--- /dev/null
+++ b/test/CodeGen/X86/trunc-to-bool.ll
@@ -0,0 +1,32 @@
+; An integer truncation to bool should be done with an and instruction to make
+; sure only the LSBit survives. Test that this is the case both for a returned
+; value and as the operand of a branch.
+; RUN: llvm-as < %s | llc -march=x86 &&
+; RUN: llvm-as < %s | llc -march=x86 | grep '\(and\)\|\(test.*1\)' | wc -l | grep 3
+bool %test1(int %X) {
+ %Y = trunc int %X to bool
+ ret bool %Y
+}
+
+bool %test2(int %val, int %mask) {
+entry:
+ %mask = trunc int %mask to ubyte
+ %shifted = ashr int %val, ubyte %mask
+ %anded = and int %shifted, 1
+ %trunced = trunc int %anded to bool
+ br bool %trunced, label %ret_true, label %ret_false
+ret_true:
+ ret bool true
+ret_false:
+ ret bool false
+}
+
+int %test3(sbyte* %ptr) {
+ %val = load sbyte* %ptr
+ %tmp = trunc sbyte %val to bool ; %<bool> [#uses=1]
+ br bool %tmp, label %cond_true, label %cond_false
+cond_true:
+ ret int 21
+cond_false:
+ ret int 42
+}