[PATCH] D124709: [InstCombine][NFC] Add baseline tests for folds of ((A&B)^C)|B
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 18:53:10 PDT 2022
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: fhahn, nikic, craig.topper.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a subscriber: StephenFan.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: LLVM.
Baseline tests (preparations to address https://github.com/llvm/llvm-project/issues/55169 ).
Test plan: ninja check-llvm
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124709
Files:
llvm/test/Transforms/InstCombine/and-xor-or.ll
Index: llvm/test/Transforms/InstCombine/and-xor-or.ll
===================================================================
--- llvm/test/Transforms/InstCombine/and-xor-or.ll
+++ llvm/test/Transforms/InstCombine/and-xor-or.ll
@@ -168,6 +168,36 @@
ret i64 %3
}
+; ((x & y) + z) | y -> (z | y)
+
+define i64 @and_xor_or1(i64 %x, i64 %y, i64 %z) {
+; CHECK-LABEL: @and_xor_or1(
+; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = xor i64 [[TMP1]], [[Z:%.*]]
+; CHECK-NEXT: [[TMP3:%.*]] = or i64 [[TMP2]], [[Y]]
+; CHECK-NEXT: ret i64 [[TMP3]]
+;
+ %1 = and i64 %x, %y
+ %2 = xor i64 %1, %z
+ %3 = or i64 %2, %y
+ ret i64 %3
+}
+
+; y | ((x & y) + z) -> (z | y)
+
+define i64 @and_xor_or2(i64 %x, i64 %y, i64 %z) {
+; CHECK-LABEL: @and_xor_or2(
+; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = xor i64 [[TMP1]], [[Z:%.*]]
+; CHECK-NEXT: [[TMP3:%.*]] = or i64 [[TMP2]], [[Y]]
+; CHECK-NEXT: ret i64 [[TMP3]]
+;
+ %1 = and i64 %x, %y
+ %2 = xor i64 %1, %z
+ %3 = or i64 %y, %2
+ ret i64 %3
+}
+
; PR37098 - https://bugs.llvm.org/show_bug.cgi?id=37098
; Reassociate bitwise logic to eliminate a shift.
; There are 4 commuted * 3 shift ops * 3 logic ops = 36 potential variations of this fold.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124709.426202.patch
Type: text/x-patch
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220430/09e26aae/attachment.bin>
More information about the llvm-commits
mailing list