This is my first time using the commutable matchers so wanted to make sure I was doing it right.
Are there any other matcher tricks to further shrink this? Can we commute the whole match so we don't have to LHS and RHS separately?
Differential D31680
[InstCombine] Use commutable and/or/xor matchers to simplify some code craig.topper on Apr 4 2017, 3:02 PM. Authored by
Details This is my first time using the commutable matchers so wanted to make sure I was doing it right. Are there any other matcher tricks to further shrink this? Can we commute the whole match so we don't have to LHS and RHS separately?
Diff Detail
Event TimelineComment Actions This is the minimum improvement, but we can do better. :)
Value *A, *B, *C, *D; if (match(&I, m_c_Add(m_Xor(m_Value(A), m_Value(B)), m_And(m_Value(C), m_Value(D)))) && ((A == C && B == D) || (A == D && B == C))) return BinaryOperator::CreateOr(A, B); Comment Actions I think this is a decent cleanup per-se, makes the code more readable, so it can go in. I agree with Sanjay it can be improved, but that can be left as a follow-up. |