diff options
author | Nadav Rotem <nrotem@apple.com> | 2013-01-30 06:35:22 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2013-01-30 06:35:22 +0000 |
commit | cc687faba373e6aa3cefe594bd9f3212e18617eb (patch) | |
tree | a53df8faf4e5c5121303786d1805606a54407be2 /test | |
parent | 581126e4a1daf5e7e6203bf81769f96bea25e601 (diff) | |
download | external_llvm-cc687faba373e6aa3cefe594bd9f3212e18617eb.zip external_llvm-cc687faba373e6aa3cefe594bd9f3212e18617eb.tar.gz external_llvm-cc687faba373e6aa3cefe594bd9f3212e18617eb.tar.bz2 |
InstCombine: canonicalize sext-and --> select
sext-not-and --> select.
Patch by Muhammad Tauqir Ahmad.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173901 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstCombine/logical-select.ll | 30 | ||||
-rw-r--r-- | test/Transforms/InstCombine/mul.ll | 5 | ||||
-rw-r--r-- | test/Transforms/InstCombine/vector-casts.ll | 3 |
3 files changed, 24 insertions, 14 deletions
diff --git a/test/Transforms/InstCombine/logical-select.ll b/test/Transforms/InstCombine/logical-select.ll index bb59817..07a326b 100644 --- a/test/Transforms/InstCombine/logical-select.ll +++ b/test/Transforms/InstCombine/logical-select.ll @@ -10,8 +10,10 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %j = or i32 %g, %i ret i32 %j ; CHECK: %e = icmp slt i32 %a, %b -; CHECK: %j = select i1 %e, i32 %c, i32 %d -; CHECK: ret i32 %j +; CHECK-NEXT: %g = select i1 %e, i32 %c, i32 0 +; CHECK-NEXT: %i = select i1 %e, i32 0, i32 %d +; CHECK-NEXT: %j = or i32 %g, %i +; CHECK-NEXT: ret i32 %j } define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %e = icmp slt i32 %a, %b @@ -22,8 +24,10 @@ define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %j = or i32 %i, %g ret i32 %j ; CHECK: %e = icmp slt i32 %a, %b -; CHECK: %j = select i1 %e, i32 %c, i32 %d -; CHECK: ret i32 %j +; CHECK-NEXT: %g = select i1 %e, i32 %c, i32 0 +; CHECK-NEXT: %i = select i1 %e, i32 0, i32 %d +; CHECK-NEXT: %j = or i32 %i, %g +; CHECK-NEXT: ret i32 %j } define i32 @goo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { @@ -36,8 +40,10 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: %1 = select i1 %0, i32 %c, i32 0 +; CHECK-NEXT: %2 = select i1 %0, i32 0, i32 %d +; CHECK-NEXT: %3 = or i32 %1, %2 +; CHECK-NEXT: ret i32 %3 } define i32 @poo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { entry: @@ -49,8 +55,10 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: %1 = select i1 %0, i32 %c, i32 0 +; CHECK-NEXT: %2 = select i1 %0, i32 0, i32 %d +; CHECK-NEXT: %3 = or i32 %1, %2 +; CHECK-NEXT: ret i32 %3 } define i32 @par(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { @@ -63,6 +71,8 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: %1 = select i1 %0, i32 %c, i32 0 +; CHECK-NEXT: %2 = select i1 %0, i32 0, i32 %d +; CHECK-NEXT: %3 = or i32 %1, %2 +; CHECK-NEXT: ret i32 %3 } diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll index 34ce088..16213b8 100644 --- a/test/Transforms/InstCombine/mul.ll +++ b/test/Transforms/InstCombine/mul.ll @@ -138,9 +138,8 @@ define i32 @test16(i32 %b, i1 %c) { ; e = b & (a >> 31) %e = mul i32 %d, %b ; <i32> [#uses=1] ret i32 %e -; CHECK: [[TEST16:%.*]] = sext i1 %c to i32 -; CHECK-NEXT: %e = and i32 %1, %b -; CHECK-NEXT: ret i32 %e +; CHECK: [[TEST16:%.*]] = select i1 %c, i32 %b, i32 0 +; CHECK-NEXT: ret i32 [[TEST16]] } ; X * Y (when Y is 0 or 1) --> x & (0-Y) diff --git a/test/Transforms/InstCombine/vector-casts.ll b/test/Transforms/InstCombine/vector-casts.ll index 7bbf53c..2f2990b 100644 --- a/test/Transforms/InstCombine/vector-casts.ll +++ b/test/Transforms/InstCombine/vector-casts.ll @@ -64,7 +64,8 @@ entry: ; CHECK: @test5 ; CHECK: sext <4 x i1> %cmp to <4 x i32> -; CHECK: sext <4 x i1> %cmp4 to <4 x i32> +; The sext-and pair is canonicalized to a select. +; CHECK: select <4 x i1> %cmp4, <4 x i32> %sext, <4 x i32> zeroinitializer } |