[PATCH] InstCombine ((A | ~B) ^ (~A | B)) to A ^ B
David Majnemer
david.majnemer at gmail.com
Wed Aug 13 16:00:48 PDT 2014
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2511-2538
@@ -2510,2 +2510,30 @@
}
+ // (A | ~B) ^ (~A | B) -> A ^ B
+ // (A | ~B) ^ (B | ~A) -> A ^ B
+ if (match(Op0I, m_Or(m_Value(A), m_Not(m_Value(B)))) &&
+ (match(Op1I, m_Or(m_Not(m_Specific(A)), m_Specific(B))) ||
+ match(Op1I, m_Or(m_Specific(B), m_Not(m_Specific(A)))))) {
+ return BinaryOperator::CreateXor(A, B);
+ }
+ // (~B | A) ^ (~A | B) -> A ^ B
+ // (~B | A) ^ (B | ~A) -> A ^ B
+ if (match(Op0I, m_Or(m_Not(m_Value(B)), m_Value(A))) &&
+ (match(Op1I, m_Or(m_Not(m_Specific(A)), m_Specific(B))) ||
+ match(Op1I, m_Or(m_Specific(B), m_Not(m_Specific(A)))))) {
+ return BinaryOperator::CreateXor(A, B);
+ }
+ // (~A | B) ^ (A | ~B) -> A ^ B
+ // (~A | B) ^ (~B | A) -> A ^ B
+ if (match(Op0I, m_Or(m_Not(m_Value(A)), m_Value(B))) &&
+ (match(Op1I, m_Or(m_Specific(A), m_Not(m_Specific(B)))) ||
+ match(Op1I, m_Or(m_Not(m_Specific(B)), m_Specific(A))))) {
+ return BinaryOperator::CreateXor(A, B);
+ }
+ // (B | ~A) ^ (A | ~B) -> A ^ B
+ // (B | ~A) ^ (~B | A) -> A ^ B
+ if (match(Op0I, m_Or(m_Value(B), m_Not(m_Value(A)))) &&
+ (match(Op1I, m_Or(m_Specific(A), m_Not(m_Specific(B)))) ||
+ match(Op1I, m_Or(m_Not(m_Specific(B)), m_Specific(A))))) {
+ return BinaryOperator::CreateXor(A, B);
+ }
// (A ^ B)^(A | B) -> A & B
----------------
You have what appear to be eight different patterns you are trying to match. Are you sure we need all of them? What happens if you ran a reassociate pass first?
http://reviews.llvm.org/D4883
More information about the llvm-commits
mailing list