diff options
author | Tim Northover <tnorthover@apple.com> | 2013-09-04 11:57:17 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2013-09-04 11:57:17 +0000 |
commit | 0415b1810bbf93f434f1c561e172bf24c1cb37dc (patch) | |
tree | c2d7a5cda9e53e3e9e710e4b24749681a6ed8ac6 /test/Transforms/InstCombine | |
parent | 7bfabdac4ebf82f9f6a9ee7a00fd948f729dc7fe (diff) | |
download | external_llvm-0415b1810bbf93f434f1c561e172bf24c1cb37dc.zip external_llvm-0415b1810bbf93f434f1c561e172bf24c1cb37dc.tar.gz external_llvm-0415b1810bbf93f434f1c561e172bf24c1cb37dc.tar.bz2 |
InstCombine: allow unmasked icmps to be combined with logical ops
"(icmp op i8 A, B)" is equivalent to "(icmp op i8 (A & 0xff), B)" as a
degenerate case. Allowing this as a "masked" comparison when analysing "(icmp)
&/| (icmp)" allows us to combine them in more cases.
rdar://problem/7625728
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r-- | test/Transforms/InstCombine/icmp-logical.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp-logical.ll b/test/Transforms/InstCombine/icmp-logical.ll index c0c5a61..d5d8cbc 100644 --- a/test/Transforms/InstCombine/icmp-logical.ll +++ b/test/Transforms/InstCombine/icmp-logical.ll @@ -120,3 +120,33 @@ define i1 @masked_or_allzeroes_notoptimised(i32 %A) { ret i1 %res } +define i1 @nomask_lhs(i32 %in) { +; CHECK-LABEL: @nomask_lhs +; CHECK: [[MASK:%.*]] = and i32 %in, 1 +; CHECK: icmp eq i32 [[MASK]], 0 +; CHECK-NOT: icmp +; CHECK: ret i1 + %tst1 = icmp eq i32 %in, 0 + + %masked = and i32 %in, 1 + %tst2 = icmp eq i32 %masked, 0 + + %val = or i1 %tst1, %tst2 + ret i1 %val +} + + +define i1 @nomask_rhs(i32 %in) { +; CHECK-LABEL: @nomask_rhs +; CHECK: [[MASK:%.*]] = and i32 %in, 1 +; CHECK: icmp eq i32 [[MASK]], 0 +; CHECK-NOT: icmp +; CHECK: ret i1 + %masked = and i32 %in, 1 + %tst1 = icmp eq i32 %masked, 0 + + %tst2 = icmp eq i32 %in, 0 + + %val = or i1 %tst1, %tst2 + ret i1 %val +} |