Skip to content

Commit 102396a

Browse files
committed
!fixup address comments, thanks
1 parent 005b24c commit 102396a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8385,8 +8385,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
83858385
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
83868386
auto *SingleDef = cast<VPSingleDefRecipe>(&R);
83878387
auto *UnderlyingValue = SingleDef->getUnderlyingValue();
8388-
// Skip recipes that do not need transforming, including canonical IV,
8389-
// wide canonical IV and VPInstructions without underlying values. The
8388+
// Skip recipes that do not need transforming, including blends,
8389+
// widened canonical IV and VPInstructions without underlying values. The
83908390
// latter are added above for masking.
83918391
// FIXME: Migrate code relying on the underlying instruction from VPlan0
83928392
// to construct recipes below to not use the underlying instruction.
@@ -9393,7 +9393,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
93939393
VPBuilder ScalarPHBuilder(MainScalarPH, MainScalarPH->begin());
93949394
Type *Ty = VPTypeAnalysis(MainPlan).inferScalarType(VectorTC);
93959395
ResumePhi = ScalarPHBuilder.createScalarPhi(
9396-
{VectorTC, MainPlan.getOrAddLiveIn(Constant::getNullValue(Ty))}, {},
9396+
{VectorTC, MainPlan.getConstantInt(Ty, 0)}, {},
93979397
"vec.epilog.resume.val");
93989398
} else {
93999399
ResumePhi = cast<VPPhi>(&*ResumePhiIter);

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ void VPRegionBlock::dissolveToCFGLoop() {
860860
auto *ScalarR =
861861
VPBuilder(Header, Header->begin())
862862
.createScalarPhi(
863-
{Plan.getOrAddLiveIn(ConstantInt::get(CanIVInfo->getType(), 0)),
864-
CanIVInc},
863+
{Plan.getConstantInt(CanIVInfo->getType(), 0), CanIVInc},
865864
CanIVInfo->getDebugLoc(), "index");
866865
CanIV->replaceAllUsesWith(ScalarR);
867866
}
@@ -880,6 +879,7 @@ void VPRegionBlock::dissolveToCFGLoop() {
880879
}
881880

882881
VPInstruction *VPRegionBlock::getCanonicalIVIncrement() {
882+
// TODO: Represent the increment as VPRegionValue as well.
883883
auto *ExitingLatch = cast<VPBasicBlock>(getExiting());
884884
VPValue *CanIV = getCanonicalIV();
885885
assert(CanIV && "Expected a canonical IV");
@@ -1234,6 +1234,9 @@ VPlan *VPlan::duplicate() {
12341234
// TripCount is cloned. In any case NewPlan->TripCount is updated below.
12351235

12361236
if (auto *LoopRegion = getVectorLoopRegion()) {
1237+
assert(LoopRegion->getCanonicalIV() &&
1238+
NewPlan->getVectorLoopRegion()->getCanonicalIV() &&
1239+
"Loop regions of both plans must have canonical IVs.");
12371240
Old2NewVPValues[LoopRegion->getCanonicalIV()] =
12381241
NewPlan->getVectorLoopRegion()->getCanonicalIV();
12391242
}

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3975,7 +3975,9 @@ class LLVM_ABI_FOR_TEST VPRegionBlock : public VPBlockBase {
39753975
VPBlockBase *Exiting;
39763976

39773977
/// Holds the Canonical IV of the loop region along with additional
3978-
/// information. If CanIV is nullptr, the region is a replicating region.
3978+
/// information. If CanIV is nullptr, the region is a replicating region. Loop
3979+
/// regions retain their canonical IVs until they are dissolved, even if they
3980+
/// may not have any users.
39793981
VPCanonicalIVInfo *CanIVInfo = nullptr;
39803982

39813983
/// Use VPlan::createVPRegionBlock to create VPRegionBlocks.

0 commit comments

Comments
 (0)