Skip to content

Commit 15da03a

Browse files
committed
[NFC][LoopVectorize] Add more loop early exit asserts
This patch is split off llvm#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 b4e17d4 commit 15da03a

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
@@ -8925,8 +8925,9 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
89258925
VPTypeAnalysis TypeInfo(Plan.getCanonicalIV()->getScalarType());
89268926
auto *ScalarPH = Plan.getScalarPreheader();
89278927
auto *MiddleVPBB = cast<VPBasicBlock>(ScalarPH->getSinglePredecessor());
8928+
VPRegionBlock *VectorRegion = Plan.getVectorLoopRegion();
89288929
VPBuilder VectorPHBuilder(
8929-
cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSinglePredecessor()));
8930+
cast<VPBasicBlock>(VectorRegion->getSinglePredecessor()));
89308931
VPBuilder MiddleBuilder(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
89318932
VPBuilder ScalarPHBuilder(ScalarPH);
89328933
VPValue *OneVPV = Plan.getOrAddLiveIn(
@@ -8958,6 +8959,8 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
89588959
// start value provides the value if the loop is bypassed.
89598960
bool IsFOR = isa<VPFirstOrderRecurrencePHIRecipe>(VectorPhiR);
89608961
auto *ResumeFromVectorLoop = VectorPhiR->getBackedgeValue();
8962+
assert(VectorRegion->getSingleSuccessor() == Plan.getMiddleBlock() &&
8963+
"Cannot handle loops with uncountable early exits");
89618964
if (IsFOR)
89628965
ResumeFromVectorLoop = MiddleBuilder.createNaryOp(
89638966
VPInstruction::ExtractFromEnd, {ResumeFromVectorLoop, OneVPV}, {},
@@ -9127,6 +9130,9 @@ static void addExitUsersForFirstOrderRecurrences(
91279130
if (!FOR)
91289131
continue;
91299132

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

0 commit comments

Comments
 (0)