[llvm] [LV]: Improve accuracy of calculating remaining iterations of MainLoopVF (PR #156723)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 10 05:10:11 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 =
----------------
paulwalker-arm wrote:
For the case when both TC and VF are multiples of `vscale` this is effectively doing the opposite of the PR's title in that we're going from potentially knowing the exact value for `RemainingIterations` to having a guess based on the tuning option?
I've uploaded a WIP patch (https://github.com/llvm/llvm-project/pull/157836, which is loosely blocked on https://github.com/llvm/llvm-project/pull/141798) where I'm improving SCEV's handling for `vscale` to improve control flow for vscale based loops.
https://github.com/llvm/llvm-project/pull/156723
More information about the llvm-commits
mailing list