@@ -523,9 +523,8 @@ static void removeDeadRecipes(VPlan &Plan) {
523
523
static VPScalarIVStepsRecipe *
524
524
createScalarIVSteps (VPlan &Plan, InductionDescriptor::InductionKind Kind,
525
525
Instruction::BinaryOps InductionOpcode,
526
- FPMathOperator *FPBinOp, ScalarEvolution &SE,
527
- Instruction *TruncI, VPValue *StartV, VPValue *Step,
528
- VPBasicBlock::iterator IP) {
526
+ FPMathOperator *FPBinOp, Instruction *TruncI,
527
+ VPValue *StartV, VPValue *Step, VPBasicBlock::iterator IP) {
529
528
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
530
529
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV ();
531
530
VPSingleDefRecipe *BaseIV = CanonicalIV;
@@ -535,8 +534,8 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
535
534
}
536
535
537
536
// Truncate base induction if needed.
538
- VPTypeAnalysis TypeInfo (Plan. getCanonicalIV () ->getScalarType (),
539
- SE. getContext ());
537
+ Type *CanonicalIVType = CanonicalIV ->getScalarType ();
538
+ VPTypeAnalysis TypeInfo (CanonicalIVType, CanonicalIVType-> getContext ());
540
539
Type *ResultTy = TypeInfo.inferScalarType (BaseIV);
541
540
if (TruncI) {
542
541
Type *TruncTy = TruncI->getType ();
@@ -576,7 +575,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
576
575
// / if any of its users needs scalar values, by providing them scalar steps
577
576
// / built on the canonical scalar IV and update the original IV's users. This is
578
577
// / an optional optimization to reduce the needs of vector extracts.
579
- static void legalizeAndOptimizeInductions (VPlan &Plan, ScalarEvolution &SE ) {
578
+ static void legalizeAndOptimizeInductions (VPlan &Plan) {
580
579
SmallVector<VPRecipeBase *> ToRemove;
581
580
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
582
581
bool HasOnlyVectorVFs = !Plan.hasVF (ElementCount::getFixed (1 ));
@@ -594,7 +593,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
594
593
VPValue *StepV = PtrIV->getOperand (1 );
595
594
VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
596
595
Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr ,
597
- SE, nullptr , StartV, StepV, InsertPt);
596
+ nullptr , StartV, StepV, InsertPt);
598
597
599
598
auto *Recipe = new VPInstruction (VPInstruction::PtrAdd,
600
599
{PtrIV->getStartValue (), Steps},
@@ -618,7 +617,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
618
617
const InductionDescriptor &ID = WideIV->getInductionDescriptor ();
619
618
VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
620
619
Plan, ID.getKind (), ID.getInductionOpcode (),
621
- dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()), SE,
620
+ dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()),
622
621
WideIV->getTruncInst (), WideIV->getStartValue (), WideIV->getStepValue (),
623
622
InsertPt);
624
623
@@ -976,10 +975,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
976
975
}
977
976
978
977
// / Try to simplify the recipes in \p Plan.
979
- static void simplifyRecipes (VPlan &Plan, LLVMContext &Ctx ) {
978
+ static void simplifyRecipes (VPlan &Plan) {
980
979
ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT (
981
980
Plan.getEntry ());
982
- VPTypeAnalysis TypeInfo (Plan.getCanonicalIV ()->getScalarType (), Ctx);
981
+ Type *CanonicalIVType = Plan.getCanonicalIV ()->getScalarType ();
982
+ VPTypeAnalysis TypeInfo (CanonicalIVType, CanonicalIVType->getContext ());
983
983
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
984
984
for (VPRecipeBase &R : make_early_inc_range (*VPBB)) {
985
985
simplifyRecipe (R, TypeInfo);
@@ -988,8 +988,7 @@ static void simplifyRecipes(VPlan &Plan, LLVMContext &Ctx) {
988
988
}
989
989
990
990
void VPlanTransforms::truncateToMinimalBitwidths (
991
- VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs,
992
- LLVMContext &Ctx) {
991
+ VPlan &Plan, const MapVector<Instruction *, uint64_t > &MinBWs) {
993
992
#ifndef NDEBUG
994
993
// Count the processed recipes and cross check the count later with MinBWs
995
994
// size, to make sure all entries in MinBWs have been handled.
@@ -1000,7 +999,9 @@ void VPlanTransforms::truncateToMinimalBitwidths(
1000
999
// other uses have different types for their operands, making them invalidly
1001
1000
// typed.
1002
1001
DenseMap<VPValue *, VPWidenCastRecipe *> ProcessedTruncs;
1003
- VPTypeAnalysis TypeInfo (Plan.getCanonicalIV ()->getScalarType (), Ctx);
1002
+ Type *CanonicalIVType = Plan.getCanonicalIV ()->getScalarType ();
1003
+ LLVMContext &Ctx = CanonicalIVType->getContext ();
1004
+ VPTypeAnalysis TypeInfo (CanonicalIVType, Ctx);
1004
1005
VPBasicBlock *PH = Plan.getEntry ();
1005
1006
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
1006
1007
vp_depth_first_deep (Plan.getVectorLoopRegion ()))) {
@@ -1119,12 +1120,12 @@ void VPlanTransforms::truncateToMinimalBitwidths(
1119
1120
" some entries in MinBWs haven't been processed" );
1120
1121
}
1121
1122
1122
- void VPlanTransforms::optimize (VPlan &Plan, ScalarEvolution &SE ) {
1123
+ void VPlanTransforms::optimize (VPlan &Plan) {
1123
1124
removeRedundantCanonicalIVs (Plan);
1124
1125
removeRedundantInductionCasts (Plan);
1125
1126
1126
- simplifyRecipes (Plan, SE. getContext () );
1127
- legalizeAndOptimizeInductions (Plan, SE );
1127
+ simplifyRecipes (Plan);
1128
+ legalizeAndOptimizeInductions (Plan);
1128
1129
removeDeadRecipes (Plan);
1129
1130
1130
1131
createAndOptimizeReplicateRegions (Plan);
0 commit comments