summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-01-24 16:28:28 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-01-24 16:28:28 +0000
commit435eba09b75dc64a0e3a1b39953c1ddc3ef0de7c (patch)
treee73818da30d62c176e72727d1a0424b48ab0e7a0 /llvm/test/Transforms
parentcbc86bcbb59e9db635600d1aba277413bb09d0cb (diff)
downloadbcm5719-llvm-435eba09b75dc64a0e3a1b39953c1ddc3ef0de7c.tar.gz
bcm5719-llvm-435eba09b75dc64a0e3a1b39953c1ddc3ef0de7c.zip
ConstantFolding: Add a missing folding that leads to a miscompile.
We use constant folding to see if an intrinsic evaluates to the same value as a constant that we know. If we don't take the undefinedness into account we get a value that doesn't match the actual implementation, and miscompiled code. This was uncovered by Chandler's simplifycfg changes. llvm-svn: 173356
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll2
-rw-r--r--llvm/test/Transforms/InstCombine/intrinsics.ll36
2 files changed, 37 insertions, 1 deletions
diff --git a/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll b/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll
index 6d34cb17fff..c5ee70c2ff1 100644
--- a/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll
+++ b/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll
@@ -3,6 +3,6 @@
declare i13 @llvm.cttz.i13(i13, i1)
define i13 @test() {
- %X = call i13 @llvm.cttz.i13(i13 0, i1 true)
+ %X = call i13 @llvm.cttz.i13(i13 0, i1 false)
ret i13 %X
}
diff --git a/llvm/test/Transforms/InstCombine/intrinsics.ll b/llvm/test/Transforms/InstCombine/intrinsics.ll
index 93f0a953fd3..f334b3b1e93 100644
--- a/llvm/test/Transforms/InstCombine/intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/intrinsics.ll
@@ -220,3 +220,39 @@ define i32 @cttz_simplify1b(i32 %x) nounwind readnone ssp {
; CHECK: @cttz_simplify1b
; CHECK-NEXT: ret i32 0
}
+
+define i32 @ctlz_undef(i32 %Value) nounwind {
+ %ctlz = call i32 @llvm.ctlz.i32(i32 0, i1 true)
+ ret i32 %ctlz
+
+; CHECK: @ctlz_undef
+; CHECK-NEXT: ret i32 undef
+}
+
+define i32 @cttz_undef(i32 %Value) nounwind {
+ %cttz = call i32 @llvm.cttz.i32(i32 0, i1 true)
+ ret i32 %cttz
+
+; CHECK: @cttz_undef
+; CHECK-NEXT: ret i32 undef
+}
+
+define i32 @ctlz_select(i32 %Value) nounwind {
+ %tobool = icmp ne i32 %Value, 0
+ %ctlz = call i32 @llvm.ctlz.i32(i32 %Value, i1 true)
+ %s = select i1 %tobool, i32 %ctlz, i32 32
+ ret i32 %s
+
+; CHECK: @ctlz_select
+; CHECK: select i1 %tobool, i32 %ctlz, i32 32
+}
+
+define i32 @cttz_select(i32 %Value) nounwind {
+ %tobool = icmp ne i32 %Value, 0
+ %cttz = call i32 @llvm.cttz.i32(i32 %Value, i1 true)
+ %s = select i1 %tobool, i32 %cttz, i32 32
+ ret i32 %s
+
+; CHECK: @cttz_select
+; CHECK: select i1 %tobool, i32 %cttz, i32 32
+}
OpenPOWER on IntegriCloud