[llvm] [LSR] Clean up code using SCEVPatternMatch (NFC) (PR #145556)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 27 08:39:20 PDT 2025


================
@@ -6478,13 +6467,10 @@ struct SCEVDbgValueBuilder {
   /// Components of the expression are omitted if they are an identity function.
   /// Chain (non-affine) SCEVs are not supported.
   bool SCEVToValueExpr(const llvm::SCEVAddRecExpr &SAR, ScalarEvolution &SE) {
-    assert(SAR.isAffine() && "Expected affine SCEV");
-    // TODO: Is this check needed?
-    if (isa<SCEVAddRecExpr>(SAR.getStart()))
-      return false;
-
-    const SCEV *Start = SAR.getStart();
-    const SCEV *Stride = SAR.getStepRecurrence(SE);
+    const SCEV *Start, *Stride;
+    [[maybe_unused]] bool Match =
+        match(&SAR, m_scev_AffineAddRec(m_SCEV(Start), m_SCEV(Stride)));
----------------
nikic wrote:

Not a fan of using match() just to unpack, esp. as the unpack here is trivial.

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


More information about the llvm-commits mailing list