[PATCH] D24419: [InstCombine] use commutative matchers for patterns with commutative operators

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 11:04:44 PDT 2016


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2350
+  if (match(Op1, m_c_Xor(m_Not(m_Value(A)), m_Value(B))) &&
+      match(Op0, m_c_And(m_Specific(A), m_Specific(B))))
     return BinaryOperator::CreateXor(Builder->CreateNot(A), B);
----------------
efriedma wrote:
> This isn't actually equivalent to four separate checks in the case where both operands of the xor are "not" operations.  I guess that doesn't really matter much in practice for this particular case, but we need a better approach in general.
Is it possible to have both operands 'notted'? We should always be able to fold:
  %negx = xor i32 %x, -1
  %negy = xor i32 %y, -1
  %xor = xor i32 %negx, %negy

to:
  xor i32 %x, %y

before we reach here?


https://reviews.llvm.org/D24419





More information about the llvm-commits mailing list