Skip to content

Commit 01625c0

Browse files
committed
!fixup, clamp the range to make sure the plan has scalar/vector VF only.
1 parent 9e96e1d commit 01625c0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,13 +2382,18 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) {
23822382
void VPlanTransforms::handleUncountableEarlyExit(
23832383
VPlan &Plan, ScalarEvolution &SE, Loop *OrigLoop,
23842384
BasicBlock *UncountableExitingBlock, VPRecipeBuilder &RecipeBuilder,
2385-
const VFRange &Range) {
2385+
VFRange &Range) {
23862386
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
23872387
auto *LatchVPBB = cast<VPBasicBlock>(LoopRegion->getExiting());
23882388
VPBuilder Builder(LatchVPBB->getTerminator());
23892389
auto *MiddleVPBB = Plan.getMiddleBlock();
23902390
VPValue *IsEarlyExitTaken = nullptr;
23912391

2392+
// Clamp the range that make sure we insert extractElement for incoming value
2393+
// correctly.
2394+
bool IsScalarVF = LoopVectorizationPlanner::getDecisionAndClampRange(
2395+
[&](ElementCount VF) { return VF.isScalar(); }, Range);
2396+
23922397
// Process the uncountable exiting block. Update IsEarlyExitTaken, which
23932398
// tracks if the uncountable early exit has been taken. Also split the middle
23942399
// block and have it conditionally branch to the early exit block if
@@ -2438,7 +2443,7 @@ void VPlanTransforms::handleUncountableEarlyExit(
24382443
ExitIRI->extractLastLaneOfOperand(MiddleBuilder);
24392444
}
24402445
// Add the incoming value from the early exit.
2441-
if (!IncomingFromEarlyExit->isLiveIn() && !Range.Start.isScalar()) {
2446+
if (!IncomingFromEarlyExit->isLiveIn() && !IsScalarVF) {
24422447
VPValue *FirstActiveLane = EarlyExitB.createNaryOp(
24432448
VPInstruction::FirstActiveLane, {EarlyExitTakenCond}, nullptr,
24442449
"first.active.lane");

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct VPlanTransforms {
176176
Loop *OrigLoop,
177177
BasicBlock *UncountableExitingBlock,
178178
VPRecipeBuilder &RecipeBuilder,
179-
const VFRange &Range);
179+
VFRange &Range);
180180

181181
/// Lower abstract recipes to concrete ones, that can be codegen'd.
182182
static void convertToConcreteRecipes(VPlan &Plan);

0 commit comments

Comments
 (0)