Skip to content

Commit 280abaf

Browse files
authored
[VPlan] Handle scalar-VF in transforms (NFC) (#161365)
1 parent 5665b1b commit 280abaf

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8165,14 +8165,12 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
81658165
VFRange SubRange = {VF, MaxVFTimes2};
81668166
if (auto Plan = tryToBuildVPlanWithVPRecipes(
81678167
std::unique_ptr<VPlan>(VPlan0->duplicate()), SubRange, &LVer)) {
8168-
bool HasScalarVF = Plan->hasScalarVFOnly();
81698168
// Now optimize the initial VPlan.
8170-
if (!HasScalarVF)
8171-
VPlanTransforms::runPass(VPlanTransforms::truncateToMinimalBitwidths,
8172-
*Plan, CM.getMinimalBitwidths());
8169+
VPlanTransforms::runPass(VPlanTransforms::truncateToMinimalBitwidths,
8170+
*Plan, CM.getMinimalBitwidths());
81738171
VPlanTransforms::runPass(VPlanTransforms::optimize, *Plan);
81748172
// TODO: try to put it close to addActiveLaneMask().
8175-
if (CM.foldTailWithEVL() && !HasScalarVF)
8173+
if (CM.foldTailWithEVL())
81768174
VPlanTransforms::runPass(VPlanTransforms::addExplicitVectorLength,
81778175
*Plan, CM.getMaxSafeElements());
81788176
assert(verifyVPlanIsValid(*Plan) && "VPlan is invalid");

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,8 @@ static void licm(VPlan &Plan) {
21242124

21252125
void VPlanTransforms::truncateToMinimalBitwidths(
21262126
VPlan &Plan, const MapVector<Instruction *, uint64_t> &MinBWs) {
2127+
if (Plan.hasScalarVFOnly())
2128+
return;
21272129
// Keep track of created truncates, so they can be re-used. Note that we
21282130
// cannot use RAUW after creating a new truncate, as this would could make
21292131
// other uses have different types for their operands, making them invalidly
@@ -2704,6 +2706,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
27042706
///
27052707
void VPlanTransforms::addExplicitVectorLength(
27062708
VPlan &Plan, const std::optional<unsigned> &MaxSafeElements) {
2709+
if (Plan.hasScalarVFOnly())
2710+
return;
27072711
VPBasicBlock *Header = Plan.getVectorLoopRegion()->getEntryBasicBlock();
27082712

27092713
auto *CanonicalIVPHI = Plan.getCanonicalIV();

0 commit comments

Comments
 (0)