[llvm] [LV]: Improve accuracy of calculating remaining iterations of MainLoopVF (PR #156723)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 05:29:47 PDT 2025
================
@@ -4371,11 +4371,30 @@ 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));
+
+ // Calculate runtime estimated value for TC/MainLoopVF only when they are in
+ // different numerical space.
+ // TODO: This is a workaround until SCEV can evaluate vscale-based
+ // expressions.
+ if (match(TC, m_scev_Mul(m_SCEV(), m_SCEVVScale())) &&
----------------
david-arm wrote:
I think it's probably worth caching this result in a variable since it's used in two places.
https://github.com/llvm/llvm-project/pull/156723
More information about the llvm-commits
mailing list