[llvm] [SCEVPatternMatch] Extend m_scev_AffineAddRec with Loop (PR #141132)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu May 22 13:28:23 PDT 2025


================
@@ -162,13 +163,18 @@ template <typename SCEVTy, typename Op0_t, typename Op1_t>
 struct SCEVBinaryExpr_match {
   Op0_t Op0;
   Op1_t Op1;
+  const Loop *L;
 
-  SCEVBinaryExpr_match(Op0_t Op0, Op1_t Op1) : Op0(Op0), Op1(Op1) {}
+  SCEVBinaryExpr_match(Op0_t Op0, Op1_t Op1, const Loop *L = nullptr)
+      : Op0(Op0), Op1(Op1), L(L) {}
 
   bool match(const SCEV *S) const {
     auto *E = dyn_cast<SCEVTy>(S);
+    bool LoopMatches = true;
+    if constexpr (std::is_same_v<SCEVTy, SCEVAddRecExpr>)
----------------
nikic wrote:

I'd prefer to make this a separate matcher from SCEVBinaryExpr_match.

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


More information about the llvm-commits mailing list