@@ -501,7 +501,8 @@ static void removeRedundantInductionCasts(VPlan &Plan) {
501501// / Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
502502// / recipe, if it exists.
503503static 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+ VPValue *EndValue = LoopRegion->getCanonicalIV ();
807+ auto CanonicalIVType = LoopRegion->getCanonicalIV ()->getScalarType ();
805808 VPBuilder B (cast<VPBasicBlock>(PredVPBB));
806809
807810 DebugLoc DL = cast<VPInstruction>(Op)->getDebugLoc ();
@@ -1532,7 +1535,7 @@ static bool isConditionTrueViaVFAndUF(VPValue *Cond, VPlan &Plan,
15321535 return isConditionTrueViaVFAndUF (C, Plan, BestVF, BestUF, SE);
15331536 });
15341537
1535- auto *CanIV = Plan.getCanonicalIV ();
1538+ auto *CanIV = Plan.getVectorLoopRegion ()-> getCanonicalIV ();
15361539 if (!match (Cond, m_SpecificICmp (CmpInst::ICMP_EQ,
15371540 m_Specific (CanIV->getBackedgeValue ()),
15381541 m_Specific (&Plan.getVectorTripCount ()))))
@@ -2316,7 +2319,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23162319 VPlan &Plan, bool DataAndControlFlowWithoutRuntimeCheck) {
23172320 VPRegionBlock *TopRegion = Plan.getVectorLoopRegion ();
23182321 VPBasicBlock *EB = TopRegion->getExitingBasicBlock ();
2319- auto *CanonicalIVPHI = Plan. getCanonicalIV ();
2322+ auto *CanonicalIVPHI = TopRegion-> getCanonicalIV ();
23202323 VPValue *StartV = CanonicalIVPHI->getStartValue ();
23212324
23222325 auto *CanonicalIVIncrement =
@@ -2355,7 +2358,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23552358
23562359 // Create the active lane mask instruction in the VPlan preheader.
23572360 VPValue *ALMMultiplier = Plan.getOrAddLiveIn (
2358- ConstantInt::get (Plan. getCanonicalIV ()->getScalarType (), 1 ));
2361+ ConstantInt::get (TopRegion-> getCanonicalIV ()->getScalarType (), 1 ));
23592362 auto *EntryALM = Builder.createNaryOp (VPInstruction::ActiveLaneMask,
23602363 {EntryIncrement, TC, ALMMultiplier}, DL,
23612364 " active.lane.mask.entry" );
@@ -2391,21 +2394,23 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23912394// / TODO: Introduce explicit recipe for header-mask instead of searching
23922395// / for the header-mask pattern manually.
23932396static VPSingleDefRecipe *findHeaderMask (VPlan &Plan) {
2397+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
23942398 SmallVector<VPValue *> WideCanonicalIVs;
2395- auto *FoundWidenCanonicalIVUser = find_if (Plan. getCanonicalIV ()-> users (),
2396- IsaPred<VPWidenCanonicalIVRecipe>);
2397- assert (count_if (Plan. getCanonicalIV ()->users (),
2399+ auto *FoundWidenCanonicalIVUser = find_if (
2400+ LoopRegion-> getCanonicalIV ()-> users (), IsaPred<VPWidenCanonicalIVRecipe>);
2401+ assert (count_if (LoopRegion-> getCanonicalIV ()->users (),
23982402 IsaPred<VPWidenCanonicalIVRecipe>) <= 1 &&
23992403 " Must have at most one VPWideCanonicalIVRecipe" );
2400- if (FoundWidenCanonicalIVUser != Plan.getCanonicalIV ()->users ().end ()) {
2404+ if (FoundWidenCanonicalIVUser !=
2405+ LoopRegion->getCanonicalIV ()->users ().end ()) {
24012406 auto *WideCanonicalIV =
24022407 cast<VPWidenCanonicalIVRecipe>(*FoundWidenCanonicalIVUser);
24032408 WideCanonicalIVs.push_back (WideCanonicalIV);
24042409 }
24052410
24062411 // Also include VPWidenIntOrFpInductionRecipes that represent a widened
24072412 // version of the canonical induction.
2408- VPBasicBlock *HeaderVPBB = Plan. getVectorLoopRegion () ->getEntryBasicBlock ();
2413+ VPBasicBlock *HeaderVPBB = LoopRegion ->getEntryBasicBlock ();
24092414 for (VPRecipeBase &Phi : HeaderVPBB->phis ()) {
24102415 auto *WidenOriginalIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
24112416 if (WidenOriginalIV && WidenOriginalIV->isCanonical ())
@@ -2438,8 +2443,9 @@ void VPlanTransforms::addActiveLaneMask(
24382443 " DataAndControlFlowWithoutRuntimeCheck implies "
24392444 " UseActiveLaneMaskForControlFlow" );
24402445
2441- auto *FoundWidenCanonicalIVUser = find_if (Plan.getCanonicalIV ()->users (),
2442- IsaPred<VPWidenCanonicalIVRecipe>);
2446+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
2447+ auto *FoundWidenCanonicalIVUser = find_if (
2448+ LoopRegion->getCanonicalIV ()->users (), IsaPred<VPWidenCanonicalIVRecipe>);
24432449 assert (FoundWidenCanonicalIVUser &&
24442450 " Must have widened canonical IV when tail folding!" );
24452451 VPSingleDefRecipe *HeaderMask = findHeaderMask (Plan);
@@ -2452,7 +2458,7 @@ void VPlanTransforms::addActiveLaneMask(
24522458 } else {
24532459 VPBuilder B = VPBuilder::getToInsertAfter (WideCanonicalIV);
24542460 VPValue *ALMMultiplier = Plan.getOrAddLiveIn (
2455- ConstantInt::get (Plan. getCanonicalIV ()->getScalarType (), 1 ));
2461+ ConstantInt::get (LoopRegion-> getCanonicalIV ()->getScalarType (), 1 ));
24562462 LaneMask =
24572463 B.createNaryOp (VPInstruction::ActiveLaneMask,
24582464 {WideCanonicalIV, Plan.getTripCount (), ALMMultiplier},
@@ -2562,9 +2568,10 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
25622568 });
25632569
25642570 assert (all_of (Plan.getVFxUF ().users (),
2565- [&Plan](VPUser *U) {
2566- return match (U, m_c_Add (m_Specific (Plan.getCanonicalIV ()),
2567- m_Specific (&Plan.getVFxUF ()))) ||
2571+ [&LoopRegion, &Plan](VPUser *U) {
2572+ return match (U,
2573+ m_c_Add (m_Specific (LoopRegion->getCanonicalIV ()),
2574+ m_Specific (&Plan.getVFxUF ()))) ||
25682575 isa<VPWidenPointerInductionRecipe>(U);
25692576 }) &&
25702577 " Only users of VFxUF should be VPWidenPointerInductionRecipe and the "
@@ -2719,9 +2726,10 @@ void VPlanTransforms::addExplicitVectorLength(
27192726 VPlan &Plan, const std::optional<unsigned > &MaxSafeElements) {
27202727 if (Plan.hasScalarVFOnly ())
27212728 return ;
2722- VPBasicBlock *Header = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
2729+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
2730+ VPBasicBlock *Header = LoopRegion->getEntryBasicBlock ();
27232731
2724- auto *CanonicalIVPHI = Plan. getCanonicalIV ();
2732+ auto *CanonicalIVPHI = LoopRegion-> getCanonicalIV ();
27252733 auto *CanIVTy = CanonicalIVPHI->getScalarType ();
27262734 VPValue *StartV = CanonicalIVPHI->getStartValue ();
27272735
@@ -4165,7 +4173,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
41654173
41664174 // Adjust induction to reflect that the transformed plan only processes one
41674175 // original iteration.
4168- auto *CanIV = Plan. getCanonicalIV ();
4176+ auto *CanIV = VectorLoop-> getCanonicalIV ();
41694177 auto *Inc = cast<VPInstruction>(CanIV->getBackedgeValue ());
41704178 VPBuilder PHBuilder (Plan.getVectorPreheader ());
41714179
0 commit comments