[PATCH] D142090: [InstCombine] precommit tests for D140666

Yingchi Long via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 01:23:27 PST 2023


inclyc created this revision.
Herald added a project: All.
inclyc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142090

Files:
  llvm/test/Transforms/InstCombine/icmp-logical.ll


Index: llvm/test/Transforms/InstCombine/icmp-logical.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-logical.ll
+++ llvm/test/Transforms/InstCombine/icmp-logical.ll
@@ -277,6 +277,89 @@
   ret i1 %res
 }
 
+
+define i1 @masked_or_eq(i32 %A) {
+; CHECK-LABEL: @masked_or_eq(
+; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 15
+; CHECK-NEXT:    [[TST1:%.*]] = icmp eq i32 [[MASK1]], 3
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 255
+; CHECK-NEXT:    [[TST2:%.*]] = icmp eq i32 [[MASK2]], 243
+; CHECK-NEXT:    [[RES:%.*]] = or i1 [[TST1]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %mask1 = and i32 %A, 15 ; 0x0f
+  %tst1 = icmp eq i32 %mask1, 3 ; 0x03
+  %mask2 = and i32 %A, 255 ; 0xff
+  %tst2 = icmp eq i32 %mask2, 243; 0xf3
+  %res = or i1 %tst1, %tst2
+  ret i1 %res
+}
+
+define i1 @masked_or_eq_contradict_notoptimized(i32 %A) {
+; CHECK-LABEL: @masked_or_eq_contradict_notoptimized(
+; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 15
+; CHECK-NEXT:    [[TST1:%.*]] = icmp eq i32 [[MASK1]], 3
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 255
+; CHECK-NEXT:    [[TST2:%.*]] = icmp eq i32 [[MASK2]], 242
+; CHECK-NEXT:    [[RES:%.*]] = or i1 [[TST1]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %mask1 = and i32 %A, 15 ; 0x0f
+  %tst1 = icmp eq i32 %mask1, 3 ; 0x03
+  %mask2 = and i32 %A, 255 ; 0xff
+  %tst2 = icmp eq i32 %mask2, 242; 0xf2
+  %res = or i1 %tst1, %tst2
+  ret i1 %res
+}
+
+define i1 @masked_and_ne(i32 %A) {
+; CHECK-LABEL: @masked_and_ne(
+; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 15
+; CHECK-NEXT:    [[TST1:%.*]] = icmp ne i32 [[MASK1]], 3
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 255
+; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], 243
+; CHECK-NEXT:    [[RES:%.*]] = and i1 [[TST1]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %mask1 = and i32 %A, 15 ; 0x0f
+  %tst1 = icmp ne i32 %mask1, 3 ; 0x03
+  %mask2 = and i32 %A, 255 ; 0xff
+  %tst2 = icmp ne i32 %mask2, 243 ; 0xf3
+  %res = and i1 %tst1, %tst2
+  ret i1 %res
+}
+
+define i1 @masked_and_ne_contradict_notoptimized(i32 %A) {
+; CHECK-LABEL: @masked_and_ne_contradict_notoptimized(
+; CHECK-NEXT:    [[MASK1:%.*]] = and i32 [[A:%.*]], 15
+; CHECK-NEXT:    [[TST1:%.*]] = icmp ne i32 [[MASK1]], 3
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A]], 255
+; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], 242
+; CHECK-NEXT:    [[RES:%.*]] = and i1 [[TST1]], [[TST2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %mask1 = and i32 %A, 15 ; 0x0f
+  %tst1 = icmp ne i32 %mask1, 3 ; 0x03
+  %mask2 = and i32 %A, 255 ; 0xff
+  %tst2 = icmp ne i32 %mask2, 242 ; 0xf2
+  %res = and i1 %tst1, %tst2
+  ret i1 %res
+}
+
+define i1 @masked_and_expected_false(i32 %A) {
+; CHECK-LABEL: @masked_and_expected_false(
+; CHECK-NEXT:    [[MASK2:%.*]] = and i32 [[A:%.*]], 255
+; CHECK-NEXT:    [[TST2:%.*]] = icmp ne i32 [[MASK2]], 242
+; CHECK-NEXT:    ret i1 [[TST2]]
+;
+  %mask1 = and i32 %A, 3 ; 0x0f
+  %tst1 = icmp ne i32 %mask1, 15 ; 0x03
+  %mask2 = and i32 %A, 255 ; 0xff
+  %tst2 = icmp ne i32 %mask2, 242 ; 0xf2
+  %res = and i1 %tst1, %tst2
+  ret i1 %res
+}
+
 define i1 @nomask_lhs(i32 %in) {
 ; CHECK-LABEL: @nomask_lhs(
 ; CHECK-NEXT:    [[MASKED:%.*]] = and i32 [[IN:%.*]], 1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142090.490410.patch
Type: text/x-patch
Size: 3286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/3c9c4d22/attachment-0001.bin>


More information about the llvm-commits mailing list