Skip to content

Commit 1a9e450

Browse files
committed
[VPBuilder] Add setInsertPoint version taking a recipe directly (NFC).
This helps to slightly simplify code when a recipe can be obtained easily. Suggested in D158779.
1 parent eaf1590 commit 1a9e450

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ class VPBuilder {
120120
InsertPt = IP;
121121
}
122122

123+
/// This specifies that created instructions should be inserted at the
124+
/// specified point.
125+
void setInsertPoint(VPRecipeBase *IP) {
126+
BB = IP->getParent();
127+
InsertPt = IP->getIterator();
128+
}
129+
123130
/// Create an N-ary operation with \p Opcode, \p Operands and set \p Inst as
124131
/// its underlying Instruction.
125132
VPValue *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9133,7 +9133,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91339133
VPValue *CondOp = nullptr;
91349134
if (CM.blockNeedsPredicationForAnyReason(BB)) {
91359135
VPBuilder::InsertPointGuard Guard(Builder);
9136-
Builder.setInsertPoint(LinkVPBB, CurrentLink->getIterator());
9136+
Builder.setInsertPoint(CurrentLink);
91379137
CondOp = RecipeBuilder.createBlockInMask(BB, *Plan);
91389138
}
91399139

@@ -9153,7 +9153,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91539153
// and the live-out instruction of each reduction, at the beginning of the
91549154
// dedicated latch block.
91559155
if (CM.foldTailByMasking()) {
9156-
Builder.setInsertPoint(LatchVPBB, LatchVPBB->begin());
9156+
Builder.setInsertPoint(&*LatchVPBB->begin());
91579157
for (VPRecipeBase &R :
91589158
Plan->getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
91599159
VPReductionPHIRecipe *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);

0 commit comments

Comments
 (0)