Skip to content

Commit fd5c17f

Browse files
committed
[LV] Use SCEV::getElementCount in selectEpilogueVectorizationFactor.
Follow-up to #149789 to use getElementCount to compute the remaining iterations in selectEpilogueVectrizationFactor.
1 parent a5d9ba6 commit fd5c17f

File tree

2 files changed

+157
-50
lines changed

2 files changed

+157
-50
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4479,19 +4479,17 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
44794479
Type *TCType = Legal->getWidestInductionType();
44804480
const SCEV *RemainingIterations = nullptr;
44814481
unsigned MaxTripCount = 0;
4482-
if (MainLoopVF.isFixed()) {
4483-
// TODO: extend to support scalable VFs.
4484-
const SCEV *TC = vputils::getSCEVExprForVPValue(
4485-
getPlanFor(MainLoopVF).getTripCount(), SE);
4486-
assert(!isa<SCEVCouldNotCompute>(TC) &&
4487-
"Trip count SCEV must be computable");
4488-
RemainingIterations = SE.getURemExpr(
4489-
TC, SE.getConstant(TCType, MainLoopVF.getFixedValue() * IC));
4490-
4491-
// No iterations left to process in the epilogue.
4492-
if (RemainingIterations->isZero())
4493-
return Result;
4482+
const SCEV *TC =
4483+
vputils::getSCEVExprForVPValue(getPlanFor(MainLoopVF).getTripCount(), SE);
4484+
assert(!isa<SCEVCouldNotCompute>(TC) && "Trip count SCEV must be computable");
4485+
RemainingIterations =
4486+
SE.getURemExpr(TC, SE.getElementCount(TCType, MainLoopVF * IC));
4487+
4488+
// No iterations left to process in the epilogue.
4489+
if (RemainingIterations->isZero())
4490+
return Result;
44944491

4492+
if (MainLoopVF.isFixed()) {
44954493
MaxTripCount = MainLoopVF.getFixedValue() * IC - 1;
44964494
if (SE.isKnownPredicate(CmpInst::ICMP_ULT, RemainingIterations,
44974495
SE.getConstant(TCType, MaxTripCount))) {

0 commit comments

Comments
 (0)