Skip to content

Commit

Permalink
[VPBuilder] Add setInsertPoint version taking a recipe directly (NFC).
Browse files Browse the repository at this point in the history
This helps to slightly simplify code when a recipe can be obtained
easily. Suggested in D158779.
  • Loading branch information
fhahn committed Sep 25, 2023
1 parent eaf1590 commit 1a9e450
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class VPBuilder {
InsertPt = IP;
}

/// This specifies that created instructions should be inserted at the
/// specified point.
void setInsertPoint(VPRecipeBase *IP) {
BB = IP->getParent();
InsertPt = IP->getIterator();
}

/// Create an N-ary operation with \p Opcode, \p Operands and set \p Inst as
/// its underlying Instruction.
VPValue *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9133,7 +9133,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
VPValue *CondOp = nullptr;
if (CM.blockNeedsPredicationForAnyReason(BB)) {
VPBuilder::InsertPointGuard Guard(Builder);
Builder.setInsertPoint(LinkVPBB, CurrentLink->getIterator());
Builder.setInsertPoint(CurrentLink);
CondOp = RecipeBuilder.createBlockInMask(BB, *Plan);
}

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

0 comments on commit 1a9e450

Please sign in to comment.