[llvm] [DAG] SDPatternMatch - Fix m_Reassociatable mismatching (PR #170061)
Artur Bermond Torres via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 4 13:53:55 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;
+ EXPECT_TRUE(sd_match(
+ ADD010, m_ReassociatableAdd(m_Value(A), m_Value(B), m_Deferred(A))));
+ EXPECT_EQ(Op0, A);
+ EXPECT_EQ(Op1, B);
+ EXPECT_NE(A, B);
----------------
bermondd wrote:
yeah, I was thinking of whether I should keep it or remove it. When both tests above that one pass then this one is indeed redundant, but if one of them fails, the outcome of this third check could provide some insight as to what happened. But it also does clutter the code a bit, so I'm very much not opposed to removing it.
https://github.com/llvm/llvm-project/pull/170061
More information about the llvm-commits
mailing list