Skip to content

Commit 6955f28

Browse files
committed
Reduce cost only when not tail-folding
1 parent 1722aea commit 6955f28

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5583,7 +5583,7 @@ InstructionCost LoopVectorizationCostModel::expectedCost(ElementCount VF) {
55835583
// away.
55845584
SmallPtrSet<Instruction *, 2> ValuesToIgnoreForVF;
55855585
auto TC = PSE.getSE()->getSmallConstantTripCount(TheLoop);
5586-
if (VF.isFixed() && TC == VF.getFixedValue())
5586+
if (VF.isFixed() && TC == VF.getFixedValue() && !foldTailByMasking())
55875587
addFullyUnrolledInstructionsToIgnore(TheLoop, Legal->getInductionVars(),
55885588
ValuesToIgnoreForVF);
55895589

@@ -7283,7 +7283,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
72837283
// TODO: Remove this code after stepping away from the legacy cost model and
72847284
// adding code to simplify VPlans before calculating their costs.
72857285
auto TC = PSE.getSE()->getSmallConstantTripCount(OrigLoop);
7286-
if (VF.isFixed() && TC == VF.getFixedValue())
7286+
if (VF.isFixed() && TC == VF.getFixedValue() && !CM.foldTailByMasking())
72877287
addFullyUnrolledInstructionsToIgnore(OrigLoop, Legal->getInductionVars(),
72887288
CostCtx.SkipCostComputation);
72897289

0 commit comments

Comments
 (0)