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

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


================
@@ -2255,7 +2255,7 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
     // This is done in other passes, but we want to be able to consume this
     // pattern in InstCombine so we can generate it without creating infinite
     // loops.
-    if (match(Op0, m_Add(m_Value(X), m_Value(Z))) &&
+    if (match(Op0, m_c_Add(m_Value(X), m_Value(Z))) &&
----------------
topperc wrote:

The entire `match(Op0, m_c_Add(m_Value(X), m_Value(Z)))` is evaluated before `match(Op1, m_c_Add(m_Value(Y), m_Specific(Z))))` is evaluated. It won't come back try Op0 again if the Op1 match fails.

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


More information about the llvm-commits mailing list