[llvm] [DAG] SDPatternMatch - Fix m_Reassociatable mismatching (PR #170061)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 10:00:35 PST 2025
================
@@ -842,6 +842,28 @@ TEST_F(SelectionDAGPatternMatchTest, matchReassociatableOp) {
EXPECT_TRUE(sd_match(
MUL, m_ReassociatableMul(m_Value(), m_Value(), m_Value(), m_Value())));
+ // (Op0 + Op1) + Op0 binds correctly, allowing commutation
+ SDValue ADD010 = DAG->getNode(ISD::ADD, DL, Int32VT, ADD01, Op0);
+ SDValue A, B;
----------------
mshockwave wrote:
> because as it currently is, the matching commutes the leaf nodes and not the patterns,
Ah that makes sense to me. Then I think we should _not_ allow m_Value(A), m_Deferred(B), m_Value(B) to match. So on this end no change is needed.
https://github.com/llvm/llvm-project/pull/170061
More information about the llvm-commits
mailing list