[PATCH] Added InstCombine transform for pattern "(A & B) ^ ((A ^ C) | B) -> (~A)".

David Majnemer david.majnemer at gmail.com
Fri Aug 8 09:57:11 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2519-2522
@@ -2518,2 +2518,6 @@
       return BinaryOperator::CreateOr(A, B);
+    // (A & B) ^ ((A ^ C) | B) -> (~A)
+    if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&
+        match(Op1I, m_Or(m_Xor(m_Specific(A), m_Value(C)), m_Specific(B))))
+      return BinaryOperator::CreateNot(A);
   }
----------------
This is incorrect, it should be something like:

  // (A & B) ^ ((A ^ C) | B) -> (B | C) ^ A
  if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&
      match(Op1I, m_Or(m_Xor(m_Specific(A), m_Value(C)), m_Specific(B))))
    return BinaryOperator::CreateXor(Builder->CreateOr(B, C), A);

http://reviews.llvm.org/D4828






More information about the llvm-commits mailing list