Issue 169645
Summary [DAG] SDPatternMatch - m_Reassociatable mismatches
Labels good first issue, llvm:SelectionDAG
Assignees
Reporter RKSimon
    Noticed while working on #169644

If we attempt to match a m_ReassociatableAdd pattern containing both the m_Value and m_Deferred for a given SDValue, the matcher gets corrupted and fails to match the correct SDValue pairs

foldAddToAvg:
```
  if ((!LegalOperations || hasOperation(ISD::AVGFLOORU, VT)) &&
      (sd_match(N,
 m_Add(m_And(m_Value(A), m_Value(B)),
 m_Srl(m_Xor(m_Deferred(A), m_Deferred(B)), m_One()))) ||
       sd_match(N, m_ReassociatableAdd(
                       m_Srl(m_Value(A), m_One()), m_Srl(m_Value(B), m_One()),
 m_ReassociatableAnd(m_Deferred(A), m_Deferred(B),
 m_One()))))) {
    return DAG.getNode(ISD::AVGFLOORU, DL, VT, A, B);
  }
```

in this case we end up with the same SDValue being matched for A and B.

Hopefully this is just an evaluation ordering issue, but there might be something else going on.

Good first issue for someone who likes template programming!
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to