Skip to content

Commit 1e16872

Browse files
committed
!fixup address latest comments, thanks!
1 parent 208a182 commit 1e16872

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,12 +2354,15 @@ EpilogueVectorizerMainLoop::createIterationCountCheck(ElementCount VF,
23542354
}
23552355

23562356
/// Replace \p VPBB with a VPIRBasicBlock wrapping \p IRBB. All recipes from \p
2357-
/// VPBB are moved to the end of the newly created VPIRBasicBlock. VPBB must
2358-
/// have a single predecessor, which is rewired to the new VPIRBasicBlock. All
2359-
/// successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
2360-
static VPIRBasicBlock *replaceVPBBWithIRVPBB(VPlan &Plan, VPBasicBlock *VPBB,
2361-
BasicBlock *IRBB) {
2362-
VPIRBasicBlock *IRVPBB = Plan.createVPIRBasicBlock(IRBB);
2357+
/// VPBB are moved to the end of the newly created VPIRBasicBlock. All
2358+
/// predecessors and successors of VPBB, if any, are rewired to the new
2359+
/// VPIRBasicBlock. If \p VPBB may be unreachable, \p Plan must be passed.
2360+
static VPIRBasicBlock *replaceVPBBWithIRVPBB(VPBasicBlock *VPBB,
2361+
BasicBlock *IRBB,
2362+
VPlan *Plan = nullptr) {
2363+
if (!Plan)
2364+
Plan = VPBB->getPlan();
2365+
VPIRBasicBlock *IRVPBB = Plan->createVPIRBasicBlock(IRBB);
23632366
auto IP = IRVPBB->begin();
23642367
for (auto &R : make_early_inc_range(VPBB->phis()))
23652368
R.moveBefore(*IRVPBB, IP);
@@ -2570,7 +2573,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
25702573
// Remove redundant induction instructions.
25712574
cse(HeaderBB);
25722575

2573-
if (Plan.getScalarPreheader()->getNumPredecessors() == 0)
2576+
if (Plan.getScalarPreheader()->hasPredecessors())
25742577
return;
25752578

25762579
// Set/update profile weights for the vector and remainder loops as original
@@ -7274,8 +7277,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
72747277
BasicBlock *EntryBB =
72757278
cast<VPIRBasicBlock>(BestVPlan.getEntry())->getIRBasicBlock();
72767279
State.CFG.PrevBB = ILV.createVectorizedLoopSkeleton();
7277-
replaceVPBBWithIRVPBB(BestVPlan, BestVPlan.getScalarPreheader(),
7278-
State.CFG.PrevBB->getSingleSuccessor());
7280+
replaceVPBBWithIRVPBB(BestVPlan.getScalarPreheader(),
7281+
State.CFG.PrevBB->getSingleSuccessor(), &BestVPlan);
72797282
VPlanTransforms::removeDeadRecipes(BestVPlan);
72807283

72817284
assert(verifyVPlanIsValid(BestVPlan, true /*VerifyLate*/) &&
@@ -7475,8 +7478,7 @@ EpilogueVectorizerMainLoop::emitIterationCountCheck(BasicBlock *Bypass,
74757478
// generated here dominates the vector epilog iter check.
74767479
EPI.TripCount = Count;
74777480
} else {
7478-
VectorPHVPBB =
7479-
replaceVPBBWithIRVPBB(Plan, VectorPHVPBB, LoopVectorPreHeader);
7481+
VectorPHVPBB = replaceVPBBWithIRVPBB(VectorPHVPBB, LoopVectorPreHeader);
74807482
}
74817483

74827484
BranchInst &BI =
@@ -7509,7 +7511,7 @@ BasicBlock *EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton() {
75097511
BasicBlock *VecEpilogueIterationCountCheck =
75107512
SplitBlock(LoopVectorPreHeader, LoopVectorPreHeader->begin(), DT, LI,
75117513
nullptr, "vec.epilog.iter.check", true);
7512-
VectorPHVPBB = replaceVPBBWithIRVPBB(Plan, VectorPHVPBB, LoopVectorPreHeader);
7514+
VectorPHVPBB = replaceVPBBWithIRVPBB(VectorPHVPBB, LoopVectorPreHeader);
75137515

75147516
emitMinimumVectorEpilogueIterCountCheck(ScalarPH,
75157517
VecEpilogueIterationCountCheck);

llvm/test/Transforms/LoopVectorize/X86/cost-conditional-branches.ll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ target triple = "x86_64-apple-macosx10.8.0"
77
define void @test_replicate_call_chain(float %x, ptr noalias %A, ptr noalias %B, ptr align 4 noalias %C, ptr align 4 noalias %D, ptr noalias %E) #0 {
88
; CHECK-LABEL: @test_replicate_call_chain(
99
; CHECK-NEXT: entry:
10-
; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
10+
; CHECK-NEXT: br label [[VECTOR_PH:%.*]]
1111
; CHECK: vector.ph:
1212
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
1313
; CHECK: vector.body:
@@ -97,14 +97,12 @@ define void @test_replicate_call_chain(float %x, ptr noalias %A, ptr noalias %B,
9797
; CHECK-NEXT: [[TMP75:%.*]] = icmp eq i64 [[INDEX_NEXT]], 96
9898
; CHECK-NEXT: br i1 [[TMP75]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
9999
; CHECK: middle.block:
100-
; CHECK-NEXT: br label [[SCALAR_PH]]
100+
; CHECK-NEXT: br label [[SCALAR_PH:%.*]]
101101
; CHECK: scalar.ph:
102-
; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 96, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
103-
; CHECK-NEXT: [[BC_RESUME_VAL2:%.*]] = phi i64 [ 4, [[MIDDLE_BLOCK]] ], [ 100, [[ENTRY]] ]
104102
; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
105103
; CHECK: loop.header:
106-
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
107-
; CHECK-NEXT: [[DEC_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL2]], [[SCALAR_PH]] ], [ [[DEC_IV_NEXT:%.*]], [[LOOP_LATCH]] ]
104+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 96, [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
105+
; CHECK-NEXT: [[DEC_IV:%.*]] = phi i64 [ 4, [[SCALAR_PH]] ], [ [[DEC_IV_NEXT:%.*]], [[LOOP_LATCH]] ]
108106
; CHECK-NEXT: [[IV_INC:%.*]] = add i64 [[IV]], 1
109107
; CHECK-NEXT: [[GEP_A:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[IV]]
110108
; CHECK-NEXT: [[L_A:%.*]] = load float, ptr [[GEP_A]], align 4

0 commit comments

Comments
 (0)