@@ -526,9 +526,8 @@ static void removeDeadRecipes(VPlan &Plan) {
526
526
static VPScalarIVStepsRecipe *
527
527
createScalarIVSteps (VPlan &Plan, InductionDescriptor::InductionKind Kind,
528
528
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) {
532
531
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
533
532
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV ();
534
533
VPSingleDefRecipe *BaseIV = CanonicalIV;
@@ -538,8 +537,8 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
538
537
}
539
538
540
539
// 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 ());
543
542
Type *ResultTy = TypeInfo.inferScalarType (BaseIV);
544
543
if (TruncI) {
545
544
Type *TruncTy = TruncI->getType ();
@@ -579,7 +578,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
579
578
// / if any of its users needs scalar values, by providing them scalar steps
580
579
// / built on the canonical scalar IV and update the original IV's users. This is
581
580
// / an optional optimization to reduce the needs of vector extracts.
582
- static void legalizeAndOptimizeInductions (VPlan &Plan, ScalarEvolution &SE ) {
581
+ static void legalizeAndOptimizeInductions (VPlan &Plan) {
583
582
SmallVector<VPRecipeBase *> ToRemove;
584
583
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
585
584
bool HasOnlyVectorVFs = !Plan.hasVF (ElementCount::getFixed (1 ));
@@ -597,7 +596,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
597
596
VPValue *StepV = PtrIV->getOperand (1 );
598
597
VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
599
598
Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr ,
600
- SE, nullptr , StartV, StepV, InsertPt);
599
+ nullptr , StartV, StepV, InsertPt);
601
600
602
601
auto *Recipe = new VPInstruction (VPInstruction::PtrAdd,
603
602
{PtrIV->getStartValue (), Steps},
@@ -621,7 +620,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
621
620
const InductionDescriptor &ID = WideIV->getInductionDescriptor ();
622
621
VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
623
622
Plan, ID.getKind (), ID.getInductionOpcode (),
624
- dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()), SE,
623
+ dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()),
625
624
WideIV->getTruncInst (), WideIV->getStartValue (), WideIV->getStepValue (),
626
625
InsertPt);
627
626
@@ -979,10 +978,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
979
978
}
980
979
981
980
// / Try to simplify the recipes in \p Plan.
982
- static void simplifyRecipes (VPlan &Plan, LLVMContext &Ctx ) {
981
+ static void simplifyRecipes (VPlan &Plan) {
983
982
ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT (
984
983
Plan.getEntry ());
985
- VPTypeAnalysis TypeInfo (Plan.getCanonicalIV ()->getScalarType (), Ctx);
984
+ Type *CanonicalIVType = Plan.getCanonicalIV ()->getScalarType ();
985
+ VPTypeAnalysis TypeInfo (CanonicalIVType, CanonicalIVType->getContext ());
986
986
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
987
987
for (VPRecipeBase &R : make_early_inc_range (*VPBB)) {
988
988
simplifyRecipe (R, TypeInfo);
@@ -991,8 +991,7 @@ static void simplifyRecipes(VPlan &Plan, LLVMContext &Ctx) {
991
991
}
992
992
993
993
void VPlanTransforms::truncateToMinimalBitwidths (
994
- VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs,
995
- LLVMContext &Ctx) {
994
+ VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs) {
996
995
#ifndef NDEBUG
997
996
// Count the processed recipes and cross check the count later with MinBWs
998
997
// size, to make sure all entries in MinBWs have been handled.
@@ -1003,7 +1002,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
1003
1002
// other uses have different types for their operands, making them invalidly
1004
1003
// typed.
1005
1004
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);
1007
1008
VPBasicBlock *PH = Plan.getEntry ();
1008
1009
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
1009
1010
vp_depth_first_deep (Plan.getVectorLoopRegion ()))) {
@@ -1123,12 +1124,12 @@ void VPlanTransforms::truncateToMinimalBitwidths(
1123
1124
" some entries in MinBWs haven't been processed" );
1124
1125
}
1125
1126
1126
- void VPlanTransforms::optimize (VPlan &Plan, ScalarEvolution &SE ) {
1127
+ void VPlanTransforms::optimize (VPlan &Plan) {
1127
1128
removeRedundantCanonicalIVs (Plan);
1128
1129
removeRedundantInductionCasts (Plan);
1129
1130
1130
- simplifyRecipes (Plan, SE. getContext () );
1131
- legalizeAndOptimizeInductions (Plan, SE );
1131
+ simplifyRecipes (Plan);
1132
+ legalizeAndOptimizeInductions (Plan);
1132
1133
removeDeadRecipes (Plan);
1133
1134
1134
1135
createAndOptimizeReplicateRegions (Plan);
0 commit comments