Skip to content

Commit 1ae4d5f

Browse files
committed
!fixup address comments, thanks
1 parent 66f50b9 commit 1ae4d5f

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9409,11 +9409,11 @@ static bool processLoopInVPlanNativePath(
94099409

94109410
{
94119411
GeneratedRTChecks Checks(PSE, DT, LI, TTI, F->getDataLayout(), CM.CostKind);
9412-
InnerLoopVectorizer LB(L, PSE, LI, DT, TTI, AC, VF.Width, 1, &CM, BFI, PSI,
9413-
Checks, BestPlan);
9412+
InnerLoopVectorizer LB(L, PSE, LI, DT, TTI, AC, VF.Width, /*UF=*/1, &CM,
9413+
BFI, PSI, Checks, BestPlan);
94149414
LLVM_DEBUG(dbgs() << "Vectorizing outer loop in \""
94159415
<< L->getHeader()->getParent()->getName() << "\"\n");
9416-
LVP.addMinimumIterationCheck(BestPlan, VF.Width, 1,
9416+
LVP.addMinimumIterationCheck(BestPlan, VF.Width, /*UF=*/1,
94179417
VF.MinProfitableTripCount);
94189418

94199419
LVP.executePlan(VF.Width, 1, BestPlan, LB, DT, false);

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ void VPlanTransforms::addMinimumIterationCheck(
740740
DebugLoc::getUnknown());
741741

742742
// Don't execute the vector loop if (UMax - n) < (VF * UF).
743+
// FIXME: Should only check VF * UF, but currently checks Step=max(VF*UF,
744+
// minProfitableTripCount).
743745
TripCountCheck = Builder.createICmp(ICmpInst::ICMP_ULT, DistanceToMax,
744746
Builder.createExpandSCEV(Step), DL);
745747
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3512,6 +3512,9 @@ VPlanTransforms::expandSCEVs(VPlan &Plan, ScalarEvolution &SE) {
35123512
InsertPt = std::next(ExpSCEV->getIterator());
35133513
ExpSCEV->eraseFromParent();
35143514
}
3515+
assert(none_of(*Entry, IsaPred<VPExpandSCEVRecipe>) &&
3516+
"VPExpandSCEVRecipes must be be at the beginning of the entry block, "
3517+
"after any VPIRInstructions");
35153518
for (Instruction &I : *EntryBB) {
35163519
if (!Expander.isInsertedInstruction(&I) || isa<PHINode>(I))
35173520
continue;

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,40 @@ struct VPlanTransforms {
6262
/// The created loop is wrapped in an initial skeleton to facilitate
6363
/// vectorization, consisting of a vector pre-header, an exit block for the
6464
/// main vector loop (middle.block) and a new block as preheader of the scalar
65-
/// loop (scalar.ph). It also adds a canonical IV and its increment, using \p
66-
/// InductionTy and \p IVDL, and creates a VPValue expression for the original
67-
/// trip count.
65+
/// loop (scalar.ph). See below for an illustration. It also adds a canonical
66+
/// IV and its increment, using \p InductionTy and \p IVDL, and creates a
67+
/// VPValue expression for the original trip count.
68+
///
69+
/// [ ] <-- Plan's entry VPIRBasicBlock, wrapping the original loop's
70+
/// / \ old preheader. Will contain iteration number check and SCEV
71+
/// | | expansions.
72+
/// | |
73+
/// / v
74+
/// | [ ] <-- vector loop bypass (may consist of multiple blocks) will be
75+
/// | / | added later.
76+
/// | / v
77+
/// || [ ] <-- vector pre header.
78+
/// |/ |
79+
/// | v
80+
/// | [ ] \ <-- plain CFG loop wrapping original loop to be vectorized.
81+
/// | [ ]_|
82+
/// | |
83+
/// | v
84+
/// | [ ] <--- middle-block with the branch to successors
85+
/// | / |
86+
/// | / |
87+
/// | | v
88+
/// \--->[ ] <--- scalar preheader (initial a VPBasicBlock, which will be
89+
/// | | replaced later by a VPIRBasicBlock wrapping the scalar
90+
/// | | preheader basic block.
91+
/// | |
92+
/// v <-- edge from middle to exit iff epilogue is not required.
93+
/// | [ ] \
94+
/// | [ ]_| <-- old scalar loop to handle remainder (scalar epilogue,
95+
/// | | header wrapped in VPIRBasicBlock).
96+
/// \ |
97+
/// \ v
98+
/// >[ ] <-- original loop exit block(s), wrapped in VPIRBasicBlocks.
6899
LLVM_ABI_FOR_TEST static std::unique_ptr<VPlan>
69100
buildVPlan0(Loop *TheLoop, LoopInfo &LI, Type *InductionTy, DebugLoc IVDL,
70101
PredicatedScalarEvolution &PSE);

0 commit comments

Comments
 (0)