@@ -526,9 +526,8 @@ static void removeDeadRecipes(VPlan &Plan) {
526526static VPScalarIVStepsRecipe *
527527createScalarIVSteps (VPlan &Plan, InductionDescriptor::InductionKind Kind,
528528 Instruction::BinaryOps InductionOpcode,
529- FPMathOperator *FPBinOp, ScalarEvolution &SE,
530- Instruction *TruncI, VPValue *StartV, VPValue *Step,
531- VPBasicBlock::iterator IP) {
529+ FPMathOperator *FPBinOp, Instruction *TruncI,
530+ VPValue *StartV, VPValue *Step, VPBasicBlock::iterator IP) {
532531 VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
533532 VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV ();
534533 VPSingleDefRecipe *BaseIV = CanonicalIV;
@@ -538,8 +537,8 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
538537 }
539538
540539 // Truncate base induction if needed.
541- VPTypeAnalysis TypeInfo (Plan. getCanonicalIV () ->getScalarType (),
542- SE. getContext ());
540+ Type *CanonicalIVType = CanonicalIV ->getScalarType ();
541+ VPTypeAnalysis TypeInfo (CanonicalIVType, CanonicalIVType-> getContext ());
543542 Type *ResultTy = TypeInfo.inferScalarType (BaseIV);
544543 if (TruncI) {
545544 Type *TruncTy = TruncI->getType ();
@@ -579,7 +578,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
579578// / if any of its users needs scalar values, by providing them scalar steps
580579// / built on the canonical scalar IV and update the original IV's users. This is
581580// / an optional optimization to reduce the needs of vector extracts.
582- static void legalizeAndOptimizeInductions (VPlan &Plan, ScalarEvolution &SE ) {
581+ static void legalizeAndOptimizeInductions (VPlan &Plan) {
583582 SmallVector<VPRecipeBase *> ToRemove;
584583 VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
585584 bool HasOnlyVectorVFs = !Plan.hasVF (ElementCount::getFixed (1 ));
@@ -597,7 +596,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
597596 VPValue *StepV = PtrIV->getOperand (1 );
598597 VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
599598 Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr ,
600- SE, nullptr , StartV, StepV, InsertPt);
599+ nullptr , StartV, StepV, InsertPt);
601600
602601 auto *Recipe = new VPInstruction (VPInstruction::PtrAdd,
603602 {PtrIV->getStartValue (), Steps},
@@ -621,7 +620,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
621620 const InductionDescriptor &ID = WideIV->getInductionDescriptor ();
622621 VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
623622 Plan, ID.getKind (), ID.getInductionOpcode (),
624- dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()), SE,
623+ dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()),
625624 WideIV->getTruncInst (), WideIV->getStartValue (), WideIV->getStepValue (),
626625 InsertPt);
627626
@@ -979,10 +978,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
979978}
980979
981980// / Try to simplify the recipes in \p Plan.
982- static void simplifyRecipes (VPlan &Plan, LLVMContext &Ctx ) {
981+ static void simplifyRecipes (VPlan &Plan) {
983982 ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT (
984983 Plan.getEntry ());
985- VPTypeAnalysis TypeInfo (Plan.getCanonicalIV ()->getScalarType (), Ctx);
984+ Type *CanonicalIVType = Plan.getCanonicalIV ()->getScalarType ();
985+ VPTypeAnalysis TypeInfo (CanonicalIVType, CanonicalIVType->getContext ());
986986 for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
987987 for (VPRecipeBase &R : make_early_inc_range (*VPBB)) {
988988 simplifyRecipe (R, TypeInfo);
@@ -991,8 +991,7 @@ static void simplifyRecipes(VPlan &Plan, LLVMContext &Ctx) {
991991}
992992
993993void VPlanTransforms::truncateToMinimalBitwidths (
994- VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs,
995- LLVMContext &Ctx) {
994+ VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs) {
996995#ifndef NDEBUG
997996 // Count the processed recipes and cross check the count later with MinBWs
998997 // size, to make sure all entries in MinBWs have been handled.
@@ -1003,7 +1002,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
10031002 // other uses have different types for their operands, making them invalidly
10041003 // typed.
10051004 DenseMap<VPValue *, VPWidenCastRecipe *> ProcessedTruncs;
1006- VPTypeAnalysis TypeInfo (Plan.getCanonicalIV ()->getScalarType (), Ctx);
1005+ Type *CanonicalIVType = Plan.getCanonicalIV ()->getScalarType ();
1006+ LLVMContext &Ctx = CanonicalIVType->getContext ();
1007+ VPTypeAnalysis TypeInfo (CanonicalIVType, Ctx);
10071008 VPBasicBlock *PH = Plan.getEntry ();
10081009 for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
10091010 vp_depth_first_deep (Plan.getVectorLoopRegion ()))) {
@@ -1123,12 +1124,12 @@ void VPlanTransforms::truncateToMinimalBitwidths(
11231124 " some entries in MinBWs haven't been processed" );
11241125}
11251126
1126- void VPlanTransforms::optimize (VPlan &Plan, ScalarEvolution &SE ) {
1127+ void VPlanTransforms::optimize (VPlan &Plan) {
11271128 removeRedundantCanonicalIVs (Plan);
11281129 removeRedundantInductionCasts (Plan);
11291130
1130- simplifyRecipes (Plan, SE. getContext () );
1131- legalizeAndOptimizeInductions (Plan, SE );
1131+ simplifyRecipes (Plan);
1132+ legalizeAndOptimizeInductions (Plan);
11321133 removeDeadRecipes (Plan);
11331134
11341135 createAndOptimizeReplicateRegions (Plan);
0 commit comments