[llvm] [DAG] SDPatternMatch - Fix m_Reassociatable mismatching (PR #170061)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 16:35:20 PST 2025


================
@@ -1339,21 +1332,31 @@ template <typename... PatternTs> struct ReassociatableOpc_match {
     }
   }
 
+  // Searchs for a matching leaf for every sub-pattern.
+  template <typename MatchContext, typename PatternHd, typename... PatternTl>
   [[nodiscard]] inline bool
-  reassociatableMatchHelper(ArrayRef<SmallBitVector> Matches,
-                            SmallBitVector &Used, size_t Curr = 0) {
-    if (Curr == Matches.size())
-      return true;
-    for (size_t Match = 0, N = Matches[Curr].size(); Match < N; Match++) {
-      if (!Matches[Curr][Match] || Used[Match])
+  reassociatableMatchHelper(const MatchContext &Ctx,
+                            SmallVector<SDValue> &Leaves, SmallBitVector &Used,
----------------
mshockwave wrote:

`Leaves` isn't modified in the function body right? then I think we can use `ArrayRef` here.

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


More information about the llvm-commits mailing list