[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 10:26:17 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:
I guess I'm suggestion we should restrict the use of `estimateElementCount` to only those cases where the values being compared are in different domains (i.e. one is fixed and the other scalable). That is the scenario where `vscale` becomes problematic and providing an estimate is our only option and typically better than doing nothing.
Sure, there are scalable TC and VF cases where we don't do a great job, but often that's due to missing optimisation and/or analysis.
https://github.com/llvm/llvm-project/pull/156723
More information about the llvm-commits
mailing list