Skip to content

Commit 08d294d

Browse files
committed
[VPlan] Simplify VPBuilder insert point when adding users in exit block.
Simplifies setting the insert point, addressing a TODO.
1 parent 4808842 commit 08d294d

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class VPBuilder {
6969
VPBuilder() = default;
7070
VPBuilder(VPBasicBlock *InsertBB) { setInsertPoint(InsertBB); }
7171
VPBuilder(VPRecipeBase *InsertPt) { setInsertPoint(InsertPt); }
72+
VPBuilder(VPBasicBlock *TheBB, VPBasicBlock::iterator IP) {
73+
setInsertPoint(TheBB, IP);
74+
}
7275

7376
/// Clear the insertion point: created instructions will not be inserted into
7477
/// a block.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8691,14 +8691,7 @@ addUsersInExitBlock(VPlan &Plan,
86918691
cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
86928692
BasicBlock *ExitBB =
86938693
cast<VPIRBasicBlock>(MiddleVPBB->getSuccessors()[0])->getIRBasicBlock();
8694-
// TODO: set B to MiddleVPBB->getFirstNonPhi(), taking care of affected tests.
8695-
VPBuilder B(MiddleVPBB);
8696-
if (auto *Terminator = MiddleVPBB->getTerminator()) {
8697-
auto *Condition = dyn_cast<VPInstruction>(Terminator->getOperand(0));
8698-
assert((!Condition || Condition->getParent() == MiddleVPBB) &&
8699-
"Condition expected in MiddleVPBB");
8700-
B.setInsertPoint(Condition ? Condition : Terminator);
8701-
}
8694+
VPBuilder B(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
87028695

87038696
// Introduce VPUsers modeling the exit values.
87048697
for (const auto &[ExitPhi, V] : ExitingValuesToFix) {

llvm/test/Transforms/LoopVectorize/first-order-recurrence-sink-replicate-region.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ define i32 @sink_replicate_region_3_reduction(i32 %x, i8 %y, ptr %ptr) optsize {
221221
; CHECK-EMPTY:
222222
; CHECK-NEXT: middle.block:
223223
; CHECK-NEXT: EMIT vp<[[RED_RES:%.+]]> = compute-reduction-result ir<%and.red>, vp<[[SEL]]>
224-
; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%recur.next>, ir<1>
225224
; CHECK-NEXT: EMIT vp<[[RED_EX:%.+]]> = extract-from-end vp<[[RED_RES]]>, ir<1>
225+
; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%recur.next>, ir<1>
226226
; CHECK-NEXT: EMIT branch-on-cond ir<true>
227227
; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
228228
; CHECK-EMPTY:

0 commit comments

Comments
 (0)