summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-05-10 16:26:37 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-05-10 16:26:37 +0000
commit7159a307b9a0a53f9a33e416d24b9308ef547d97 (patch)
tree90fef1983af353ee36a49cfacb202a153ea68e3b /test
parentc24a374331fc97dd215937c8f0a9bf5271f39657 (diff)
downloadexternal_llvm-7159a307b9a0a53f9a33e416d24b9308ef547d97.zip
external_llvm-7159a307b9a0a53f9a33e416d24b9308ef547d97.tar.gz
external_llvm-7159a307b9a0a53f9a33e416d24b9308ef547d97.tar.bz2
InstCombine: Don't claim to be able to evaluate any shl in a zexted type.
The shift amount may be larger than the type leading to undefined behavior. Limit the transform to constant shift amounts. While there update the bits to clear in the result which may enable additional optimizations. PR15959. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/cast.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll
index de738bb..ff2c0a9 100644
--- a/test/Transforms/InstCombine/cast.ll
+++ b/test/Transforms/InstCombine/cast.ll
@@ -898,3 +898,31 @@ define double @test81(double *%p, float %f) {
%l = load double* %r
ret double %l
}
+
+define i64 @test82(i64 %A) nounwind {
+ %B = trunc i64 %A to i32
+ %C = lshr i32 %B, 8
+ %D = shl i32 %C, 9
+ %E = zext i32 %D to i64
+ ret i64 %E
+
+; CHECK: @test82
+; CHECK-NEXT: [[REG:%[0-9]*]] = shl i64 %A, 1
+; CHECK-NEXT: %E = and i64 [[REG]], 4294966784
+; CHECK-NEXT: ret i64 %E
+}
+
+; PR15959
+define i64 @test83(i16 %a, i64 %k) {
+ %conv = sext i16 %a to i32
+ %sub = add nsw i64 %k, -1
+ %sh_prom = trunc i64 %sub to i32
+ %shl = shl i32 %conv, %sh_prom
+ %sh_prom1 = zext i32 %shl to i64
+ ret i64 %sh_prom1
+
+; CHECK: @test83
+; CHECK: %sub = add nsw i64 %k, 4294967295
+; CHECK: %sh_prom = trunc i64 %sub to i32
+; CHECK: %shl = shl i32 %conv, %sh_prom
+}