Skip to content

Commit 8299bfa

Browse files
committed
[VPlan] Extract reduction result insertion point to variable (NFCI).
Split off from #92651 as suggested.
1 parent 655651a commit 8299bfa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9011,6 +9011,9 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
90119011
}
90129012
}
90139013
Builder.setInsertPoint(&*LatchVPBB->begin());
9014+
VPBasicBlock *MiddleVPBB =
9015+
cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor());
9016+
VPBasicBlock::iterator IP = MiddleVPBB->getFirstNonPhi();
90149017
for (VPRecipeBase &R :
90159018
Plan->getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
90169019
VPReductionPHIRecipe *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
@@ -9119,8 +9122,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91199122
// also modeled in VPlan.
91209123
auto *FinalReductionResult = new VPInstruction(
91219124
VPInstruction::ComputeReductionResult, {PhiR, NewExitingVPV}, ExitDL);
9122-
cast<VPBasicBlock>(VectorLoopRegion->getSingleSuccessor())
9123-
->appendRecipe(FinalReductionResult);
9125+
FinalReductionResult->insertBefore(*MiddleVPBB, IP);
91249126
OrigExitingVPV->replaceUsesWithIf(
91259127
FinalReductionResult,
91269128
[](VPUser &User, unsigned) { return isa<VPLiveOut>(&User); });

0 commit comments

Comments
 (0)