(C & X) | ~(C | Y) -> C ? X : ~Y
Details
Diff Detail
Event Timeline
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2973–2974 | This is more general than needed. Complexity canonicalization guarantees that the 'not' is operand 1. We could also check for the common operand out here for efficiency? if (match(Op0, m_And(m_Value(A), m_Value(C))) && match(Op1, m_Not(m_Or(m_Value(B), m_Value(D)))) && hasCommonOperand(A, C, B, D) && (Op0->hasOneUse() || Op1->hasOneUse())) { |
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2973–2974 | If we use hasCommonOperand we needn't call matchSelectFromAndOr I think. |
LGTM - see inline comment for a minor adjustment.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2565 | The name "SelectNotFalseVal" is confusing to me. I would prefer to name this "InvertFalseVal". Then adjust the code comment above to say: /// When InvertFalseVal is set to true, we try to match the pattern /// where we have peeked through a 'not' op and A and B are the same: /// (A & C) | ~(A | D) --> (A & C) | (~A & ~D) --> A' ? C : ~D |
Rename AisB ? It seems to suggest that A is known to be equivalent to B.