@@ -2093,17 +2093,16 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
20932093 // TODO: Use VPInstruction::ExplicitVectorLength to get maximum EVL.
20942094 VPValue *MaxEVL = &Plan.getVF ();
20952095 // Emit VPScalarCastRecipe in preheader if VF is not a 32 bits integer.
2096+ VPBuilder Builder (LoopRegion->getPreheaderVPBB ());
20962097 if (unsigned VFSize =
20972098 TypeInfo.inferScalarType (MaxEVL)->getScalarSizeInBits ();
20982099 VFSize != 32 ) {
2099- VPBuilder Builder (LoopRegion->getPreheaderVPBB ());
21002100 MaxEVL = Builder.createScalarCast (
21012101 VFSize > 32 ? Instruction::Trunc : Instruction::ZExt, MaxEVL,
21022102 Type::getInt32Ty (Ctx), DebugLoc ());
21032103 }
2104- PrevEVL = new VPInstruction (Instruction::PHI, {MaxEVL, &EVL}, DebugLoc (),
2105- " prev.evl" );
2106- PrevEVL->insertBefore (*Header, Header->getFirstNonPhi ());
2104+ Builder.setInsertPoint (Header, Header->getFirstNonPhi ());
2105+ PrevEVL = Builder.createScalarPhi ({MaxEVL, &EVL}, DebugLoc (), " prev.evl" );
21072106 }
21082107
21092108 for (VPUser *U : to_vector (Plan.getVF ().users ())) {
@@ -2433,10 +2432,10 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
24332432 auto *PhiR = cast<VPHeaderPHIRecipe>(&R);
24342433 StringRef Name =
24352434 isa<VPCanonicalIVPHIRecipe>(PhiR) ? " index" : " evl.based.iv" ;
2436- auto *ScalarR = new VPInstruction (
2437- Instruction::PHI, {PhiR->getStartValue (), PhiR->getBackedgeValue ()},
2435+ VPBuilder Builder (PhiR);
2436+ auto *ScalarR = Builder.createScalarPhi (
2437+ {PhiR->getStartValue (), PhiR->getBackedgeValue ()},
24382438 PhiR->getDebugLoc (), Name);
2439- ScalarR->insertBefore (PhiR);
24402439 PhiR->replaceAllUsesWith (ScalarR);
24412440 ToRemove.push_back (PhiR);
24422441 continue ;
0 commit comments