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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 04:17:58 PST 2025


================
@@ -1614,41 +1617,30 @@ bool InductionDescriptor::isInductionPHI(
 
   // Check that the PHI is consecutive.
   const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
-  const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PhiScev);
+  const SCEV *Step;
 
-  if (!AR) {
+  // FIXME: We are currently matching the specific loop TheLoop; if it doesn't
+  // match, we should treat it as a uniform. Unfortunately, we don't currently
+  // know how to handled uniform PHIs.
+  if (!match(PhiScev, m_scev_AffineAddRec(m_SCEV(), m_SCEV(Step),
+                                          m_SpecificLoop(TheLoop)))) {
----------------
david-arm wrote:

If we don't match because the loop is different, it would be good to keep the same debug message as before. Alternatively, rewrite the debug message to be more precise, i.e. something like

```
  LLVM_DEBUG(dbgs() << "LV: PHI is not a poly recurrence for the requested loop.\n");
```

that way at least it's a bit clearer that it could be a poly recurrence for a different loop.

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


More information about the llvm-commits mailing list