@@ -741,8 +741,7 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) {
741741 VPValue *IVStep = WideIV->getStepValue ();
742742 switch (ID.getInductionOpcode ()) {
743743 case Instruction::Add:
744- return match (VPV, m_c_Binary<Instruction::Add>(m_Specific (WideIV),
745- m_Specific (IVStep)));
744+ return match (VPV, m_c_Add (m_Specific (WideIV), m_Specific (IVStep)));
746745 case Instruction::FAdd:
747746 return match (VPV, m_c_Binary<Instruction::FAdd>(m_Specific (WideIV),
748747 m_Specific (IVStep)));
@@ -2231,9 +2230,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
22312230
22322231 assert (all_of (Plan.getVFxUF ().users (),
22332232 [&Plan](VPUser *U) {
2234- return match (U, m_c_Binary<Instruction::Add>(
2235- m_Specific (Plan.getCanonicalIV ()),
2236- m_Specific (&Plan.getVFxUF ()))) ||
2233+ return match (U, m_c_Add (m_Specific (Plan.getCanonicalIV ()),
2234+ m_Specific (&Plan.getVFxUF ()))) ||
22372235 isa<VPWidenPointerInductionRecipe>(U);
22382236 }) &&
22392237 " Only users of VFxUF should be VPWidenPointerInductionRecipe and the "
@@ -2446,45 +2444,37 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
24462444 // Find EVL loop entries by locating VPEVLBasedIVPHIRecipe.
24472445 // There should be only one EVL PHI in the entire plan.
24482446 VPEVLBasedIVPHIRecipe *EVLPhi = nullptr ;
2449- VPValue *AVLNext = nullptr ;
24502447
24512448 for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
24522449 vp_depth_first_shallow (Plan.getEntry ())))
2453- for (VPRecipeBase &R : VPBB->phis ()) {
2454- auto *PhiR = dyn_cast<VPSingleDefRecipe>(&R);
2455- if (!PhiR)
2456- continue ;
2457- VPValue *Backedge;
2458- if (auto *EVL = dyn_cast<VPEVLBasedIVPHIRecipe>(PhiR)) {
2450+ for (VPRecipeBase &R : VPBB->phis ())
2451+ if (auto *PhiR = dyn_cast<VPEVLBasedIVPHIRecipe>(&R)) {
24592452 assert (!EVLPhi && " Found multiple EVL PHIs. Only one expected" );
2460- EVLPhi = EVL;
2461- continue ;
2462- }
2463- if (match (PhiR,
2464- m_VPInstruction<Instruction::PHI>(
2465- m_Specific (Plan.getTripCount ()), m_VPValue (Backedge))) &&
2466- match (Backedge,
2467- m_VPInstruction<Instruction::Sub>(
2468- m_Specific (PhiR),
2469- m_ZExtOrSelf (
2470- m_VPInstruction<VPInstruction::ExplicitVectorLength>(
2471- m_CombineOr (
2472- m_Specific (PhiR),
2473- // The AVL may be capped to a safe distance.
2474- m_Select (m_VPValue (), m_Specific (PhiR),
2475- m_VPValue ()))))))) {
2476- AVLNext = Backedge;
2453+ EVLPhi = PhiR;
24772454 }
2478- }
24792455
24802456 // Early return if no EVL PHI is found.
24812457 if (!EVLPhi)
24822458 return ;
24832459
2484- assert (AVLNext && " Didn't find AVL backedge?" );
2485-
24862460 VPBasicBlock *HeaderVPBB = EVLPhi->getParent ();
24872461 VPValue *EVLIncrement = EVLPhi->getBackedgeValue ();
2462+ VPValue *AVL, *EVL;
2463+ if (!match (EVLIncrement,
2464+ m_c_Add (m_ZExtOrSelf (m_VPValue (EVL)), m_Specific (EVLPhi))) ||
2465+ !match (EVL, m_EVL (m_VPValue (AVL))))
2466+ llvm_unreachable (" Didn't find EVL?" );
2467+
2468+ // The AVL may be capped to a safe distance.
2469+ VPValue *SafeAVL;
2470+ if (match (AVL, m_Select (m_VPValue (), m_VPValue (SafeAVL), m_VPValue ())))
2471+ AVL = SafeAVL;
2472+
2473+ VPValue *AVLNext;
2474+ if (!match (AVL, m_VPInstruction<Instruction::PHI>(
2475+ m_Specific (Plan.getTripCount ()), m_VPValue (AVLNext))) ||
2476+ !match (AVLNext, m_Sub (m_Specific (AVL), m_ZExtOrSelf (m_Specific (EVL)))))
2477+ llvm_unreachable (" Didn't find AVL backedge?" );
24882478
24892479 // Convert EVLPhi to concrete recipe.
24902480 auto *ScalarR =
@@ -2496,9 +2486,8 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
24962486 // Replace CanonicalIVInc with EVL-PHI increment.
24972487 auto *CanonicalIV = cast<VPPhi>(&*HeaderVPBB->begin ());
24982488 VPValue *Backedge = CanonicalIV->getIncomingValue (1 );
2499- assert (match (Backedge,
2500- m_c_Binary<Instruction::Add>(m_Specific (CanonicalIV),
2501- m_Specific (&Plan.getVFxUF ()))) &&
2489+ assert (match (Backedge, m_c_Add (m_Specific (CanonicalIV),
2490+ m_Specific (&Plan.getVFxUF ()))) &&
25022491 " Unexpected canonical iv" );
25032492 Backedge->replaceAllUsesWith (EVLIncrement);
25042493
0 commit comments