[llvm] [LV]: Improve accuracy of calculating remaining iterations of MainLoopVF (PR #156723)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 09:23:20 PDT 2025


================
@@ -4372,8 +4372,21 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
   const SCEV *TC =
       vputils::getSCEVExprForVPValue(getPlanFor(MainLoopVF).getTripCount(), SE);
   assert(!isa<SCEVCouldNotCompute>(TC) && "Trip count SCEV must be computable");
-  RemainingIterations =
-      SE.getURemExpr(TC, SE.getElementCount(TCType, MainLoopVF * IC));
+  const SCEV *KnownMinTC;
+  bool ScalableTC = match(TC, m_scev_Mul(m_SCEV(KnownMinTC), m_SCEVVScale())) ||
+                    match(TC, m_scev_Mul(m_SCEVVScale(), m_SCEV(KnownMinTC)));
----------------
paulwalker-arm wrote:

```suggestion
  bool ScalableTC = match(TC, m_scev_c_Mul(m_SCEV(KnownMinTC), m_SCEVVScale()));
```

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


More information about the llvm-commits mailing list