Skip to content

Commit 206b42c

Browse files
committed
[LV] Use VPBuilder to create ComputeReductionResult. (NFC)
Update code to use VPBuilder, to simplify follow-up changes.
1 parent 2f1416b commit 206b42c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9861,15 +9861,16 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
98619861
// bc.merge.rdx phi nodes, hence it needs to be created unconditionally here
98629862
// even for in-loop reductions, until the reduction resume value handling is
98639863
// also modeled in VPlan.
9864-
auto *FinalReductionResult = new VPInstruction(
9864+
VPBuilder::InsertPointGuard Guard(Builder);
9865+
Builder.setInsertPoint(MiddleVPBB, IP);
9866+
auto *FinalReductionResult = Builder.createNaryOp(
98659867
VPInstruction::ComputeReductionResult, {PhiR, NewExitingVPV}, ExitDL);
98669868
// Update all users outside the vector region.
98679869
OrigExitingVPV->replaceUsesWithIf(
9868-
FinalReductionResult, [](VPUser &User, unsigned) {
9870+
FinalReductionResult, [FinalReductionResult](VPUser &User, unsigned) {
98699871
auto *Parent = cast<VPRecipeBase>(&User)->getParent();
9870-
return Parent && !Parent->getParent();
9872+
return FinalReductionResult != &User && !Parent->getParent();
98719873
});
9872-
FinalReductionResult->insertBefore(*MiddleVPBB, IP);
98739874

98749875
// Adjust AnyOf reductions; replace the reduction phi for the selected value
98759876
// with a boolean reduction phi node to check if the condition is true in
@@ -9891,7 +9892,6 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
98919892
if (CmpR->getOperand(I) == PhiR)
98929893
CmpR->setOperand(I, PhiR->getStartValue());
98939894
}
9894-
VPBuilder::InsertPointGuard Guard(Builder);
98959895
Builder.setInsertPoint(Select);
98969896

98979897
// If the true value of the select is the reduction phi, the new value is

0 commit comments

Comments
 (0)