Skip to content

Commit 8615193

Browse files
authored
[VPlan] Move getCanonicalIV to VPRegionBlock (NFC). (llvm#163020)
The canonical IV is tied to region blocks; move getCanonicalIV there and update all users. PR: llvm#163020
1 parent 4b89704 commit 8615193

File tree

8 files changed

+78
-58
lines changed

8 files changed

+78
-58
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8240,14 +8240,14 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
82408240
// the vector loop or when not folding the tail. In the later case, we know
82418241
// that the canonical induction increment will not overflow as the vector trip
82428242
// count is >= increment and a multiple of the increment.
8243+
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
82438244
bool HasNUW = !IVUpdateMayOverflow || Style == TailFoldingStyle::None;
82448245
if (!HasNUW) {
8245-
auto *IVInc = Plan->getVectorLoopRegion()
8246-
->getExitingBasicBlock()
8247-
->getTerminator()
8248-
->getOperand(0);
8249-
assert(match(IVInc, m_VPInstruction<Instruction::Add>(
8250-
m_Specific(Plan->getCanonicalIV()), m_VPValue())) &&
8246+
auto *IVInc =
8247+
LoopRegion->getExitingBasicBlock()->getTerminator()->getOperand(0);
8248+
assert(match(IVInc,
8249+
m_VPInstruction<Instruction::Add>(
8250+
m_Specific(LoopRegion->getCanonicalIV()), m_VPValue())) &&
82518251
"Did not find the canonical IV increment");
82528252
cast<VPRecipeWithIRFlags>(IVInc)->dropPoisonGeneratingFlags();
82538253
}
@@ -8293,7 +8293,6 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
82938293

82948294
// Scan the body of the loop in a topological order to visit each basic block
82958295
// after having visited its predecessor basic blocks.
8296-
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
82978296
VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
82988297
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
82998298
HeaderVPBB);
@@ -8377,8 +8376,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
83778376
for (VPValue *Old : Old2New.keys())
83788377
Old->getDefiningRecipe()->eraseFromParent();
83798378

8380-
assert(isa<VPRegionBlock>(Plan->getVectorLoopRegion()) &&
8381-
!Plan->getVectorLoopRegion()->getEntryBasicBlock()->empty() &&
8379+
assert(isa<VPRegionBlock>(LoopRegion) &&
8380+
!LoopRegion->getEntryBasicBlock()->empty() &&
83828381
"entry block must be set to a VPRegionBlock having a non-empty entry "
83838382
"VPBasicBlock");
83848383

@@ -9326,8 +9325,9 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
93269325
if (ResumePhiIter == MainScalarPH->phis().end()) {
93279326
VPBuilder ScalarPHBuilder(MainScalarPH, MainScalarPH->begin());
93289327
ResumePhi = ScalarPHBuilder.createScalarPhi(
9329-
{VectorTC, MainPlan.getCanonicalIV()->getStartValue()}, {},
9330-
"vec.epilog.resume.val");
9328+
{VectorTC,
9329+
MainPlan.getVectorLoopRegion()->getCanonicalIV()->getStartValue()},
9330+
{}, "vec.epilog.resume.val");
93319331
} else {
93329332
ResumePhi = cast<VPPhi>(&*ResumePhiIter);
93339333
if (MainScalarPH->begin() == MainScalarPH->end())
@@ -9354,7 +9354,7 @@ static SmallVector<Instruction *> preparePlanForEpilogueVectorLoop(
93549354
VPBasicBlock *Header = VectorLoop->getEntryBasicBlock();
93559355
Header->setName("vec.epilog.vector.body");
93569356

9357-
VPCanonicalIVPHIRecipe *IV = Plan.getCanonicalIV();
9357+
VPCanonicalIVPHIRecipe *IV = VectorLoop->getCanonicalIV();
93589358
// When vectorizing the epilogue loop, the canonical induction needs to be
93599359
// adjusted by the value after the main vector loop. Find the resume value
93609360
// created during execution of the main VPlan. It must be the first phi in the

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,6 +4058,19 @@ class LLVM_ABI_FOR_TEST VPRegionBlock : public VPBlockBase {
40584058
/// Remove the current region from its VPlan, connecting its predecessor to
40594059
/// its entry, and its exiting block to its successor.
40604060
void dissolveToCFGLoop();
4061+
4062+
/// Returns the canonical induction recipe of the region.
4063+
VPCanonicalIVPHIRecipe *getCanonicalIV() {
4064+
VPBasicBlock *EntryVPBB = getEntryBasicBlock();
4065+
if (EntryVPBB->empty()) {
4066+
// VPlan native path. TODO: Unify both code paths.
4067+
EntryVPBB = cast<VPBasicBlock>(EntryVPBB->getSingleSuccessor());
4068+
}
4069+
return cast<VPCanonicalIVPHIRecipe>(&*EntryVPBB->begin());
4070+
}
4071+
const VPCanonicalIVPHIRecipe *getCanonicalIV() const {
4072+
return const_cast<VPRegionBlock *>(this)->getCanonicalIV();
4073+
}
40614074
};
40624075

40634076
/// VPlan models a candidate for vectorization, encoding various decisions take
@@ -4369,16 +4382,6 @@ class VPlan {
43694382
LLVM_DUMP_METHOD void dump() const;
43704383
#endif
43714384

4372-
/// Returns the canonical induction recipe of the vector loop.
4373-
VPCanonicalIVPHIRecipe *getCanonicalIV() {
4374-
VPBasicBlock *EntryVPBB = getVectorLoopRegion()->getEntryBasicBlock();
4375-
if (EntryVPBB->empty()) {
4376-
// VPlan native path.
4377-
EntryVPBB = cast<VPBasicBlock>(EntryVPBB->getSingleSuccessor());
4378-
}
4379-
return cast<VPCanonicalIVPHIRecipe>(&*EntryVPBB->begin());
4380-
}
4381-
43824385
VPValue *getSCEVExpansion(const SCEV *S) const {
43834386
return SCEVToExpansion.lookup(S);
43844387
}

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,11 @@ void VPlanTransforms::attachCheckBlock(VPlan &Plan, Value *Cond,
658658
}
659659

660660
VPIRMetadata VPBranchWeights;
661-
auto *Term = VPBuilder(CheckBlockVPBB)
662-
.createNaryOp(VPInstruction::BranchOnCond, {CondVPV},
663-
Plan.getCanonicalIV()->getDebugLoc());
661+
auto *Term =
662+
VPBuilder(CheckBlockVPBB)
663+
.createNaryOp(
664+
VPInstruction::BranchOnCond, {CondVPV},
665+
Plan.getVectorLoopRegion()->getCanonicalIV()->getDebugLoc());
664666
if (AddBranchWeights) {
665667
MDBuilder MDB(Plan.getContext());
666668
MDNode *BranchWeights =
@@ -921,8 +923,8 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
921923
if (auto *DerivedIV = dyn_cast<VPDerivedIVRecipe>(VecV)) {
922924
if (DerivedIV->getNumUsers() == 1 &&
923925
DerivedIV->getOperand(1) == &Plan.getVectorTripCount()) {
924-
auto *NewSel = Builder.createSelect(AnyNaN, Plan.getCanonicalIV(),
925-
&Plan.getVectorTripCount());
926+
auto *NewSel = Builder.createSelect(
927+
AnyNaN, LoopRegion->getCanonicalIV(), &Plan.getVectorTripCount());
926928
DerivedIV->moveAfter(&*Builder.getInsertPoint());
927929
DerivedIV->setOperand(1, NewSel);
928930
continue;
@@ -935,7 +937,8 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
935937
"FMaxNum/FMinNum reduction.\n");
936938
return false;
937939
}
938-
auto *NewSel = Builder.createSelect(AnyNaN, Plan.getCanonicalIV(), VecV);
940+
auto *NewSel =
941+
Builder.createSelect(AnyNaN, LoopRegion->getCanonicalIV(), VecV);
939942
ResumeR->setOperand(0, NewSel);
940943
}
941944

llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ void VPPredicator::createHeaderMask(VPBasicBlock *HeaderVPBB, bool FoldTail) {
168168
// non-phi instructions.
169169

170170
auto &Plan = *HeaderVPBB->getPlan();
171-
auto *IV = new VPWidenCanonicalIVRecipe(Plan.getCanonicalIV());
171+
auto *IV =
172+
new VPWidenCanonicalIVRecipe(HeaderVPBB->getParent()->getCanonicalIV());
172173
Builder.setInsertPoint(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
173174
Builder.insert(IV);
174175

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ bool VPWidenIntOrFpInductionRecipe::isCanonical() const {
23442344
return false;
23452345
auto *StepC = dyn_cast<ConstantInt>(getStepValue()->getLiveInIRValue());
23462346
auto *StartC = dyn_cast<ConstantInt>(getStartValue()->getLiveInIRValue());
2347-
auto *CanIV = cast<VPCanonicalIVPHIRecipe>(&*getParent()->begin());
2347+
auto *CanIV = getParent()->getParent()->getCanonicalIV();
23482348
return StartC && StartC->isZero() && StepC && StepC->isOne() &&
23492349
getScalarType() == CanIV->getScalarType();
23502350
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ static void removeRedundantInductionCasts(VPlan &Plan) {
501501
/// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
502502
/// recipe, if it exists.
503503
static void removeRedundantCanonicalIVs(VPlan &Plan) {
504-
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
504+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
505+
VPCanonicalIVPHIRecipe *CanonicalIV = LoopRegion->getCanonicalIV();
505506
VPWidenCanonicalIVRecipe *WidenNewIV = nullptr;
506507
for (VPUser *U : CanonicalIV->users()) {
507508
WidenNewIV = dyn_cast<VPWidenCanonicalIVRecipe>(U);
@@ -512,7 +513,7 @@ static void removeRedundantCanonicalIVs(VPlan &Plan) {
512513
if (!WidenNewIV)
513514
return;
514515

515-
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
516+
VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
516517
for (VPRecipeBase &Phi : HeaderVPBB->phis()) {
517518
auto *WidenOriginalIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
518519

@@ -582,8 +583,9 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
582583
FPMathOperator *FPBinOp, Instruction *TruncI,
583584
VPValue *StartV, VPValue *Step, DebugLoc DL,
584585
VPBuilder &Builder) {
585-
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
586-
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
586+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
587+
VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
588+
VPCanonicalIVPHIRecipe *CanonicalIV = LoopRegion->getCanonicalIV();
587589
VPSingleDefRecipe *BaseIV = Builder.createDerivedIV(
588590
Kind, FPBinOp, StartV, CanonicalIV, Step, "offset.idx");
589591

@@ -800,8 +802,9 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
800802
return nullptr;
801803

802804
// Calculate the final index.
803-
VPValue *EndValue = Plan.getCanonicalIV();
804-
auto CanonicalIVType = Plan.getCanonicalIV()->getScalarType();
805+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
806+
auto *CanonicalIV = LoopRegion->getCanonicalIV();
807+
Type *CanonicalIVType = CanonicalIV->getScalarType();
805808
VPBuilder B(cast<VPBasicBlock>(PredVPBB));
806809

807810
DebugLoc DL = cast<VPInstruction>(Op)->getDebugLoc();
@@ -810,7 +813,8 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
810813
Type *FirstActiveLaneType = TypeInfo.inferScalarType(FirstActiveLane);
811814
FirstActiveLane = B.createScalarZExtOrTrunc(FirstActiveLane, CanonicalIVType,
812815
FirstActiveLaneType, DL);
813-
EndValue = B.createNaryOp(Instruction::Add, {EndValue, FirstActiveLane}, DL);
816+
VPValue *EndValue =
817+
B.createNaryOp(Instruction::Add, {CanonicalIV, FirstActiveLane}, DL);
814818

815819
// `getOptimizableIVOf()` always returns the pre-incremented IV, so if it
816820
// changed it means the exit is using the incremented value, so we need to
@@ -1530,7 +1534,7 @@ static bool isConditionTrueViaVFAndUF(VPValue *Cond, VPlan &Plan,
15301534
return isConditionTrueViaVFAndUF(C, Plan, BestVF, BestUF, SE);
15311535
});
15321536

1533-
auto *CanIV = Plan.getCanonicalIV();
1537+
auto *CanIV = Plan.getVectorLoopRegion()->getCanonicalIV();
15341538
if (!match(Cond, m_SpecificICmp(CmpInst::ICMP_EQ,
15351539
m_Specific(CanIV->getBackedgeValue()),
15361540
m_Specific(&Plan.getVectorTripCount()))))
@@ -2319,7 +2323,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23192323
VPlan &Plan, bool DataAndControlFlowWithoutRuntimeCheck) {
23202324
VPRegionBlock *TopRegion = Plan.getVectorLoopRegion();
23212325
VPBasicBlock *EB = TopRegion->getExitingBasicBlock();
2322-
auto *CanonicalIVPHI = Plan.getCanonicalIV();
2326+
auto *CanonicalIVPHI = TopRegion->getCanonicalIV();
23232327
VPValue *StartV = CanonicalIVPHI->getStartValue();
23242328

23252329
auto *CanonicalIVIncrement =
@@ -2358,7 +2362,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23582362

23592363
// Create the active lane mask instruction in the VPlan preheader.
23602364
VPValue *ALMMultiplier = Plan.getOrAddLiveIn(
2361-
ConstantInt::get(Plan.getCanonicalIV()->getScalarType(), 1));
2365+
ConstantInt::get(TopRegion->getCanonicalIV()->getScalarType(), 1));
23622366
auto *EntryALM = Builder.createNaryOp(VPInstruction::ActiveLaneMask,
23632367
{EntryIncrement, TC, ALMMultiplier}, DL,
23642368
"active.lane.mask.entry");
@@ -2394,21 +2398,23 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23942398
/// TODO: Introduce explicit recipe for header-mask instead of searching
23952399
/// for the header-mask pattern manually.
23962400
static VPSingleDefRecipe *findHeaderMask(VPlan &Plan) {
2401+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
23972402
SmallVector<VPValue *> WideCanonicalIVs;
2398-
auto *FoundWidenCanonicalIVUser = find_if(Plan.getCanonicalIV()->users(),
2399-
IsaPred<VPWidenCanonicalIVRecipe>);
2400-
assert(count_if(Plan.getCanonicalIV()->users(),
2403+
auto *FoundWidenCanonicalIVUser = find_if(
2404+
LoopRegion->getCanonicalIV()->users(), IsaPred<VPWidenCanonicalIVRecipe>);
2405+
assert(count_if(LoopRegion->getCanonicalIV()->users(),
24012406
IsaPred<VPWidenCanonicalIVRecipe>) <= 1 &&
24022407
"Must have at most one VPWideCanonicalIVRecipe");
2403-
if (FoundWidenCanonicalIVUser != Plan.getCanonicalIV()->users().end()) {
2408+
if (FoundWidenCanonicalIVUser !=
2409+
LoopRegion->getCanonicalIV()->users().end()) {
24042410
auto *WideCanonicalIV =
24052411
cast<VPWidenCanonicalIVRecipe>(*FoundWidenCanonicalIVUser);
24062412
WideCanonicalIVs.push_back(WideCanonicalIV);
24072413
}
24082414

24092415
// Also include VPWidenIntOrFpInductionRecipes that represent a widened
24102416
// version of the canonical induction.
2411-
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
2417+
VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
24122418
for (VPRecipeBase &Phi : HeaderVPBB->phis()) {
24132419
auto *WidenOriginalIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
24142420
if (WidenOriginalIV && WidenOriginalIV->isCanonical())
@@ -2441,8 +2447,9 @@ void VPlanTransforms::addActiveLaneMask(
24412447
"DataAndControlFlowWithoutRuntimeCheck implies "
24422448
"UseActiveLaneMaskForControlFlow");
24432449

2444-
auto *FoundWidenCanonicalIVUser = find_if(Plan.getCanonicalIV()->users(),
2445-
IsaPred<VPWidenCanonicalIVRecipe>);
2450+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
2451+
auto *FoundWidenCanonicalIVUser = find_if(
2452+
LoopRegion->getCanonicalIV()->users(), IsaPred<VPWidenCanonicalIVRecipe>);
24462453
assert(FoundWidenCanonicalIVUser &&
24472454
"Must have widened canonical IV when tail folding!");
24482455
VPSingleDefRecipe *HeaderMask = findHeaderMask(Plan);
@@ -2455,7 +2462,7 @@ void VPlanTransforms::addActiveLaneMask(
24552462
} else {
24562463
VPBuilder B = VPBuilder::getToInsertAfter(WideCanonicalIV);
24572464
VPValue *ALMMultiplier = Plan.getOrAddLiveIn(
2458-
ConstantInt::get(Plan.getCanonicalIV()->getScalarType(), 1));
2465+
ConstantInt::get(LoopRegion->getCanonicalIV()->getScalarType(), 1));
24592466
LaneMask =
24602467
B.createNaryOp(VPInstruction::ActiveLaneMask,
24612468
{WideCanonicalIV, Plan.getTripCount(), ALMMultiplier},
@@ -2565,9 +2572,10 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
25652572
});
25662573

25672574
assert(all_of(Plan.getVFxUF().users(),
2568-
[&Plan](VPUser *U) {
2569-
return match(U, m_c_Add(m_Specific(Plan.getCanonicalIV()),
2570-
m_Specific(&Plan.getVFxUF()))) ||
2575+
[&LoopRegion, &Plan](VPUser *U) {
2576+
return match(U,
2577+
m_c_Add(m_Specific(LoopRegion->getCanonicalIV()),
2578+
m_Specific(&Plan.getVFxUF()))) ||
25712579
isa<VPWidenPointerInductionRecipe>(U);
25722580
}) &&
25732581
"Only users of VFxUF should be VPWidenPointerInductionRecipe and the "
@@ -2722,9 +2730,10 @@ void VPlanTransforms::addExplicitVectorLength(
27222730
VPlan &Plan, const std::optional<unsigned> &MaxSafeElements) {
27232731
if (Plan.hasScalarVFOnly())
27242732
return;
2725-
VPBasicBlock *Header = Plan.getVectorLoopRegion()->getEntryBasicBlock();
2733+
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
2734+
VPBasicBlock *Header = LoopRegion->getEntryBasicBlock();
27262735

2727-
auto *CanonicalIVPHI = Plan.getCanonicalIV();
2736+
auto *CanonicalIVPHI = LoopRegion->getCanonicalIV();
27282737
auto *CanIVTy = CanonicalIVPHI->getScalarType();
27292738
VPValue *StartV = CanonicalIVPHI->getStartValue();
27302739

@@ -4164,7 +4173,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
41644173

41654174
// Adjust induction to reflect that the transformed plan only processes one
41664175
// original iteration.
4167-
auto *CanIV = Plan.getCanonicalIV();
4176+
auto *CanIV = VectorLoop->getCanonicalIV();
41684177
auto *Inc = cast<VPInstruction>(CanIV->getBackedgeValue());
41694178
VPBuilder PHBuilder(Plan.getVectorPreheader());
41704179

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class UnrollState {
6969
VPBasicBlock::iterator InsertPtForPhi);
7070

7171
VPValue *getConstantVPV(unsigned Part) {
72-
Type *CanIVIntTy = Plan.getCanonicalIV()->getScalarType();
72+
Type *CanIVIntTy =
73+
Plan.getVectorLoopRegion()->getCanonicalIV()->getScalarType();
7374
return Plan.getOrAddLiveIn(ConstantInt::get(CanIVIntTy, Part));
7475
}
7576

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ bool vputils::isHeaderMask(const VPValue *V, VPlan &Plan) {
6767

6868
if (match(V, m_ActiveLaneMask(m_VPValue(A), m_VPValue(B), m_One())))
6969
return B == Plan.getTripCount() &&
70-
(match(A, m_ScalarIVSteps(m_Specific(Plan.getCanonicalIV()), m_One(),
71-
m_Specific(&Plan.getVF()))) ||
70+
(match(A,
71+
m_ScalarIVSteps(
72+
m_Specific(Plan.getVectorLoopRegion()->getCanonicalIV()),
73+
m_One(), m_Specific(&Plan.getVF()))) ||
7274
IsWideCanonicalIV(A));
7375

7476
return match(V, m_ICmp(m_VPValue(A), m_VPValue(B))) && IsWideCanonicalIV(A) &&
@@ -102,7 +104,8 @@ bool vputils::isUniformAcrossVFsAndUFs(VPValue *V) {
102104
return all_of(R->operands(), isUniformAcrossVFsAndUFs);
103105
}
104106

105-
auto *CanonicalIV = R->getParent()->getPlan()->getCanonicalIV();
107+
auto *CanonicalIV =
108+
R->getParent()->getEnclosingLoopRegion()->getCanonicalIV();
106109
// Canonical IV chain is uniform.
107110
if (V == CanonicalIV || V == CanonicalIV->getBackedgeValue())
108111
return true;

0 commit comments

Comments
 (0)