[llvm] [IVDesc] Use SCEVPatternMatch to improve code (NFC) (PR #168397)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 02:20:34 PST 2025


================
@@ -1614,41 +1618,26 @@ bool InductionDescriptor::isInductionPHI(
 
   // Check that the PHI is consecutive.
   const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
-  const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PhiScev);
-
-  if (!AR) {
+  const SCEV *Step;
+  if (!match(PhiScev, m_scev_AffineAddRec(m_SCEV(), m_SCEV(Step),
+                                          m_SpecificLoop(TheLoop)))) {
     LLVM_DEBUG(dbgs() << "LV: PHI is not a poly recurrence.\n");
     return false;
   }
 
-  if (AR->getLoop() != TheLoop) {
-    // FIXME: We should treat this as a uniform. Unfortunately, we
-    // don't currently know how to handled uniform PHIs.
-    LLVM_DEBUG(
-        dbgs() << "LV: PHI is a recurrence with respect to an outer loop.\n");
-    return false;
-  }
-
----------------
artagnon wrote:

Thanks, kept FIXME, but I don't think it's worth keeping the debug message.

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


More information about the llvm-commits mailing list