@@ -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 ();
@@ -1520,7 +1523,7 @@ static bool isConditionTrueViaVFAndUF(VPValue *Cond, VPlan &Plan,
15201523 return isConditionTrueViaVFAndUF (C, Plan, BestVF, BestUF, SE);
15211524 });
15221525
1523- auto *CanIV = Plan.getCanonicalIV ();
1526+ auto *CanIV = Plan.getVectorLoopRegion ()-> getCanonicalIV ();
15241527 if (!match (Cond, m_SpecificICmp (CmpInst::ICMP_EQ,
15251528 m_Specific (CanIV->getBackedgeValue ()),
15261529 m_Specific (&Plan.getVectorTripCount ()))))
@@ -2304,7 +2307,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23042307 VPlan &Plan, bool DataAndControlFlowWithoutRuntimeCheck) {
23052308 VPRegionBlock *TopRegion = Plan.getVectorLoopRegion ();
23062309 VPBasicBlock *EB = TopRegion->getExitingBasicBlock ();
2307- auto *CanonicalIVPHI = Plan. getCanonicalIV ();
2310+ auto *CanonicalIVPHI = TopRegion-> getCanonicalIV ();
23082311 VPValue *StartV = CanonicalIVPHI->getStartValue ();
23092312
23102313 auto *CanonicalIVIncrement =
@@ -2343,7 +2346,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23432346
23442347 // Create the active lane mask instruction in the VPlan preheader.
23452348 VPValue *ALMMultiplier = Plan.getOrAddLiveIn (
2346- ConstantInt::get (Plan. getCanonicalIV ()->getScalarType (), 1 ));
2349+ ConstantInt::get (TopRegion-> getCanonicalIV ()->getScalarType (), 1 ));
23472350 auto *EntryALM = Builder.createNaryOp (VPInstruction::ActiveLaneMask,
23482351 {EntryIncrement, TC, ALMMultiplier}, DL,
23492352 " active.lane.mask.entry" );
@@ -2379,21 +2382,23 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
23792382// / TODO: Introduce explicit recipe for header-mask instead of searching
23802383// / for the header-mask pattern manually.
23812384static VPSingleDefRecipe *findHeaderMask (VPlan &Plan) {
2385+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
23822386 SmallVector<VPValue *> WideCanonicalIVs;
2383- auto *FoundWidenCanonicalIVUser = find_if (Plan. getCanonicalIV ()-> users (),
2384- IsaPred<VPWidenCanonicalIVRecipe>);
2385- assert (count_if (Plan. getCanonicalIV ()->users (),
2387+ auto *FoundWidenCanonicalIVUser = find_if (
2388+ LoopRegion-> getCanonicalIV ()-> users (), IsaPred<VPWidenCanonicalIVRecipe>);
2389+ assert (count_if (LoopRegion-> getCanonicalIV ()->users (),
23862390 IsaPred<VPWidenCanonicalIVRecipe>) <= 1 &&
23872391 " Must have at most one VPWideCanonicalIVRecipe" );
2388- if (FoundWidenCanonicalIVUser != Plan.getCanonicalIV ()->users ().end ()) {
2392+ if (FoundWidenCanonicalIVUser !=
2393+ LoopRegion->getCanonicalIV ()->users ().end ()) {
23892394 auto *WideCanonicalIV =
23902395 cast<VPWidenCanonicalIVRecipe>(*FoundWidenCanonicalIVUser);
23912396 WideCanonicalIVs.push_back (WideCanonicalIV);
23922397 }
23932398
23942399 // Also include VPWidenIntOrFpInductionRecipes that represent a widened
23952400 // version of the canonical induction.
2396- VPBasicBlock *HeaderVPBB = Plan. getVectorLoopRegion () ->getEntryBasicBlock ();
2401+ VPBasicBlock *HeaderVPBB = LoopRegion ->getEntryBasicBlock ();
23972402 for (VPRecipeBase &Phi : HeaderVPBB->phis ()) {
23982403 auto *WidenOriginalIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
23992404 if (WidenOriginalIV && WidenOriginalIV->isCanonical ())
@@ -2426,8 +2431,9 @@ void VPlanTransforms::addActiveLaneMask(
24262431 " DataAndControlFlowWithoutRuntimeCheck implies "
24272432 " UseActiveLaneMaskForControlFlow" );
24282433
2429- auto *FoundWidenCanonicalIVUser = find_if (Plan.getCanonicalIV ()->users (),
2430- IsaPred<VPWidenCanonicalIVRecipe>);
2434+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
2435+ auto *FoundWidenCanonicalIVUser = find_if (
2436+ LoopRegion->getCanonicalIV ()->users (), IsaPred<VPWidenCanonicalIVRecipe>);
24312437 assert (FoundWidenCanonicalIVUser &&
24322438 " Must have widened canonical IV when tail folding!" );
24332439 VPSingleDefRecipe *HeaderMask = findHeaderMask (Plan);
@@ -2440,7 +2446,7 @@ void VPlanTransforms::addActiveLaneMask(
24402446 } else {
24412447 VPBuilder B = VPBuilder::getToInsertAfter (WideCanonicalIV);
24422448 VPValue *ALMMultiplier = Plan.getOrAddLiveIn (
2443- ConstantInt::get (Plan. getCanonicalIV ()->getScalarType (), 1 ));
2449+ ConstantInt::get (LoopRegion-> getCanonicalIV ()->getScalarType (), 1 ));
24442450 LaneMask =
24452451 B.createNaryOp (VPInstruction::ActiveLaneMask,
24462452 {WideCanonicalIV, Plan.getTripCount (), ALMMultiplier},
@@ -2550,9 +2556,10 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
25502556 });
25512557
25522558 assert (all_of (Plan.getVFxUF ().users (),
2553- [&Plan](VPUser *U) {
2554- return match (U, m_c_Add (m_Specific (Plan.getCanonicalIV ()),
2555- m_Specific (&Plan.getVFxUF ()))) ||
2559+ [&LoopRegion, &Plan](VPUser *U) {
2560+ return match (U,
2561+ m_c_Add (m_Specific (LoopRegion->getCanonicalIV ()),
2562+ m_Specific (&Plan.getVFxUF ()))) ||
25562563 isa<VPWidenPointerInductionRecipe>(U);
25572564 }) &&
25582565 " Only users of VFxUF should be VPWidenPointerInductionRecipe and the "
@@ -2707,9 +2714,10 @@ void VPlanTransforms::addExplicitVectorLength(
27072714 VPlan &Plan, const std::optional<unsigned > &MaxSafeElements) {
27082715 if (Plan.hasScalarVFOnly ())
27092716 return ;
2710- VPBasicBlock *Header = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
2717+ VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion ();
2718+ VPBasicBlock *Header = LoopRegion->getEntryBasicBlock ();
27112719
2712- auto *CanonicalIVPHI = Plan. getCanonicalIV ();
2720+ auto *CanonicalIVPHI = LoopRegion-> getCanonicalIV ();
27132721 auto *CanIVTy = CanonicalIVPHI->getScalarType ();
27142722 VPValue *StartV = CanonicalIVPHI->getStartValue ();
27152723
@@ -4153,7 +4161,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
41534161
41544162 // Adjust induction to reflect that the transformed plan only processes one
41554163 // original iteration.
4156- auto *CanIV = Plan. getCanonicalIV ();
4164+ auto *CanIV = VectorLoop-> getCanonicalIV ();
41574165 auto *Inc = cast<VPInstruction>(CanIV->getBackedgeValue ());
41584166 VPBuilder PHBuilder (Plan.getVectorPreheader ());
41594167
0 commit comments