diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-12-20 03:04:38 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-20 03:04:38 +0000 |
| commit | 0b6a0b02573bdf62eb3f0b000cfd7c7fcdbc1ccb (patch) | |
| tree | 2da52620ca4fb7e1f3d8fe10f6438f4e3ad2dcee /llvm/test | |
| parent | 2cb463ed080fe95c683dfe2212a6215a0c8b2803 (diff) | |
| download | bcm5719-llvm-0b6a0b02573bdf62eb3f0b000cfd7c7fcdbc1ccb.tar.gz bcm5719-llvm-0b6a0b02573bdf62eb3f0b000cfd7c7fcdbc1ccb.zip | |
InstSimplify: Optimize away pointless comparisons
(X & INT_MIN) ? X & INT_MAX : X into X & INT_MAX
(X & INT_MIN) ? X : X & INT_MAX into X
(X & INT_MIN) ? X | INT_MIN : X into X
(X & INT_MIN) ? X : X | INT_MIN into X | INT_MIN
llvm-svn: 224669
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index b30416e9d26..1d45e5728e6 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -31,6 +31,82 @@ define i32 @test3(i32 %x) { ; CHECK: ret i32 %[[and]] } +define i32 @test4(i32 %X) { + %cmp = icmp slt i32 %X, 0 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %X, i32 %or + ret i32 %cond +; CHECK-LABEL: @test4 +; CHECK: %[[or:.*]] = or i32 %X, -2147483648 +; CHECK: ret i32 %[[or]] +} + +define i32 @test5(i32 %X) { + %cmp = icmp slt i32 %X, 0 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %or, i32 %X + ret i32 %cond +; CHECK-LABEL: @test5 +; CHECK: ret i32 %X +} + +define i32 @test6(i32 %X) { + %cmp = icmp slt i32 %X, 0 + %and = and i32 %X, 2147483647 + %cond = select i1 %cmp, i32 %and, i32 %X + ret i32 %cond +; CHECK-LABEL: @test6 +; CHECK: %[[and:.*]] = and i32 %X, 2147483647 +; CHECK: ret i32 %[[and]] +} + +define i32 @test7(i32 %X) { + %cmp = icmp slt i32 %X, 0 + %and = and i32 %X, 2147483647 + %cond = select i1 %cmp, i32 %X, i32 %and + ret i32 %cond +; CHECK-LABEL: @test7 +; CHECK: ret i32 %X +} + +define i32 @test8(i32 %X) { + %cmp = icmp sgt i32 %X, -1 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %X, i32 %or + ret i32 %cond +; CHECK-LABEL: @test8 +; CHECK: ret i32 %X +} + +define i32 @test9(i32 %X) { + %cmp = icmp sgt i32 %X, -1 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %or, i32 %X + ret i32 %cond +; CHECK-LABEL: @test9 +; CHECK: %[[or:.*]] = or i32 %X, -2147483648 +; CHECK: ret i32 %[[or]] +} + +define i32 @test10(i32 %X) { + %cmp = icmp sgt i32 %X, -1 + %and = and i32 %X, 2147483647 + %cond = select i1 %cmp, i32 %and, i32 %X + ret i32 %cond +; CHECK-LABEL: @test10 +; CHECK: ret i32 %X +} + +define i32 @test11(i32 %X) { + %cmp = icmp sgt i32 %X, -1 + %and = and i32 %X, 2147483647 + %cond = select i1 %cmp, i32 %X, i32 %and + ret i32 %cond +; CHECK-LABEL: @test11 +; CHECK: %[[and:.*]] = and i32 %X, 2147483647 +; CHECK: ret i32 %[[and]] +} + ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8( ; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %x, 8 ; CHECK-NEXT: ret i32 [[OR]] |

