diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-11-18 09:31:41 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-11-18 09:31:41 +0000 |
| commit | 6fdb6b8fd4e18c0741a839a11d7dee7077bc7505 (patch) | |
| tree | 4b0da2b648a372da566f751f72b95f112d689554 /llvm/test/Transforms/InstCombine/icmp-logical.ll | |
| parent | 1a3327bb626c46c89400f3f03d39fb9bc6157d14 (diff) | |
| download | bcm5719-llvm-6fdb6b8fd4e18c0741a839a11d7dee7077bc7505.tar.gz bcm5719-llvm-6fdb6b8fd4e18c0741a839a11d7dee7077bc7505.zip | |
InstCombine: Fold away tautological masked compares
It is impossible for (x & INT_MAX) == 0 && x == INT_MAX to ever be true.
While this sort of reasoning should normally live in InstSimplify,
the machinery that derives this result is not trivial to split out.
llvm-svn: 222230
Diffstat (limited to 'llvm/test/Transforms/InstCombine/icmp-logical.ll')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-logical.ll | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-logical.ll b/llvm/test/Transforms/InstCombine/icmp-logical.ll index d5d8cbc8c26..faae2016e20 100644 --- a/llvm/test/Transforms/InstCombine/icmp-logical.ll +++ b/llvm/test/Transforms/InstCombine/icmp-logical.ll @@ -150,3 +150,23 @@ define i1 @nomask_rhs(i32 %in) { %val = or i1 %tst1, %tst2 ret i1 %val } + +define i1 @fold_mask_cmps_to_false(i32 %x) { +; CHECK-LABEL: @fold_mask_cmps_to_false +; CHECK: ret i1 false + %1 = and i32 %x, 2147483647 + %2 = icmp eq i32 %1, 0 + %3 = icmp eq i32 %x, 2147483647 + %4 = and i1 %3, %2 + ret i1 %4 +} + +define i1 @fold_mask_cmps_to_true(i32 %x) { +; CHECK-LABEL: @fold_mask_cmps_to_true +; CHECK: ret i1 true + %1 = and i32 %x, 2147483647 + %2 = icmp ne i32 %1, 0 + %3 = icmp ne i32 %x, 2147483647 + %4 = or i1 %3, %2 + ret i1 %4 +} |

