[llvm] [LV]: Improve accuracy of calculating remaining iterations of MainLoopVF (PR #156723)
Hassnaa Hamdi via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 10 09:20:27 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:
Yeah, this is not the most optimal solution that's why there is a TODO depending on SCEV.
For the mentioned case the current logic doesn't know the exact value for `RemainingIterations` , while the proposed solution approximately decides it.
https://github.com/llvm/llvm-project/pull/156723
More information about the llvm-commits
mailing list