Skip to content

Commit 65bf335

Browse files
committed
!fixup, address comment. Only clamp the range when extract is needed.
1 parent 01625c0 commit 65bf335

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,11 +2389,6 @@ void VPlanTransforms::handleUncountableEarlyExit(
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-
23972392
// Process the uncountable exiting block. Update IsEarlyExitTaken, which
23982393
// tracks if the uncountable early exit has been taken. Also split the middle
23992394
// block and have it conditionally branch to the early exit block if
@@ -2443,13 +2438,20 @@ void VPlanTransforms::handleUncountableEarlyExit(
24432438
ExitIRI->extractLastLaneOfOperand(MiddleBuilder);
24442439
}
24452440
// Add the incoming value from the early exit.
2446-
if (!IncomingFromEarlyExit->isLiveIn() && !IsScalarVF) {
2447-
VPValue *FirstActiveLane = EarlyExitB.createNaryOp(
2448-
VPInstruction::FirstActiveLane, {EarlyExitTakenCond}, nullptr,
2449-
"first.active.lane");
2450-
IncomingFromEarlyExit = EarlyExitB.createNaryOp(
2451-
Instruction::ExtractElement, {IncomingFromEarlyExit, FirstActiveLane},
2452-
nullptr, "early.exit.value");
2441+
if (!IncomingFromEarlyExit->isLiveIn()) {
2442+
// Limit range to scalar VF only, if the range contains the scalar VF.
2443+
bool IsVectorVF = LoopVectorizationPlanner::getDecisionAndClampRange(
2444+
[&](ElementCount VF) { return VF.isVector(); }, Range);
2445+
2446+
if (IsVectorVF) {
2447+
VPValue *FirstActiveLane = EarlyExitB.createNaryOp(
2448+
VPInstruction::FirstActiveLane, {EarlyExitTakenCond}, nullptr,
2449+
"first.active.lane");
2450+
IncomingFromEarlyExit =
2451+
EarlyExitB.createNaryOp(Instruction::ExtractElement,
2452+
{IncomingFromEarlyExit, FirstActiveLane},
2453+
nullptr, "early.exit.value");
2454+
}
24532455
}
24542456
ExitIRI->addOperand(IncomingFromEarlyExit);
24552457
}

0 commit comments

Comments
 (0)