Skip to content

Commit 8769486

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 081b74c commit 8769486

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
@@ -4497,19 +4497,17 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
44974497
Type *TCType = Legal->getWidestInductionType();
44984498
const SCEV *RemainingIterations = nullptr;
44994499
unsigned MaxTripCount = 0;
4500-
if (MainLoopVF.isFixed()) {
4501-
// TODO: extend to support scalable VFs.
4502-
const SCEV *TC = vputils::getSCEVExprForVPValue(
4503-
getPlanFor(MainLoopVF).getTripCount(), SE);
4504-
assert(!isa<SCEVCouldNotCompute>(TC) &&
4505-
"Trip count SCEV must be computable");
4506-
RemainingIterations = SE.getURemExpr(
4507-
TC, SE.getConstant(TCType, MainLoopVF.getFixedValue() * IC));
4508-
4509-
// No iterations left to process in the epilogue.
4510-
if (RemainingIterations->isZero())
4511-
return Result;
4500+
const SCEV *TC =
4501+
vputils::getSCEVExprForVPValue(getPlanFor(MainLoopVF).getTripCount(), SE);
4502+
assert(!isa<SCEVCouldNotCompute>(TC) && "Trip count SCEV must be computable");
4503+
RemainingIterations =
4504+
SE.getURemExpr(TC, SE.getElementCount(TCType, MainLoopVF * IC));
4505+
4506+
// No iterations left to process in the epilogue.
4507+
if (RemainingIterations->isZero())
4508+
return Result;
45124509

4510+
if (MainLoopVF.isFixed()) {
45134511
MaxTripCount = MainLoopVF.getFixedValue() * IC - 1;
45144512
if (SE.isKnownPredicate(CmpInst::ICMP_ULT, RemainingIterations,
45154513
SE.getConstant(TCType, MaxTripCount))) {

0 commit comments

Comments
 (0)