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

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 29 05:26:38 PDT 2025


================
@@ -4376,8 +4376,20 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
   const SCEV *TC =
       vputils::getSCEVExprForVPValue(getPlanFor(MainLoopVF).getTripCount(), SE);
   assert(!isa<SCEVCouldNotCompute>(TC) && "Trip count SCEV must be computable");
+
+  // TODO: Maybe this could be removed when SCEV can evaluate expressions with
+  // 'vscale'.
+  // If TC is multiple of vscale, try to get estimated value:
+  if (match(TC, m_scev_Mul(m_SCEV(), m_SCEVVScale()))) {
+    if (std::optional<ElementCount> BestKnownTC =
----------------
hassnaaHamdi wrote:

done.

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


More information about the llvm-commits mailing list