[PATCH] D159061: [InstCombine] Add tests for folding multiuse `(icmp eq/ne (or X, Y), Y)`; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 12:56:13 PDT 2023


goldstein.w.n updated this revision to Diff 556707.
goldstein.w.n added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159061/new/

https://reviews.llvm.org/D159061

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


Index: llvm/test/Transforms/InstCombine/icmp-of-or-x.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-of-or-x.ll
+++ llvm/test/Transforms/InstCombine/icmp-of-or-x.ll
@@ -377,3 +377,30 @@
   %r = icmp ugt i32 %or, %s
   ret i1 %r
 }
+
+define i1 @icmp_eq_x_invertable_y2_todo(i8 %x, i1 %y, i8 %z) {
+; CHECK-LABEL: @icmp_eq_x_invertable_y2_todo(
+; CHECK-NEXT:    [[ZZ:%.*]] = xor i8 [[Z:%.*]], -1
+; CHECK-NEXT:    [[YY:%.*]] = select i1 [[Y:%.*]], i8 7, i8 [[ZZ]]
+; CHECK-NEXT:    [[OR:%.*]] = or i8 [[YY]], [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[YY]], [[OR]]
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %zz = xor i8 %z, -1
+  %yy = select i1 %y, i8 7, i8 %zz
+  %or = or i8 %x, %yy
+  %r = icmp eq i8 %yy, %or
+  ret i1 %r
+}
+
+define i1 @icmp_eq_x_invertable_y2(i8 %x, i8 %y) {
+; CHECK-LABEL: @icmp_eq_x_invertable_y2(
+; CHECK-NEXT:    [[TMP1:%.*]] = and i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[TMP1]], 0
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %yy = xor i8 %y, -1
+  %or = or i8 %x, %yy
+  %r = icmp eq i8 %yy, %or
+  ret i1 %r
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159061.556707.patch
Type: text/x-patch
Size: 1134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230913/4124a3b8/attachment.bin>


More information about the llvm-commits mailing list