@@ -2093,17 +2093,16 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
2093
2093
// TODO: Use VPInstruction::ExplicitVectorLength to get maximum EVL.
2094
2094
VPValue *MaxEVL = &Plan.getVF ();
2095
2095
// Emit VPScalarCastRecipe in preheader if VF is not a 32 bits integer.
2096
+ VPBuilder Builder (LoopRegion->getPreheaderVPBB ());
2096
2097
if (unsigned VFSize =
2097
2098
TypeInfo.inferScalarType (MaxEVL)->getScalarSizeInBits ();
2098
2099
VFSize != 32 ) {
2099
- VPBuilder Builder (LoopRegion->getPreheaderVPBB ());
2100
2100
MaxEVL = Builder.createScalarCast (
2101
2101
VFSize > 32 ? Instruction::Trunc : Instruction::ZExt, MaxEVL,
2102
2102
Type::getInt32Ty (Ctx), DebugLoc ());
2103
2103
}
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" );
2107
2106
}
2108
2107
2109
2108
for (VPUser *U : to_vector (Plan.getVF ().users ())) {
@@ -2433,10 +2432,10 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
2433
2432
auto *PhiR = cast<VPHeaderPHIRecipe>(&R);
2434
2433
StringRef Name =
2435
2434
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 ()},
2438
2438
PhiR->getDebugLoc (), Name);
2439
- ScalarR->insertBefore (PhiR);
2440
2439
PhiR->replaceAllUsesWith (ScalarR);
2441
2440
ToRemove.push_back (PhiR);
2442
2441
continue ;
0 commit comments