@@ -2379,11 +2379,9 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
23792379 PreVectorPH->swapSuccessors ();
23802380
23812381 // We just connected a new block to the scalar preheader. Update all
2382- // ResumePhis by adding an incoming value for it, replicating the last value.
2383- for (VPRecipeBase &R : *cast<VPBasicBlock>(ScalarPH)) {
2384- auto *ResumePhi = dyn_cast<VPInstruction>(&R);
2385- if (!ResumePhi || ResumePhi->getOpcode () != VPInstruction::ResumePhi)
2386- continue ;
2382+ // VPPhis by adding an incoming value for it, replicating the last value.
2383+ for (VPRecipeBase &R : cast<VPBasicBlock>(ScalarPH)->phis ()) {
2384+ auto *ResumePhi = cast<VPPhi>(&R);
23872385 ResumePhi->addOperand (
23882386 ResumePhi->getOperand (ResumePhi->getNumOperands () - 1 ));
23892387 }
@@ -2533,7 +2531,8 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(BasicBlock *Bypass) {
25332531static void replaceVPBBWithIRVPBB (VPBasicBlock *VPBB, BasicBlock *IRBB) {
25342532 VPIRBasicBlock *IRVPBB = VPBB->getPlan ()->createVPIRBasicBlock (IRBB);
25352533 for (auto &R : make_early_inc_range (*VPBB)) {
2536- assert (!R.isPhi () && " Tried to move phi recipe to end of block" );
2534+ assert ((IRVPBB->empty () || IRVPBB->back ().isPhi () || !R.isPhi ()) &&
2535+ " Tried to move phi recipe after a non-phi recipe" );
25372536 R.moveBefore (*IRVPBB, IRVPBB->end ());
25382537 }
25392538
@@ -7535,14 +7534,10 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
75357534 // created a bc.merge.rdx Phi after the main vector body. Ensure that we carry
75367535 // over the incoming values correctly.
75377536 using namespace VPlanPatternMatch ;
7538- auto IsResumePhi = [](VPUser *U) {
7539- auto *VPI = dyn_cast<VPInstruction>(U);
7540- return VPI && VPI->getOpcode () == VPInstruction::ResumePhi;
7541- };
7542- assert (count_if (EpiRedResult->users (), IsResumePhi) == 1 &&
7537+ assert (count_if (EpiRedResult->users (), IsaPred<VPPhi>) == 1 &&
75437538 " ResumePhi must have a single user" );
75447539 auto *EpiResumePhiVPI =
7545- cast<VPInstruction>(*find_if (EpiRedResult->users (), IsResumePhi ));
7540+ cast<VPInstruction>(*find_if (EpiRedResult->users (), IsaPred<VPPhi> ));
75467541 auto *EpiResumePhi = cast<PHINode>(State.get (EpiResumePhiVPI, true ));
75477542 EpiResumePhi->setIncomingValueForBlock (
75487543 BypassBlock, MainResumePhi->getIncomingValueForBlock (BypassBlock));
@@ -8723,9 +8718,8 @@ static VPInstruction *addResumePhiRecipeForInduction(
87238718 WideIV->getDebugLoc ());
87248719 }
87258720
8726- auto *ResumePhiRecipe =
8727- ScalarPHBuilder.createNaryOp (VPInstruction::ResumePhi, {EndValue, Start},
8728- WideIV->getDebugLoc (), " bc.resume.val" );
8721+ auto *ResumePhiRecipe = ScalarPHBuilder.createScalarPhi (
8722+ {EndValue, Start}, WideIV->getDebugLoc (), " bc.resume.val" );
87298723 return ResumePhiRecipe;
87308724}
87318725
@@ -8754,8 +8748,7 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan,
87548748 if (VPInstruction *ResumePhi = addResumePhiRecipeForInduction (
87558749 WideIVR, VectorPHBuilder, ScalarPHBuilder, TypeInfo,
87568750 &Plan.getVectorTripCount ())) {
8757- assert (ResumePhi->getOpcode () == VPInstruction::ResumePhi &&
8758- " Expected a ResumePhi" );
8751+ assert (isa<VPPhi>(ResumePhi) && " Expected a phi" );
87598752 IVEndValues[WideIVR] = ResumePhi->getOperand (0 );
87608753 ScalarPhiIRI->addOperand (ResumePhi);
87618754 continue ;
@@ -8780,8 +8773,7 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan,
87808773 VPInstruction::ExtractLastElement, {ResumeFromVectorLoop}, {},
87818774 " vector.recur.extract" );
87828775 StringRef Name = IsFOR ? " scalar.recur.init" : " bc.merge.rdx" ;
8783- auto *ResumePhiR = ScalarPHBuilder.createNaryOp (
8784- VPInstruction::ResumePhi,
8776+ auto *ResumePhiR = ScalarPHBuilder.createScalarPhi (
87858777 {ResumeFromVectorLoop, VectorPhiR->getStartValue ()}, {}, Name);
87868778 ScalarPhiIRI->addOperand (ResumePhiR);
87878779 }
@@ -9961,9 +9953,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
99619953 VPI->setOperand (1 , Freeze);
99629954 if (UpdateResumePhis)
99639955 OrigStart->replaceUsesWithIf (Freeze, [Freeze](VPUser &U, unsigned ) {
9964- return Freeze != &U && isa<VPInstruction>(&U) &&
9965- cast<VPInstruction>(&U)->getOpcode () ==
9966- VPInstruction::ResumePhi;
9956+ return Freeze != &U && isa<VPPhi>(&U);
99679957 });
99689958 }
99699959 };
@@ -9976,13 +9966,12 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
99769966 // scalar (which will become vector) epilogue loop we are done. Otherwise
99779967 // create it below.
99789968 if (any_of (*MainScalarPH, [VectorTC](VPRecipeBase &R) {
9979- return match (&R, m_VPInstruction<VPInstruction::ResumePhi>(
9980- m_Specific (VectorTC), m_SpecificInt (0 )));
9969+ return match (&R, m_VPInstruction<Instruction::PHI>( m_Specific (VectorTC),
9970+ m_SpecificInt (0 )));
99819971 }))
99829972 return ;
99839973 VPBuilder ScalarPHBuilder (MainScalarPH, MainScalarPH->begin ());
9984- ScalarPHBuilder.createNaryOp (
9985- VPInstruction::ResumePhi,
9974+ ScalarPHBuilder.createScalarPhi (
99869975 {VectorTC, MainPlan.getCanonicalIV ()->getStartValue ()}, {},
99879976 " vec.epilog.resume.val" );
99889977}
0 commit comments