[PATCH] D113860: [NFC][InstSimplify] add test cases with base results for or-xor fold
Mehrnoosh Heidarpour via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 14 12:40:07 PST 2021
MehrHeidar created this revision.
MehrHeidar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch adds the following fold opportunity:
A|B | (A^B) --> A|B
that is reported here : https://bugs.llvm.org/show_bug.cgi?id=52479
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113860
Files:
llvm/test/Transforms/InstSimplify/or.ll
Index: llvm/test/Transforms/InstSimplify/or.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/or.ll
+++ llvm/test/Transforms/InstSimplify/or.ll
@@ -446,6 +446,34 @@
ret i32 %i5
}
+; (A | B) | (A ^ B) --> A | B
+
+define i69 @or_or_xor(i69 %A, i69 %B) {
+; CHECK-LABEL: @or_or_xor(
+; CHECK-NEXT: [[I1:%.*]] = or i69 [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[I2:%.*]] = xor i69 [[A]], [[B]]
+; CHECK-NEXT: [[I3:%.*]] = or i69 [[I1]], [[I2]]
+; CHECK-NEXT: ret i69 [[I3]]
+;
+ %i1 = or i69 %A, %B
+ %i2 = xor i69 %A, %B
+ %i3 = or i69 %i1, %i2
+ ret i69 %i3
+}
+
+define <4 x i4> @or_or_xor_commuted(<4 x i4> %A, <4 x i4> %B) {
+; CHECK-LABEL: @or_or_xor_commuted(
+; CHECK-NEXT: [[I1:%.*]] = or <4 x i4> [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[I2:%.*]] = xor <4 x i4> [[A]], [[B]]
+; CHECK-NEXT: [[I3:%.*]] = or <4 x i4> [[I2]], [[I1]]
+; CHECK-NEXT: ret <4 x i4> [[I3]]
+;
+ %i1 = or <4 x i4> %A, %B
+ %i2 = xor <4 x i4> %A, %B
+ %i3 = or <4 x i4> %i2, %i1
+ ret <4 x i4> %i3
+}
+
define i32 @shifted_all_ones(i32 %shamt) {
; CHECK-LABEL: @shifted_all_ones(
; CHECK-NEXT: ret i32 -1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113860.387124.patch
Type: text/x-patch
Size: 1180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211114/e693ba74/attachment.bin>
More information about the llvm-commits
mailing list