Skip to content

Commit e5b8af3

Browse files
committed
!fixup address latest comments, thanks!
1 parent 333536a commit e5b8af3

File tree

9 files changed

+99
-111
lines changed

9 files changed

+99
-111
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,12 +2432,13 @@ InnerLoopVectorizer::getOrCreateVectorTripCount(BasicBlock *InsertBlock) {
24322432
/// entry. This is used when adjusting \p Plan during skeleton
24332433
/// creation, i.e. adjusting the plan after introducing an initial runtime
24342434
/// check.
2435-
static void connectScalarPreheaderInVPlan(VPlan &Plan) {
2435+
/// TODO: Connect scalar preheader during initial VPlan construction.
2436+
static void connectScalarPreheaderAsBypassInVPlan(VPlan &Plan) {
24362437
VPBlockBase *VectorPH = Plan.getVectorPreheader();
24372438
VPBlockBase *ScalarPH = Plan.getScalarPreheader();
2438-
VPBlockBase *PredVPB = Plan.getEntry();
2439-
VPBlockUtils::connectBlocks(PredVPB, ScalarPH, -1, 0);
2440-
VPBlockUtils::connectBlocks(PredVPB, VectorPH, 0, -1);
2439+
VPBlockBase *Entry = Plan.getEntry();
2440+
VPBlockUtils::connectBlocks(Entry, ScalarPH);
2441+
std::swap(Entry->getSuccessors()[0], Entry->getSuccessors()[1]);
24412442
}
24422443

24432444
/// Introduces a new VPIRBasicBlock for \p CheckIRBB to \p Plan between the
@@ -2447,6 +2448,7 @@ static void introduceCheckBlockInVPlan(VPlan &Plan, BasicBlock *CheckIRBB) {
24472448
VPBlockBase *ScalarPH = Plan.getScalarPreheader();
24482449
VPBlockBase *VectorPH = Plan.getVectorPreheader();
24492450
VPBlockBase *PreVectorPH = VectorPH->getSinglePredecessor();
2451+
assert(PreVectorPH->getSuccessors()[0] == ScalarPH && "Unexpected successor");
24502452
VPIRBasicBlock *CheckVPIRBB = VPIRBasicBlock::fromBasicBlock(CheckIRBB);
24512453
VPBlockUtils::connectBlocks(CheckVPIRBB, ScalarPH);
24522454
VPBlockUtils::insertOnEdge(PreVectorPH, VectorPH, CheckVPIRBB);
@@ -2534,7 +2536,7 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
25342536
LoopBypassBlocks.push_back(TCCheckBlock);
25352537

25362538
// TODO: Wrap LoopVectorPreHeader in VPIRBasicBlock here.
2537-
connectScalarPreheaderInVPlan(Plan);
2539+
connectScalarPreheaderAsBypassInVPlan(Plan);
25382540
}
25392541

25402542
BasicBlock *InnerLoopVectorizer::emitSCEVChecks(BasicBlock *Bypass) {
@@ -7712,10 +7714,10 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
77127714

77137715
// 0. Generate SCEV-dependent code into the preheader, including TripCount,
77147716
// before making any changes to the CFG.
7715-
if (!BestVPlan.getEntry()->empty()) {
7717+
if (!BestVPlan.getPreheader()->empty()) {
77167718
State.CFG.PrevBB = OrigLoop->getLoopPreheader();
77177719
State.Builder.SetInsertPoint(OrigLoop->getLoopPreheader()->getTerminator());
7718-
BestVPlan.getEntry()->execute(&State);
7720+
BestVPlan.getPreheader()->execute(&State);
77197721
}
77207722
if (!ILV.getTripCount())
77217723
ILV.setTripCount(State.get(BestVPlan.getTripCount(), VPLane(0)));
@@ -7937,10 +7939,11 @@ EpilogueVectorizerMainLoop::emitIterationCountCheck(BasicBlock *Bypass,
79377939
setBranchWeights(BI, MinItersBypassWeights, /*IsExpected=*/false);
79387940
ReplaceInstWithInst(TCCheckBlock->getTerminator(), &BI);
79397941

7940-
VPBlockBase *VectorPH = Plan.getVectorPreheader();
7941-
VPBlockBase *PredVPB = VectorPH->getSinglePredecessor();
7942-
if (PredVPB->getNumSuccessors() == 1)
7943-
connectScalarPreheaderInVPlan(Plan);
7942+
// Connect the vector preheader to the scalar preheader when creating the trip
7943+
// count for the epilogue loop. Otherwise there is already a runtime check and
7944+
// connection to the scalar preheader, so we introduce it as new check block.
7945+
if (ForEpilogue)
7946+
connectScalarPreheaderAsBypassInVPlan(Plan);
79447947
else
79457948
introduceCheckBlockInVPlan(Plan, TCCheckBlock);
79467949
return TCCheckBlock;
@@ -8093,14 +8096,9 @@ EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(
80938096
VPBasicBlock *OldEntry = Plan.getEntry();
80948097
VPBlockUtils::reassociateBlocks(OldEntry, NewEntry);
80958098
Plan.setEntry(NewEntry);
8096-
for (auto &R : make_early_inc_range(*NewEntry)) {
8097-
auto *VPIR = dyn_cast<VPIRInstruction>(&R);
8098-
if (!VPIR || !isa<PHINode>(VPIR->getInstruction()))
8099-
break;
8100-
VPIR->eraseFromParent();
8101-
}
8099+
delete OldEntry;
81028100

8103-
connectScalarPreheaderInVPlan(Plan);
8101+
connectScalarPreheaderAsBypassInVPlan(Plan);
81048102
return Insert;
81058103
}
81068104

@@ -10317,7 +10315,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1031710315
// should be removed once induction resume value creation is done
1031810316
// directly in VPlan.
1031910317
EpilogILV.setTripCount(MainILV.getTripCount());
10320-
for (auto &R : make_early_inc_range(*BestEpiPlan.getEntry())) {
10318+
for (auto &R : make_early_inc_range(*BestEpiPlan.getPreheader())) {
1032110319
auto *ExpandR = dyn_cast<VPExpandSCEVRecipe>(&R);
1032210320
if (!ExpandR)
1032310321
continue;

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ VPBasicBlock *VPBlockBase::getEntryBasicBlock() {
170170
}
171171

172172
void VPBlockBase::setPlan(VPlan *ParentPlan) {
173-
assert(ParentPlan->getEntry() == this &&
174-
"Can only set plan on its entry or preheader block.");
173+
assert(ParentPlan->getEntry() == this && "Can only set plan on its entry.");
175174
Plan = ParentPlan;
176175
}
177176

@@ -822,6 +821,18 @@ void VPRegionBlock::print(raw_ostream &O, const Twine &Indent,
822821
}
823822
#endif
824823

824+
VPlan::VPlan(VPBasicBlock *Preheader, VPValue *TC, VPBasicBlock *Entry,
825+
VPIRBasicBlock *ScalarHeader)
826+
: VPlan(Preheader, TC, ScalarHeader) {
827+
VPBlockUtils::connectBlocks(Preheader, Entry);
828+
}
829+
830+
VPlan::VPlan(VPBasicBlock *Preheader, VPBasicBlock *Entry,
831+
VPIRBasicBlock *ScalarHeader)
832+
: VPlan(Preheader, ScalarHeader) {
833+
VPBlockUtils::connectBlocks(Preheader, Entry);
834+
}
835+
825836
VPlan::~VPlan() {
826837
if (Entry) {
827838
VPValue DummyValue;
@@ -851,6 +862,9 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
851862
VPIRBasicBlock *Entry =
852863
VPIRBasicBlock::fromBasicBlock(TheLoop->getLoopPreheader());
853864
VPBasicBlock *VecPreheader = new VPBasicBlock("vector.ph");
865+
// Connect entry only to vector preheader initially. Edges to the scalar
866+
// preheader will be inserted later, during skeleton creation when runtime
867+
// guards are added as needed.
854868
VPBlockUtils::connectBlocks(Entry, VecPreheader);
855869
VPIRBasicBlock *ScalarHeader =
856870
VPIRBasicBlock::fromBasicBlock(TheLoop->getHeader());
@@ -997,20 +1011,21 @@ void VPlan::execute(VPTransformState *State) {
9971011
BasicBlock *VectorPreHeader = State->CFG.PrevBB;
9981012
State->Builder.SetInsertPoint(VectorPreHeader->getTerminator());
9991013

1000-
replaceVPBBWithIRVPBB(
1001-
cast<VPBasicBlock>(getVectorLoopRegion()->getSinglePredecessor()),
1002-
VectorPreHeader);
1014+
// Disconnect VectorPreHeader from ExitBB in both the CFG and DT.
1015+
cast<BranchInst>(VectorPreHeader->getTerminator())->setSuccessor(0, nullptr);
10031016
State->CFG.DTU.applyUpdates(
10041017
{{DominatorTree::Delete, VectorPreHeader, State->CFG.ExitBB}});
10051018

1006-
// Replace regular VPBB's for the middle and scalar preheader blocks with
1007-
// VPIRBasicBlocks wrapping their IR blocks. The IR blocks are created during
1008-
// skeleton creation, so we can only create the VPIRBasicBlocks now during
1009-
// VPlan execution rather than earlier during VPlan construction.
1019+
// Replace regular VPBB's for the vector preheader, middle and scalar
1020+
// preheader blocks with VPIRBasicBlocks wrapping their IR blocks. The IR
1021+
// blocks are created during skeleton creation, so we can only create the
1022+
// VPIRBasicBlocks now during VPlan execution rather than earlier during VPlan
1023+
// construction.
1024+
replaceVPBBWithIRVPBB(getVectorPreheader(), VectorPreHeader);
10101025
BasicBlock *MiddleBB = State->CFG.ExitBB;
1011-
VPBasicBlock *MiddleVPBB = getMiddleBlock();
10121026
BasicBlock *ScalarPh = MiddleBB->getSingleSuccessor();
10131027
replaceVPBBWithIRVPBB(getScalarPreheader(), ScalarPh);
1028+
VPBasicBlock *MiddleVPBB = getMiddleBlock();
10141029
replaceVPBBWithIRVPBB(MiddleVPBB, MiddleBB);
10151030

10161031
LLVM_DEBUG(dbgs() << "Executing best plan with VF=" << State->VF
@@ -1033,8 +1048,9 @@ void VPlan::execute(VPTransformState *State) {
10331048

10341049
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
10351050
Entry);
1036-
// Generate code in the loop pre-header and body.
1037-
for (VPBlockBase *Block : make_range(RPOT.begin(), RPOT.end()))
1051+
// Generate code for the VPlan, in parts of the vector skeleton, loop body and
1052+
// successor blocks including the middle, exit and scalar preheader blocks.
1053+
for (VPBlockBase *Block : RPOT)
10381054
Block->execute(State);
10391055

10401056
VPBasicBlock *LatchVPBB = getVectorLoopRegion()->getExitingBasicBlock();
@@ -1280,14 +1296,10 @@ VPlan *VPlan::duplicate() {
12801296
VPBasicBlock *VPlan::getScalarPreheader() {
12811297
auto *MiddleVPBB =
12821298
cast<VPBasicBlock>(getVectorLoopRegion()->getSingleSuccessor());
1283-
if (MiddleVPBB->getNumSuccessors() == 2) {
1284-
// Order is strict: first is the exit block, second is the scalar preheader.
1285-
return cast<VPBasicBlock>(MiddleVPBB->getSuccessors()[1]);
1286-
}
1287-
if (auto *IRVPBB = dyn_cast<VPBasicBlock>(MiddleVPBB->getSingleSuccessor()))
1288-
return IRVPBB;
1289-
1290-
return nullptr;
1299+
auto *LastSucc = MiddleVPBB->getSuccessors().back();
1300+
// Order is strict: if the last successor is VPIRBasicBlock, it must be the
1301+
// single exit.
1302+
return isa<VPIRBasicBlock>(LastSucc) ? nullptr : cast<VPBasicBlock>(LastSucc);
12911303
}
12921304

12931305
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3715,8 +3715,9 @@ class VPlan {
37153715
friend class VPlanPrinter;
37163716
friend class VPSlotTracker;
37173717

3718-
/// Hold the single entry to the Hierarchical CFG of the VPlan, i.e. the
3719-
/// preheader of the vector loop.
3718+
/// VPBasicBlock corresponding to the original preheader. Used to place
3719+
/// VPExpandSCEV recipes for expressions used during skeleton creation and the
3720+
/// rest of VPlan execution.
37203721
VPBasicBlock *Entry;
37213722

37223723
/// VPIRBasicBlock wrapping the header of the original scalar loop.
@@ -3763,12 +3764,21 @@ class VPlan {
37633764
DenseMap<const SCEV *, VPValue *> SCEVToExpansion;
37643765

37653766
public:
3766-
/// Construct a VPlan with \p Entry entering the plan and trip count \p TC.
3767+
/// Construct a VPlan with \p Entry entering the plan, trip count \p TC and
3768+
/// with \p ScalarHeader wrapping the original header of the scalar loop.
37673769
VPlan(VPBasicBlock *Entry, VPValue *TC, VPIRBasicBlock *ScalarHeader)
37683770
: VPlan(Entry, ScalarHeader) {
37693771
TripCount = TC;
37703772
}
37713773

3774+
/// Constructor variants that take disconnected preheader and entry blocks,
3775+
/// connecting them as part of construction. Only used to reduce the need of
3776+
/// code changes during transition.
3777+
VPlan(VPBasicBlock *Preheader, VPValue *TC, VPBasicBlock *Entry,
3778+
VPIRBasicBlock *ScalarHeader);
3779+
VPlan(VPBasicBlock *Preheader, VPBasicBlock *Entry,
3780+
VPIRBasicBlock *ScalarHeader);
3781+
37723782
/// Construct a VPlan with \p Entry to the plan.
37733783
VPlan(VPBasicBlock *Entry, VPIRBasicBlock *ScalarHeader)
37743784
: Entry(Entry), ScalarHeader(ScalarHeader) {
@@ -3968,6 +3978,10 @@ class VPlan {
39683978
SCEVToExpansion[S] = V;
39693979
}
39703980

3981+
/// \return The block corresponding to the original preheader.
3982+
VPBasicBlock *getPreheader() { return Entry; }
3983+
const VPBasicBlock *getPreheader() const { return Entry; }
3984+
39713985
/// Clone the current VPlan, update all VPValues of the new VPlan and cloned
39723986
/// recipes to refer to the clones, and return it.
39733987
VPlan *duplicate();

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,16 +3241,20 @@ void VPWidenPointerInductionRecipe::print(raw_ostream &O, const Twine &Indent,
32413241
void VPExpandSCEVRecipe::execute(VPTransformState &State) {
32423242
assert(!State.Lane && "cannot be used in per-lane");
32433243
if (State.ExpandedSCEVs.contains(Expr)) {
3244+
// SCEV Expr has already been expanded, result must already be set. At the
3245+
// moment we have to execute the entry block twice (once before skeleton
3246+
// creation to get expanded SCEVs used by the skeleton and once during
3247+
// regular VPlan execution).
32443248
State.Builder.SetInsertPoint(State.CFG.VPBB2IRBB[getParent()]);
3249+
assert(State.get(this, VPLane(0)) == State.ExpandedSCEVs[Expr] &&
3250+
"Results must match");
32453251
return;
32463252
}
32473253

32483254
const DataLayout &DL = State.CFG.PrevBB->getDataLayout();
32493255
SCEVExpander Exp(SE, DL, "induction");
32503256
Value *Res = Exp.expandCodeFor(Expr, Expr->getType(),
32513257
&*State.Builder.GetInsertPoint());
3252-
/* assert(!State.ExpandedSCEVs.contains(Expr) &&*/
3253-
/*"Same SCEV expanded multiple times");*/
32543258
State.ExpandedSCEVs[Expr] = Res;
32553259
State.set(this, Res, VPLane(0));
32563260
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,8 @@ static bool mergeBlocksIntoPredecessors(VPlan &Plan) {
377377
continue;
378378
auto *PredVPBB =
379379
dyn_cast_or_null<VPBasicBlock>(VPBB->getSinglePredecessor());
380-
if (!PredVPBB || PredVPBB->getNumSuccessors() != 1)
381-
continue;
382-
if (isa<VPIRBasicBlock>(PredVPBB))
380+
if (!PredVPBB || PredVPBB->getNumSuccessors() != 1 ||
381+
isa<VPIRBasicBlock>(PredVPBB))
383382
continue;
384383
WorkList.push_back(VPBB);
385384
}

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
6262
; IF-EVL-OUTLOOP-NEXT: EMIT branch-on-cond ir<true>
6363
; IF-EVL-OUTLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
6464
; IF-EVL-OUTLOOP-EMPTY:
65-
; IF-EVL-OUTLOOP-NEXT: ir-bb<for.end>:
66-
; IF-EVL-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
67-
; IF-EVL-OUTLOOP-NEXT: No successors
68-
; IF-EVL-OUTLOOP-EMPTY:
6965
; IF-EVL-OUTLOOP-NEXT: scalar.ph:
7066
; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[RED_RESUME:%.+]]> = resume-phi vp<[[RDX]]>, ir<%start>
7167
; IF-EVL-OUTLOOP-NEXT: Successor(s): ir-bb<for.body>
@@ -77,7 +73,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
7773
; IF-EVL-OUTLOOP-NEXT: No successors
7874
; IF-EVL-OUTLOOP-EMPTY:
7975
; IF-EVL-OUTLOOP-NEXT: ir-bb<for.end>:
80-
; IF-EVL-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]>)
76+
; IF-EVL-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
8177
; IF-EVL-OUTLOOP-NEXT: No successors
8278
; IF-EVL-OUTLOOP-NEXT: }
8379
;
@@ -116,10 +112,6 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
116112
; IF-EVL-INLOOP-NEXT: EMIT branch-on-cond ir<true>
117113
; IF-EVL-INLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
118114
; IF-EVL-INLOOP-EMPTY:
119-
; IF-EVL-INLOOP-NEXT: ir-bb<for.end>:
120-
; IF-EVL-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
121-
; IF-EVL-INLOOP-NEXT: No successors
122-
; IF-EVL-INLOOP-EMPTY:
123115
; IF-EVL-INLOOP-NEXT: scalar.ph:
124116
; IF-EVL-INLOOP-NEXT: EMIT vp<[[RED_RESUME:%.+]]> = resume-phi vp<[[RDX]]>, ir<%start>
125117
; IF-EVL-INLOOP-NEXT: Successor(s): ir-bb<for.body>
@@ -131,7 +123,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
131123
; IF-EVL-INLOOP-NEXT: No successors
132124
; IF-EVL-INLOOP-EMPTY:
133125
; IF-EVL-INLOOP-NEXT: ir-bb<for.end>:
134-
; IF-EVL-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]>)
126+
; IF-EVL-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
135127
; IF-EVL-INLOOP-NEXT: No successors
136128
; IF-EVL-INLOOP-NEXT: }
137129
;
@@ -166,10 +158,6 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
166158
; NO-VP-OUTLOOP-NEXT: EMIT branch-on-cond vp<[[BOC]]>
167159
; NO-VP-OUTLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
168160
; NO-VP-OUTLOOP-EMPTY:
169-
; NO-VP-OUTLOOP-NEXT: ir-bb<for.end>:
170-
; NO-VP-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
171-
; NO-VP-OUTLOOP-NEXT: No successors
172-
; NO-VP-OUTLOOP-EMPTY:
173161
; NO-VP-OUTLOOP-NEXT: scalar.ph:
174162
; NO-VP-OUTLOOP-NEXT: EMIT vp<[[RED_RESUME:%.+]]> = resume-phi vp<[[RDX]]>, ir<%start>
175163
; NO-VP-OUTLOOP-NEXT: Successor(s): ir-bb<for.body>
@@ -181,7 +169,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
181169
; NO-VP-OUTLOOP-NEXT: No successors
182170
; NO-VP-OUTLOOP-EMPTY:
183171
; NO-VP-OUTLOOP-NEXT: ir-bb<for.end>:
184-
; NO-VP-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]>)
172+
; NO-VP-OUTLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
185173
; NO-VP-OUTLOOP-NEXT: No successors
186174
; NO-VP-OUTLOOP-NEXT: }
187175
;
@@ -216,10 +204,6 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
216204
; NO-VP-INLOOP-NEXT: EMIT branch-on-cond vp<[[BOC]]>
217205
; NO-VP-INLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
218206
; NO-VP-INLOOP-EMPTY:
219-
; NO-VP-INLOOP-NEXT: ir-bb<for.end>:
220-
; NO-VP-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
221-
; NO-VP-INLOOP-NEXT: No successors
222-
; NO-VP-INLOOP-EMPTY:
223207
; NO-VP-INLOOP-NEXT: scalar.ph:
224208
; NO-VP-INLOOP-NEXT: EMIT vp<[[RED_RESUME:%.+]]> = resume-phi vp<[[RDX]]>, ir<%start>
225209
; NO-VP-INLOOP-NEXT: Successor(s): ir-bb<for.body>
@@ -231,7 +215,7 @@ define i32 @reduction(ptr %a, i64 %n, i32 %start) {
231215
; NO-VP-INLOOP-NEXT: No successors
232216
; NO-VP-INLOOP-EMPTY:
233217
; NO-VP-INLOOP-NEXT: ir-bb<for.end>:
234-
; NO-VP-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]>)
218+
; NO-VP-INLOOP-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[RDX_EX]]> from middle.block)
235219
; NO-VP-INLOOP-NEXT: No successors
236220
; NO-VP-INLOOP-NEXT: }
237221
;

llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
4444
LLVMContext C;
4545
auto *ScalarHeader = BasicBlock::Create(C, "");
4646
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
47-
VPBlockUtils::connectBlocks(VPPH, VPBB0);
4847
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
49-
VPlan Plan(VPPH, &*TC, ScalarHeaderVPBB);
48+
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
5049

5150
VPDominatorTree VPDT;
5251
VPDT.recalculate(Plan);
@@ -125,9 +124,8 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
125124

126125
auto TC = std::make_unique<VPValue>();
127126
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
128-
VPBlockUtils::connectBlocks(VPPH, VPBB0);
129127
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
130-
VPlan Plan(VPPH, &*TC, ScalarHeaderVPBB);
128+
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
131129
VPDominatorTree VPDT;
132130
VPDT.recalculate(Plan);
133131

@@ -208,9 +206,8 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
208206

209207
auto TC = std::make_unique<VPValue>();
210208
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
211-
VPBlockUtils::connectBlocks(VPPH, VPBB1);
212209
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
213-
VPlan Plan(VPPH, &*TC, ScalarHeaderVPBB);
210+
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
214211
VPDominatorTree VPDT;
215212
VPDT.recalculate(Plan);
216213

0 commit comments

Comments
 (0)