Skip to content

Commit edc0235

Browse files
authored
[NFC][LoopVectorize] Add more loop early exit asserts (#122732)
This patch is split off #120567, adding asserts in addScalarResumePhis and addExitUsersForFirstOrderRecurrences that the loop does not contain an uncountable early exit, since the code cannot yet handle them correctly.
1 parent 135f39c commit edc0235

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9082,8 +9082,9 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
90829082
VPTypeAnalysis TypeInfo(Plan.getCanonicalIV()->getScalarType());
90839083
auto *ScalarPH = Plan.getScalarPreheader();
90849084
auto *MiddleVPBB = cast<VPBasicBlock>(ScalarPH->getSinglePredecessor());
9085+
VPRegionBlock *VectorRegion = Plan.getVectorLoopRegion();
90859086
VPBuilder VectorPHBuilder(
9086-
cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSinglePredecessor()));
9087+
cast<VPBasicBlock>(VectorRegion->getSinglePredecessor()));
90879088
VPBuilder MiddleBuilder(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
90889089
VPBuilder ScalarPHBuilder(ScalarPH);
90899090
VPValue *OneVPV = Plan.getOrAddLiveIn(
@@ -9115,6 +9116,8 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
91159116
// start value provides the value if the loop is bypassed.
91169117
bool IsFOR = isa<VPFirstOrderRecurrencePHIRecipe>(VectorPhiR);
91179118
auto *ResumeFromVectorLoop = VectorPhiR->getBackedgeValue();
9119+
assert(VectorRegion->getSingleSuccessor() == Plan.getMiddleBlock() &&
9120+
"Cannot handle loops with uncountable early exits");
91189121
if (IsFOR)
91199122
ResumeFromVectorLoop = MiddleBuilder.createNaryOp(
91209123
VPInstruction::ExtractFromEnd, {ResumeFromVectorLoop, OneVPV}, {},
@@ -9284,6 +9287,9 @@ static void addExitUsersForFirstOrderRecurrences(
92849287
if (!FOR)
92859288
continue;
92869289

9290+
assert(VectorRegion->getSingleSuccessor() == Plan.getMiddleBlock() &&
9291+
"Cannot handle loops with uncountable early exits");
9292+
92879293
// This is the second phase of vectorizing first-order recurrences, creating
92889294
// extract for users outside the loop. An overview of the transformation is
92899295
// described below. Suppose we have the following loop with some use after

0 commit comments

Comments
 (0)