@@ -7513,7 +7513,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
7513
7513
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
7514
7514
// cost model is complete for better cost estimates.
7515
7515
VPlanTransforms::unrollByUF (BestVPlan, BestUF,
7516
- OrigLoop->getHeader ()->getModule ()-> getContext ());
7516
+ OrigLoop->getHeader ()->getContext ());
7517
7517
VPlanTransforms::optimizeForVFAndUF (BestVPlan, BestVF, BestUF, PSE);
7518
7518
7519
7519
LLVM_DEBUG (dbgs () << " Executing best plan with VF=" << BestVF
@@ -8344,8 +8344,8 @@ VPWidenCallRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI,
8344
8344
if (Legal->isMaskRequired (CI))
8345
8345
Mask = getBlockInMask (CI->getParent ());
8346
8346
else
8347
- Mask = Plan.getOrAddLiveIn (ConstantInt::getTrue (
8348
- IntegerType::getInt1Ty (Variant-> getFunctionType () ->getContext ())));
8347
+ Mask = Plan.getOrAddLiveIn (
8348
+ ConstantInt::getTrue ( IntegerType::getInt1Ty (CI ->getContext ())));
8349
8349
8350
8350
Ops.insert (Ops.begin () + *MaskPos, Mask);
8351
8351
}
@@ -8713,15 +8713,13 @@ static SetVector<VPIRInstruction *> collectUsersInExitBlock(
8713
8713
// Add exit values to \p Plan. Extracts are added for each entry in \p
8714
8714
// ExitUsersToFix if needed and their operands are updated.
8715
8715
static void
8716
- addUsersInExitBlock (VPlan &Plan,
8716
+ addUsersInExitBlock (VPlan &Plan, LLVMContext &Ctx,
8717
8717
const SetVector<VPIRInstruction *> &ExitUsersToFix) {
8718
8718
if (ExitUsersToFix.empty ())
8719
8719
return ;
8720
8720
8721
8721
auto *MiddleVPBB =
8722
8722
cast<VPBasicBlock>(Plan.getVectorLoopRegion ()->getSingleSuccessor ());
8723
- BasicBlock *ExitBB =
8724
- cast<VPIRBasicBlock>(MiddleVPBB->getSuccessors ()[0 ])->getIRBasicBlock ();
8725
8723
VPBuilder B (MiddleVPBB, MiddleVPBB->getFirstNonPhi ());
8726
8724
8727
8725
// Introduce extract for exiting values and update the VPIRInstructions
@@ -8732,10 +8730,9 @@ addUsersInExitBlock(VPlan &Plan,
8732
8730
if (V->isLiveIn ())
8733
8731
continue ;
8734
8732
8735
- VPValue *Ext = B.createNaryOp (
8736
- VPInstruction::ExtractFromEnd,
8737
- {V, Plan.getOrAddLiveIn (ConstantInt::get (
8738
- IntegerType::get (ExitBB->getContext (), 32 ), 1 ))});
8733
+ VPValue *Ext = B.createNaryOp (VPInstruction::ExtractFromEnd,
8734
+ {V, Plan.getOrAddLiveIn (ConstantInt::get (
8735
+ IntegerType::get (Ctx, 32 ), 1 ))});
8739
8736
ExitIRI->setOperand (0 , Ext);
8740
8737
}
8741
8738
}
@@ -8898,9 +8895,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
8898
8895
return !CM.requiresScalarEpilogue (VF.isVector ());
8899
8896
},
8900
8897
Range);
8901
- VPlanPtr Plan = VPlan::createInitialVPlan (Legal->getWidestInductionType (),
8902
- PSE, RequiresScalarEpilogueCheck,
8903
- CM.foldTailByMasking (), OrigLoop);
8898
+ Type *WidestIndTy = Legal->getWidestInductionType ();
8899
+ VPlanPtr Plan =
8900
+ VPlan::createInitialVPlan (WidestIndTy, PSE, RequiresScalarEpilogueCheck,
8901
+ CM.foldTailByMasking (), OrigLoop);
8904
8902
8905
8903
// Don't use getDecisionAndClampRange here, because we don't know the UF
8906
8904
// so this function is better to be conservative, rather than to split
@@ -8915,7 +8913,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
8915
8913
// When not folding the tail, we know that the induction increment will not
8916
8914
// overflow.
8917
8915
bool HasNUW = Style == TailFoldingStyle::None;
8918
- addCanonicalIVRecipes (*Plan, Legal-> getWidestInductionType () , HasNUW, DL);
8916
+ addCanonicalIVRecipes (*Plan, WidestIndTy , HasNUW, DL);
8919
8917
8920
8918
VPRecipeBuilder RecipeBuilder (*Plan, OrigLoop, TLI, Legal, CM, PSE, Builder);
8921
8919
@@ -9047,7 +9045,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
9047
9045
SetVector<VPIRInstruction *> ExitUsersToFix = collectUsersInExitBlock (
9048
9046
OrigLoop, RecipeBuilder, *Plan, Legal->getInductionVars ());
9049
9047
addLiveOutsForFirstOrderRecurrences (*Plan, ExitUsersToFix);
9050
- addUsersInExitBlock (*Plan, ExitUsersToFix);
9048
+ addUsersInExitBlock (*Plan, WidestIndTy-> getContext (), ExitUsersToFix);
9051
9049
9052
9050
// ---------------------------------------------------------------------------
9053
9051
// Transform initial VPlan: Apply previously taken decisions, in order, to
0 commit comments