aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-04-12 17:25:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-04-12 17:25:07 +0000
commitfb1cd69b9022cb48dc3b054656cd015474d4f229 (patch)
tree98197c0389d99618e0b7818bf5bac0d8d24c3800 /test/Transforms/InstCombine
parentdda4b6bf25dbdb3051513eb59885b3f3de8fe3b0 (diff)
downloadexternal_llvm-fb1cd69b9022cb48dc3b054656cd015474d4f229.zip
external_llvm-fb1cd69b9022cb48dc3b054656cd015474d4f229.tar.gz
external_llvm-fb1cd69b9022cb48dc3b054656cd015474d4f229.tar.bz2
Simplify (A & ~B) in icmp if A is a power of 2
The transform will execute like so: (A & ~B) == 0 --> (A & B) != 0 (A & ~B) != 0 --> (A & B) == 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r--test/Transforms/InstCombine/icmp.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll
index 28fa33b..74adbba 100644
--- a/test/Transforms/InstCombine/icmp.ll
+++ b/test/Transforms/InstCombine/icmp.ll
@@ -938,3 +938,29 @@ define i1 @icmp_sub57_sge_sub20(i32 %x, i32 %y) {
%cmp = icmp sge i32 %1, %2
ret i1 %cmp
}
+
+; CHECK: @icmp_and_shl_neg_ne_0
+; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
+; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_and_shl_neg_ne_0(i32 %A, i32 %B) {
+ %neg = xor i32 %A, -1
+ %shl = shl i32 1, %B
+ %and = and i32 %shl, %neg
+ %cmp = icmp ne i32 %and, 0
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_and_shl_neg_eq_0
+; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
+; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_and_shl_neg_eq_0(i32 %A, i32 %B) {
+ %neg = xor i32 %A, -1
+ %shl = shl i32 1, %B
+ %and = and i32 %shl, %neg
+ %cmp = icmp eq i32 %and, 0
+ ret i1 %cmp
+}