summaryrefslogtreecommitdiff
path: root/test/CodeGen/CBackend
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-31 09:23:55 +0000
committerChris Lattner <sabre@nondot.org>2008-05-31 09:23:55 +0000
commite56d946a383e3a7330c5fe8a8cf8c409174fb774 (patch)
treee1c67172f9af9d2162e502238d105fa63a78c70d /test/CodeGen/CBackend
parent7e2dd6628e398f369a110856ec69455f65d17638 (diff)
downloadllvm-e56d946a383e3a7330c5fe8a8cf8c409174fb774.tar.gz
llvm-e56d946a383e3a7330c5fe8a8cf8c409174fb774.tar.bz2
llvm-e56d946a383e3a7330c5fe8a8cf8c409174fb774.tar.xz
Fix the CBE's handling of instructions whose result is an i1. Previously,
we did not truncate the value down to i1 with (x&1). This caused a problem when the computation of x was nontrivial, for example, "add i1 1, 1" would return 2 instead of 0. This makes the testcase compile into: ... llvm_cbe_t = (((llvm_cbe_r == 0u) + (llvm_cbe_r == 0u))&1); llvm_cbe_u = (((unsigned int )(bool )llvm_cbe_t)); ... instead of: ... llvm_cbe_t = ((llvm_cbe_r == 0u) + (llvm_cbe_r == 0u)); llvm_cbe_u = (((unsigned int )(bool )llvm_cbe_t)); ... This fixes a miscompilation of mediabench/adpcm/rawdaudio/rawdaudio and 403.gcc with the CBE, regressions from LLVM 2.2. Tanya, please pull this into the release branch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/CBackend')
-rw-r--r--test/CodeGen/CBackend/2008-05-31-BoolOverflow.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/CodeGen/CBackend/2008-05-31-BoolOverflow.ll b/test/CodeGen/CBackend/2008-05-31-BoolOverflow.ll
new file mode 100644
index 0000000000..52e0259007
--- /dev/null
+++ b/test/CodeGen/CBackend/2008-05-31-BoolOverflow.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | llc -march=c | grep {llvm_cbe_t.*&1}
+define i32 @test(i32 %r) {
+ %s = icmp eq i32 %r, 0
+ %t = add i1 %s, %s
+ %u = zext i1 %t to i32
+ br i1 %t, label %A, label %B
+A:
+
+ ret i32 %u
+B:
+
+ %v = select i1 %t, i32 %r, i32 %u
+ ret i32 %v
+}