summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-10-11 10:19:52 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-10-11 10:19:52 +0000
commit3cac85e07120f0cfcbc8e78a975f68ae99fcebbb (patch)
tree6b590d8c05b0e370555c062d397467af8cb3d12a /llvm/test/Transforms
parent686de24128d5abf2c2bde4a99c6639c98f8ec7f0 (diff)
downloadbcm5719-llvm-3cac85e07120f0cfcbc8e78a975f68ae99fcebbb.tar.gz
bcm5719-llvm-3cac85e07120f0cfcbc8e78a975f68ae99fcebbb.zip
InstCombine: mul to shl shouldn't preserve nsw
consider: mul i32 nsw %x, -2147483648 this instruction will not result in poison if %x is 1 however, if we transform this into: shl i32 nsw %x, 31 then we will be generating poison because we just shifted into the sign bit. This fixes PR21242. llvm-svn: 219566
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll2
-rw-r--r--llvm/test/Transforms/InstCombine/add2.ll6
-rw-r--r--llvm/test/Transforms/InstCombine/cast.ll12
-rw-r--r--llvm/test/Transforms/InstCombine/div.ll4
4 files changed, 12 insertions, 12 deletions
diff --git a/llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll b/llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
index a75a4656e68..895b2603ad9 100644
--- a/llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
+++ b/llvm/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
@@ -15,7 +15,7 @@ define void @fu1(i32 %parm) nounwind ssp {
; <label>:4 ; preds = %0
%5 = load i32* %1, align 4
- %6 = mul nsw i32 %5, 8
+ %6 = shl nsw i32 %5, 3
; With "nsw", the alloca and its bitcast can be fused:
%7 = add nsw i32 %6, 2048
; CHECK: alloca double
diff --git a/llvm/test/Transforms/InstCombine/add2.ll b/llvm/test/Transforms/InstCombine/add2.ll
index 2a63082e111..a166e5fb36f 100644
--- a/llvm/test/Transforms/InstCombine/add2.ll
+++ b/llvm/test/Transforms/InstCombine/add2.ll
@@ -219,7 +219,7 @@ define i16 @mul_add_to_mul_1(i16 %x) {
%add2 = add nsw i16 %x, %mul1
ret i16 %add2
; CHECK-LABEL: @mul_add_to_mul_1(
-; CHECK-NEXT: %add2 = mul nsw i16 %x, 9
+; CHECK-NEXT: %add2 = mul i16 %x, 9
; CHECK-NEXT: ret i16 %add2
}
@@ -228,7 +228,7 @@ define i16 @mul_add_to_mul_2(i16 %x) {
%add2 = add nsw i16 %mul1, %x
ret i16 %add2
; CHECK-LABEL: @mul_add_to_mul_2(
-; CHECK-NEXT: %add2 = mul nsw i16 %x, 9
+; CHECK-NEXT: %add2 = mul i16 %x, 9
; CHECK-NEXT: ret i16 %add2
}
@@ -248,7 +248,7 @@ define i16 @mul_add_to_mul_4(i16 %a) {
%add = add nsw i16 %mul1, %mul2
ret i16 %add
; CHECK-LABEL: @mul_add_to_mul_4(
-; CHECK-NEXT: %add = mul nsw i16 %a, 9
+; CHECK-NEXT: %add = mul i16 %a, 9
; CHECK-NEXT: ret i16 %add
}
diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll
index 891fcaa68fd..7d6a855d58e 100644
--- a/llvm/test/Transforms/InstCombine/cast.ll
+++ b/llvm/test/Transforms/InstCombine/cast.ll
@@ -810,7 +810,7 @@ define double @test71(double *%p, i64 %i) {
define double @test72(double *%p, i32 %i) {
; CHECK-LABEL: @test72(
- %so = mul nsw i32 %i, 8
+ %so = shl nsw i32 %i, 3
%o = sext i32 %so to i64
; CHECK-NEXT: sext i32 %i to i64
%q = bitcast double* %p to i8*
@@ -825,7 +825,7 @@ define double @test72(double *%p, i32 %i) {
define double @test73(double *%p, i128 %i) {
; CHECK-LABEL: @test73(
- %lo = mul nsw i128 %i, 8
+ %lo = shl nsw i128 %i, 3
%o = trunc i128 %lo to i64
; CHECK-NEXT: trunc i128 %i to i64
%q = bitcast double* %p to i8*
@@ -937,7 +937,7 @@ define %s @test79(%s *%p, i64 %i, i32 %j) {
define double @test80([100 x double]* %p, i32 %i) {
; CHECK-LABEL: @test80(
- %tmp = mul nsw i32 %i, 8
+ %tmp = shl nsw i32 %i, 3
; CHECK-NEXT: sext i32 %i to i64
%q = bitcast [100 x double]* %p to i8*
%pp = getelementptr i8* %q, i32 %tmp
@@ -954,7 +954,7 @@ define double @test80_addrspacecast([100 x double] addrspace(1)* %p, i32 %i) {
; CHECK-NEXT: getelementptr [100 x double] addrspace(1)* %p
; CHECK-NEXT: load double addrspace(1)*
; CHECK-NEXT: ret double
- %tmp = mul nsw i32 %i, 8
+ %tmp = shl nsw i32 %i, 3
%q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)*
%pp = getelementptr i8 addrspace(2)* %q, i32 %tmp
%r = addrspacecast i8 addrspace(2)* %pp to double addrspace(1)*
@@ -968,7 +968,7 @@ define double @test80_addrspacecast_2([100 x double] addrspace(1)* %p, i32 %i) {
; CHECK-NEXT: addrspacecast double addrspace(1)*
; CHECK-NEXT: load double addrspace(3)*
; CHECK-NEXT: ret double
- %tmp = mul nsw i32 %i, 8
+ %tmp = shl nsw i32 %i, 3
%q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)*
%pp = getelementptr i8 addrspace(2)* %q, i32 %tmp
%r = addrspacecast i8 addrspace(2)* %pp to double addrspace(3)*
@@ -978,7 +978,7 @@ define double @test80_addrspacecast_2([100 x double] addrspace(1)* %p, i32 %i) {
define double @test80_as1([100 x double] addrspace(1)* %p, i16 %i) {
; CHECK-LABEL: @test80_as1(
- %tmp = mul nsw i16 %i, 8
+ %tmp = shl nsw i16 %i, 3
; CHECK-NEXT: sext i16 %i to i32
%q = bitcast [100 x double] addrspace(1)* %p to i8 addrspace(1)*
%pp = getelementptr i8 addrspace(1)* %q, i16 %tmp
diff --git a/llvm/test/Transforms/InstCombine/div.ll b/llvm/test/Transforms/InstCombine/div.ll
index 67c5c78cd83..26e9e336823 100644
--- a/llvm/test/Transforms/InstCombine/div.ll
+++ b/llvm/test/Transforms/InstCombine/div.ll
@@ -217,7 +217,7 @@ define i32 @test25(i32 %a) {
%div = sdiv i32 %shl, 2
ret i32 %div
; CHECK-LABEL: @test25(
-; CHECK-NEXT: %div = shl nsw i32 %a, 1
+; CHECK-NEXT: %div = shl i32 %a, 1
; CHECK-NEXT: ret i32 %div
}
@@ -226,7 +226,7 @@ define i32 @test26(i32 %a) {
%div = sdiv i32 %mul, 3
ret i32 %div
; CHECK-LABEL: @test26(
-; CHECK-NEXT: %div = shl nsw i32 %a, 2
+; CHECK-NEXT: %div = shl i32 %a, 2
; CHECK-NEXT: ret i32 %div
}
OpenPOWER on IntegriCloud