OSDN Git Service

[NFC][InstCombine] icmp-logical.ll: add a few more tests.
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 11 Jul 2018 10:31:12 +0000 (10:31 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 11 Jul 2018 10:31:12 +0000 (10:31 +0000)
The @masked_and_notA_slightly_optimized and @masked_or_A
will break when PR38123 will be fixed:
https://rise4fun.com/Alive/Rny
Clearly, they aren't optimized currently.

https://rise4fun.com/Alive/ERo

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336784 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/icmp-logical.ll

index 728ec83..94ab8b5 100644 (file)
@@ -71,6 +71,21 @@ define i1 @masked_and_notA(i32 %A) {
   ret i1 %res
 }
 
+define i1 @masked_and_notA_slightly_optimized(i32 %A) {
+; CHECK-LABEL: @masked_and_notA_slightly_optimized(
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ugt i32 [[A:%.*]], 7
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 39
+; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], [[A]]
+; CHECK-NEXT:    [[RES:%.*]] = and i1 [[TMP0]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %tmp0 = icmp uge i32 %A, 8
+  %mask2 = and i32 %A, 39
+  %tst2 = icmp ne i32 %mask2, %A
+  %res = and i1 %tmp0, %tst2
+  ret i1 %res
+}
+
 define i1 @masked_or_A(i32 %A) {
 ; CHECK-LABEL: @masked_or_A(
 ; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A:%.*]], 39
@@ -85,6 +100,21 @@ define i1 @masked_or_A(i32 %A) {
   ret i1 %res
 }
 
+define i1 @masked_or_A_slightly_optimized(i32 %A) {
+; CHECK-LABEL: @masked_or_A_slightly_optimized(
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ult i32 [[A:%.*]], 8
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 39
+; CHECK-NEXT:    [[TST2:%.*]] = icmp eq i32 [[MASK2]], [[A]]
+; CHECK-NEXT:    [[RES:%.*]] = or i1 [[TMP0]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %tmp0 = icmp ult i32 %A, 8
+  %mask2 = and i32 %A, 39
+  %tst2 = icmp eq i32 %mask2, %A
+  %res = or i1 %tmp0, %tst2
+  ret i1 %res
+}
+
 define i1 @masked_or_allzeroes_notoptimised(i32 %A) {
 ; CHECK-LABEL: @masked_or_allzeroes_notoptimised(
 ; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 15