Skip to content

Commit 9212f96

Browse files
committed
[VPlan] Generalize collectUsersInExitBlocks for multiple exit bbs.
Generalize collectUsersInExitBlock to collecting exit users in multiple exit blocks. Exit blocks are leaf nodes in the VPlan (without successors) except the scalar header. Split off from #112138
1 parent 0f8aedf commit 9212f96

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8830,12 +8830,12 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
88308830
}
88318831
}
88328832

8833-
// Collect VPIRInstructions for phis in the original exit block that are modeled
8833+
// Collect VPIRInstructions for phis in the exit blocks that are modeled
88348834
// in VPlan and add the exiting VPValue as operand. Some exiting values are not
88358835
// modeled explicitly yet and won't be included. Those are un-truncated
88368836
// VPWidenIntOrFpInductionRecipe, VPWidenPointerInductionRecipe and induction
88378837
// increments.
8838-
static SetVector<VPIRInstruction *> collectUsersInExitBlock(
8838+
static SetVector<VPIRInstruction *> collectUsersInExitBlocks(
88398839
Loop *OrigLoop, VPRecipeBuilder &Builder, VPlan &Plan,
88408840
const MapVector<PHINode *, InductionDescriptor> &Inductions) {
88418841
SetVector<VPIRInstruction *> ExitUsersToFix;
@@ -8882,8 +8882,8 @@ static SetVector<VPIRInstruction *> collectUsersInExitBlock(
88828882
// Add exit values to \p Plan. Extracts are added for each entry in \p
88838883
// ExitUsersToFix if needed and their operands are updated.
88848884
static void
8885-
addUsersInExitBlock(VPlan &Plan,
8886-
const SetVector<VPIRInstruction *> &ExitUsersToFix) {
8885+
addUsersInExitBlocks(VPlan &Plan,
8886+
const SetVector<VPIRInstruction *> &ExitUsersToFix) {
88878887
if (ExitUsersToFix.empty())
88888888
return;
88898889

@@ -9179,12 +9179,11 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
91799179
VPlanTransforms::handleUncountableEarlyExit(*Plan, *PSE.getSE(), OrigLoop,
91809180
RecipeBuilder);
91819181
}
9182-
addScalarResumePhis(RecipeBuilder, *Plan);
9183-
SetVector<VPIRInstruction *> ExitUsersToFix = collectUsersInExitBlock(
9184-
OrigLoop, RecipeBuilder, *Plan, Legal->getInductionVars());
9185-
addExitUsersForFirstOrderRecurrences(*Plan, ExitUsersToFix);
9186-
addUsersInExitBlock(*Plan, ExitUsersToFix);
9187-
9182+
addScalarResumePhis(RecipeBuilder, *Plan);
9183+
SetVector<VPIRInstruction *> ExitUsersToFix = collectUsersInExitBlocks(
9184+
OrigLoop, RecipeBuilder, *Plan, Legal->getInductionVars());
9185+
addExitUsersForFirstOrderRecurrences(*Plan, ExitUsersToFix);
9186+
addUsersInExitBlocks(*Plan, ExitUsersToFix);
91889187
// ---------------------------------------------------------------------------
91899188
// Transform initial VPlan: Apply previously taken decisions, in order, to
91909189
// bring the VPlan to its final state.

0 commit comments

Comments
 (0)