Skip to content

Commit aafed34

Browse files
committed
[VPlan] Make createScalarIVSteps return VPScalarIVStepsRecipe (NFC).
This avoids the need for using getVPSingleValue/getDefiningRecipe at the place the return value is used.
1 parent fac349a commit aafed34

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,12 @@ static void removeDeadRecipes(VPlan &Plan) {
506506
}
507507
}
508508

509-
static VPValue *createScalarIVSteps(VPlan &Plan,
510-
InductionDescriptor::InductionKind Kind,
511-
Instruction::BinaryOps InductionOpcode,
512-
FPMathOperator *FPBinOp,
513-
ScalarEvolution &SE, Instruction *TruncI,
514-
VPValue *StartV, VPValue *Step,
515-
VPBasicBlock::iterator IP) {
509+
static VPScalarIVStepsRecipe *
510+
createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
511+
Instruction::BinaryOps InductionOpcode,
512+
FPMathOperator *FPBinOp, ScalarEvolution &SE,
513+
Instruction *TruncI, VPValue *StartV, VPValue *Step,
514+
VPBasicBlock::iterator IP) {
516515
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
517516
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
518517
VPSingleDefRecipe *BaseIV = CanonicalIV;
@@ -579,16 +578,13 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
579578
VPValue *StartV =
580579
Plan.getOrAddLiveIn(ConstantInt::get(ID.getStep()->getType(), 0));
581580
VPValue *StepV = PtrIV->getOperand(1);
582-
VPRecipeBase *Steps =
583-
createScalarIVSteps(Plan, InductionDescriptor::IK_IntInduction,
584-
Instruction::Add, nullptr, SE, nullptr, StartV,
585-
StepV, InsertPt)
586-
->getDefiningRecipe();
581+
VPScalarIVStepsRecipe *Steps = createScalarIVSteps(
582+
Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr,
583+
SE, nullptr, StartV, StepV, InsertPt);
587584

588-
auto *Recipe =
589-
new VPInstruction(VPInstruction::PtrAdd,
590-
{PtrIV->getStartValue(), Steps->getVPSingleValue()},
591-
PtrIV->getDebugLoc(), "next.gep");
585+
auto *Recipe = new VPInstruction(VPInstruction::PtrAdd,
586+
{PtrIV->getStartValue(), Steps},
587+
PtrIV->getDebugLoc(), "next.gep");
592588

593589
Recipe->insertAfter(Steps);
594590
PtrIV->replaceAllUsesWith(Recipe);
@@ -606,7 +602,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
606602
continue;
607603

608604
const InductionDescriptor &ID = WideIV->getInductionDescriptor();
609-
VPValue *Steps = createScalarIVSteps(
605+
VPScalarIVStepsRecipe *Steps = createScalarIVSteps(
610606
Plan, ID.getKind(), ID.getInductionOpcode(),
611607
dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp()), SE,
612608
WideIV->getTruncInst(), WideIV->getStartValue(), WideIV->getStepValue(),

0 commit comments

Comments
 (0)