[PATCH] D24419: [InstCombine] use commutative matchers for patterns with commutative operators
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 11:29:07 PDT 2016
efriedma 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
> xor i32 %x, %y
> before we reach here?
Yes, in this particular case, it probably doesn't matter. I don't want to have to reason that out for every possible use of commuted patterns, though.
More information about the llvm-commits