[PATCH] D86363: InstCombine transform pattern "(A ^ B) | ~(A | B) -> ~(A & B)" added
Jaydeep Chauhan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 03:32:15 PDT 2020
Jac1494 updated this revision to Diff 287169.
Jac1494 added a comment.
Addressed @lebedev.ri review comments.Thanks
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86363/new/
https://reviews.llvm.org/D86363
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/or-and.ll
Index: llvm/test/Transforms/InstCombine/or-and.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/or-and.ll
@@ -0,0 +1,14 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+; (A ^ B) | ~(A | B) -> ~(A & B)
+define i32 @test1(i32 %0, i32 %1) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: %3 = and i32 %0, %1
+; CHECK-NEXT: %4 = xor i32 %3, -1
+; CHECK-NEXT: ret i32 %4
+ %3 = xor i32 %0, %1
+ %4 = or i32 %0, %1
+ %5 = xor i32 %4, -1
+ %6 = or i32 %3, %5
+ ret i32 %6
+}
Index: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2694,6 +2694,11 @@
}
}
+ // (A ^ B) | ~(A | B) -> ~(A & B)
+ if (match(&I, m_c_Or(m_Xor(m_Value(A), m_Value(B)),
+ m_Not(m_c_Or(m_Deferred(A), m_Deferred(B))))))
+ return BinaryOperator::CreateNot(Builder.CreateAnd(A, B));
+
// (A ^ B) | ((B ^ C) ^ A) -> (A ^ B) | C
if (match(Op0, m_Xor(m_Value(A), m_Value(B))))
if (match(Op1, m_Xor(m_Xor(m_Specific(B), m_Value(C)), m_Specific(A))))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86363.287169.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200822/205c57da/attachment.bin>
More information about the llvm-commits
mailing list