Skip to content

Commit f0421c6

Browse files
committed
!fixup after merge
1 parent c68ddd1 commit f0421c6

File tree

4 files changed

+23
-47
lines changed

4 files changed

+23
-47
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,10 @@ void VPBasicBlock::connectToPredecessors(BasicBlock *NewBB,
448448
// Set each forward successor here when it is created, excluding
449449
// backedges. A backward successor is set when the branch is created.
450450
unsigned idx = PredVPSuccessors.front() == this ? 0 : 1;
451-
assert(!TermBr->getSuccessor(idx) &&
452-
"Trying to reset an existing successor block.");
451+
assert(
452+
(!TermBr->getSuccessor(idx) ||
453+
(isa<VPIRBasicBlock>(this) && TermBr->getSuccessor(idx) == NewBB)) &&
454+
"Trying to reset an existing successor block.");
453455
TermBr->setSuccessor(idx, NewBB);
454456
}
455457
CFG.DTU.applyUpdates({{DominatorTree::Insert, PredBB, NewBB}});
@@ -472,23 +474,7 @@ void VPIRBasicBlock::execute(VPTransformState *State) {
472474
"other blocks must be terminated by a branch");
473475
}
474476

475-
for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) {
476-
VPBasicBlock *PredVPBB = PredVPBlock->getExitingBasicBlock();
477-
BasicBlock *PredBB = State->CFG.VPBB2IRBB[PredVPBB];
478-
assert(PredBB && "Predecessor basic-block not found building successor.");
479-
LLVM_DEBUG(dbgs() << "LV: draw edge from" << PredBB->getName() << '\n');
480-
481-
auto *PredBBTerminator = PredBB->getTerminator();
482-
auto *TermBr = cast<BranchInst>(PredBBTerminator);
483-
// Set each forward successor here when it is created, excluding
484-
// backedges. A backward successor is set when the branch is created.
485-
const auto &PredVPSuccessors = PredVPBB->getHierarchicalSuccessors();
486-
unsigned idx = PredVPSuccessors.front() == this ? 0 : 1;
487-
assert((!TermBr->getSuccessor(idx) || TermBr->getSuccessor(idx) == IRBB) &&
488-
"Trying to reset an existing successor block.");
489-
TermBr->setSuccessor(idx, IRBB);
490-
State->CFG.DTU.applyUpdates({{DominatorTree::Insert, PredBB, IRBB}});
491-
}
477+
connectToPredecessors(IRBB, State->CFG);
492478
}
493479

494480
void VPBasicBlock::execute(VPTransformState *State) {
@@ -1039,11 +1025,9 @@ void VPlan::execute(VPTransformState *State) {
10391025
// VPlan execution rather than earlier during VPlan construction.
10401026
BasicBlock *MiddleBB = State->CFG.ExitBB;
10411027
BasicBlock *ScalarPh = MiddleBB->getSingleSuccessor();
1028+
VPBasicBlock *MiddleVPBB = getMiddleBlock();
10421029
replaceVPBBWithIRVPBB(getScalarPreheader(), ScalarPh);
1043-
if (getVectorLoopRegion()) {
1044-
VPBasicBlock *MiddleVPBB = getMiddleBlock();
1045-
replaceVPBBWithIRVPBB(MiddleVPBB, MiddleBB);
1046-
}
1030+
replaceVPBBWithIRVPBB(MiddleVPBB, MiddleBB);
10471031

10481032
// Disconnect the middle block from its single successor (the scalar loop
10491033
// header) in both the CFG and DT. The branch will be recreated during VPlan

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,9 +3874,7 @@ class VPlan {
38743874
}
38753875

38763876
/// Returns the preheader of the vector loop region.
3877-
VPBasicBlock *getVectorPreheader() {
3878-
return cast<VPBasicBlock>(getVectorLoopRegion()->getSinglePredecessor());
3879-
}
3877+
VPBasicBlock *getVectorPreheader() { return cast<VPBasicBlock>(getEntry()); }
38803878

38813879
/// Returns the canonical induction recipe of the vector loop.
38823880
VPCanonicalIVPHIRecipe *getCanonicalIV() {

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-reduction.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
7272
; IF-EVL-INLOOP-NEXT: IR %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
7373
; IF-EVL-INLOOP-NEXT: IR %rdx = phi i32 [ %start, %entry ], [ %add, %for.body ]
7474
; IF-EVL-INLOOP: IR %exitcond.not = icmp eq i64 %iv.next, %n
75+
; IF-EVL-INLOOP-NEXT: No successors
7576
; IF-EVL-INLOOP-NEXT: }
7677
;
7778

llvm/test/Transforms/LoopVectorize/vplan-printing-before-execute.ll

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ define void @test_tc_less_than_16(ptr %A, i64 %N) {
5757
;
5858
; CHECK: Executing best plan with VF=8, UF=2
5959
; CHECK-NEXT: VPlan 'Final VPlan for VF={8},UF={2}' {
60-
; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
6160
; CHECK-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count
6261
; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
6362
; CHECK-EMPTY:
@@ -67,27 +66,21 @@ define void @test_tc_less_than_16(ptr %A, i64 %N) {
6766
; CHECK-NEXT: No successors
6867
; CHECK-EMPTY:
6968
; CHECK-NEXT: vector.ph:
70-
; CHECK-NEXT: Successor(s): vector loop
69+
; CHECK-NEXT: Successor(s): vector.body
7170
; CHECK-EMPTY:
72-
; CHECK-NEXT: <x1> vector loop: {
73-
; CHECK-NEXT: vector.body:
74-
; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]>
75-
; CHECK-NEXT: vp<[[STEPS1:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
76-
; CHECK-NEXT: EMIT vp<[[PADD1:%.+]]> = ptradd ir<%A>, vp<[[STEPS1]]>
77-
; CHECK-NEXT: vp<[[VPTR1:%.]]> = vector-pointer vp<[[PADD1]]>
78-
; CHECK-NEXT: vp<[[VPTR2:%.]]> = vector-pointer vp<[[PADD1]]>, ir<1>
79-
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR1]]>
80-
; CHECK-NEXT: WIDEN ir<%l>.1 = load vp<[[VPTR2]]>
81-
; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10>
82-
; CHECK-NEXT: WIDEN ir<%add>.1 = add nsw ir<%l>.1, ir<10>
83-
; CHECK-NEXT: vp<[[VPTR3:%.+]]> = vector-pointer vp<[[PADD1]]>
84-
; CHECK-NEXT: vp<[[VPTR4:%.+]]> = vector-pointer vp<[[PADD1]]>, ir<1>
85-
; CHECK-NEXT: WIDEN store vp<[[VPTR3]]>, ir<%add>
86-
; CHECK-NEXT: WIDEN store vp<[[VPTR4]]>, ir<%add>.1
87-
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV:%.+]]>, vp<[[VFxUF]]>
88-
; CHECK-NEXT: EMIT branch-on-cond ir<true>
89-
; CHECK-NEXT: No successors
90-
; CHECK-NEXT: }
71+
; CHECK-NEXT: vector.body:
72+
; CHECK-NEXT: vp<[[STEPS1:%.+]]> = SCALAR-STEPS ir<0>, ir<1>
73+
; CHECK-NEXT: EMIT vp<[[PADD1:%.+]]> = ptradd ir<%A>, vp<[[STEPS1]]>
74+
; CHECK-NEXT: vp<[[VPTR1:%.]]> = vector-pointer vp<[[PADD1]]>
75+
; CHECK-NEXT: vp<[[VPTR2:%.]]> = vector-pointer vp<[[PADD1]]>, ir<1>
76+
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR1]]>
77+
; CHECK-NEXT: WIDEN ir<%l>.1 = load vp<[[VPTR2]]>
78+
; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10>
79+
; CHECK-NEXT: WIDEN ir<%add>.1 = add nsw ir<%l>.1, ir<10>
80+
; CHECK-NEXT: vp<[[VPTR3:%.+]]> = vector-pointer vp<[[PADD1]]>
81+
; CHECK-NEXT: vp<[[VPTR4:%.+]]> = vector-pointer vp<[[PADD1]]>, ir<1>
82+
; CHECK-NEXT: WIDEN store vp<[[VPTR3]]>, ir<%add>
83+
; CHECK-NEXT: WIDEN store vp<[[VPTR4]]>, ir<%add>.1
9184
; CHECK-NEXT: Successor(s): middle.block
9285
; CHECK-EMPTY:
9386
; CHECK-NEXT: middle.block:

0 commit comments

Comments
 (0)