[PATCH] D154384: [InstCombine] added icmp or xor tests

Maksim Kita via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 11:46:33 PDT 2023


kitaisreal created this revision.
kitaisreal added a reviewer: goldstein.w.n.
kitaisreal added projects: All, LLVM.
kitaisreal requested review of this revision.
Herald added a subscriber: llvm-commits.

Added tests from https://reviews.llvm.org/D154306.


https://reviews.llvm.org/D154384

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


Index: llvm/test/Transforms/InstCombine/icmp-or.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-or.ll
+++ llvm/test/Transforms/InstCombine/icmp-or.ll
@@ -363,3 +363,78 @@
   %r = icmp sgt i8 %or, -1
   ret i1 %r
 }
+
+define i1 @icmp_or_xor_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2(
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i64 %y2, %x2
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i64 %y1, %x1
+; CHECK-NEXT:    [[CMP:%.*]] = and i1 [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %xor = xor i64 %y1, %x1
+  %xor1 = xor i64 %y2, %x2
+  %or = or i64 %xor1, %xor
+  %cmp = icmp eq i64 %or, 0
+  ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_3_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_1(
+; CHECK-NEXT:    [[XOR1:%.*]] = xor i64 %y1, %x1
+; CHECK-NEXT:    [[XOR2:%.*]] = xor i64 %y2, %x2
+; CHECK-NEXT:    [[OR1:%.*]] = or i64 [[XOR2]], [[XOR1]]
+; CHECK-NEXT:    [[XOR3:%.*]] = xor i64 %y3, %x3
+; CHECK-NEXT:    [[OR2:%.*]] = or i64 [[OR1]], [[XOR3]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[OR2]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %xor = xor i64 %y1, %x1
+  %xor1 = xor i64 %y2, %x2
+  %or = or i64 %xor1, %xor
+  %xor2 = xor i64 %y3, %x3
+  %or1 = or i64 %or, %xor2
+  %cmp = icmp eq i64 %or1, 0
+  ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_3_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_2(
+; CHECK-NEXT:    [[XOR1:%.*]] = xor i64 %y1, %x1
+; CHECK-NEXT:    [[XOR2:%.*]] = xor i64 %y2, %x2
+; CHECK-NEXT:    [[OR1:%.*]] = or i64 [[XOR2]], [[XOR1]]
+; CHECK-NEXT:    [[XOR3:%.*]] = xor i64 %y3, %x3
+; CHECK-NEXT:    [[OR2:%.*]] = or i64 [[XOR3]], [[OR1]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[OR2]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %xor = xor i64 %y1, %x1
+  %xor1 = xor i64 %y2, %x2
+  %or = or i64 %xor1, %xor
+  %xor2 = xor i64 %y3, %x3
+  %or1 = or i64 %xor2, %or
+  %cmp = icmp eq i64 %or1, 0
+  ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_4(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
+; CHECK-LABEL: @icmp_or_xor_4(
+; CHECK-NEXT:    [[XOR1:%.*]] = xor i64 %y1, %x1
+; CHECK-NEXT:    [[XOR2:%.*]] = xor i64 %y2, %x2
+; CHECK-NEXT:    [[OR1:%.*]] = or i64 [[XOR2]], [[XOR1]]
+; CHECK-NEXT:    [[XOR3:%.*]] = xor i64 %y3, %x3
+; CHECK-NEXT:    [[XOR4:%.*]] = xor i64 %y4, %x4
+; CHECK-NEXT:    [[OR2:%.*]] = or i64 [[XOR4]], [[XOR3]]
+; CHECK-NEXT:    [[OR3:%.*]] = or i64 [[OR1]], [[OR2]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[OR3]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %xor = xor i64 %y1, %x1
+  %xor1 = xor i64 %y2, %x2
+  %or = or i64 %xor1, %xor
+  %xor2 = xor i64 %y3, %x3
+  %xor3 = xor i64 %y4, %x4
+  %or1 = or i64 %xor3, %xor2
+  %or2 = or i64 %or, %or1
+  %cmp = icmp eq i64 %or2, 0
+  ret i1 %cmp
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154384.536857.patch
Type: text/x-patch
Size: 2877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230703/d1cf7267/attachment.bin>


More information about the llvm-commits mailing list