[llvm] [InstCombine] Resolve FIXME: Use commutative matchers (PR #81060)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 16:27:50 PST 2024


================
@@ -2374,31 +2375,31 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
   // (sub (or A, B) (and A, B)) --> (xor A, B)
   {
     Value *A, *B;
-    if (match(Op1, m_And(m_Value(A), m_Value(B))) &&
+    if (match(Op1, m_c_And(m_Value(A), m_Value(B))) &&
----------------
topperc wrote:

This is unnecessary. The m_And captures the first operand into A and the second operand into B. It doesn't do any other checks so it will always match the first operand order it tries. It will never try to check the other order.

https://github.com/llvm/llvm-project/pull/81060


More information about the llvm-commits mailing list