[llvm] aafed34 - [VPlan] Make createScalarIVSteps return VPScalarIVStepsRecipe (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 28 13:57:36 PDT 2024
Author: Florian Hahn
Date: 2024-04-28T21:56:55+01:00
New Revision: aafed3408e7269c42f974189198a47eb6dd2fc84
URL: https://github.com/llvm/llvm-project/commit/aafed3408e7269c42f974189198a47eb6dd2fc84
DIFF: https://github.com/llvm/llvm-project/commit/aafed3408e7269c42f974189198a47eb6dd2fc84.diff
LOG: [VPlan] Make createScalarIVSteps return VPScalarIVStepsRecipe (NFC).
This avoids the need for using getVPSingleValue/getDefiningRecipe at the
place the return value is used.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index d7bc128dcfe634..a7337f7aa94d4d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -506,13 +506,12 @@ static void removeDeadRecipes(VPlan &Plan) {
}
}
-static VPValue *createScalarIVSteps(VPlan &Plan,
- InductionDescriptor::InductionKind Kind,
- Instruction::BinaryOps InductionOpcode,
- FPMathOperator *FPBinOp,
- ScalarEvolution &SE, Instruction *TruncI,
- VPValue *StartV, VPValue *Step,
- VPBasicBlock::iterator IP) {
+static VPScalarIVStepsRecipe *
+createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
+ Instruction::BinaryOps InductionOpcode,
+ FPMathOperator *FPBinOp, ScalarEvolution &SE,
+ Instruction *TruncI, VPValue *StartV, VPValue *Step,
+ VPBasicBlock::iterator IP) {
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
VPSingleDefRecipe *BaseIV = CanonicalIV;
@@ -579,16 +578,13 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
VPValue *StartV =
Plan.getOrAddLiveIn(ConstantInt::get(ID.getStep()->getType(), 0));
VPValue *StepV = PtrIV->getOperand(1);
- VPRecipeBase *Steps =
- createScalarIVSteps(Plan, InductionDescriptor::IK_IntInduction,
- Instruction::Add, nullptr, SE, nullptr, StartV,
- StepV, InsertPt)
- ->getDefiningRecipe();
+ VPScalarIVStepsRecipe *Steps = createScalarIVSteps(
+ Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr,
+ SE, nullptr, StartV, StepV, InsertPt);
- auto *Recipe =
- new VPInstruction(VPInstruction::PtrAdd,
- {PtrIV->getStartValue(), Steps->getVPSingleValue()},
- PtrIV->getDebugLoc(), "next.gep");
+ auto *Recipe = new VPInstruction(VPInstruction::PtrAdd,
+ {PtrIV->getStartValue(), Steps},
+ PtrIV->getDebugLoc(), "next.gep");
Recipe->insertAfter(Steps);
PtrIV->replaceAllUsesWith(Recipe);
@@ -606,7 +602,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
continue;
const InductionDescriptor &ID = WideIV->getInductionDescriptor();
- VPValue *Steps = createScalarIVSteps(
+ VPScalarIVStepsRecipe *Steps = createScalarIVSteps(
Plan, ID.getKind(), ID.getInductionOpcode(),
dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp()), SE,
WideIV->getTruncInst(), WideIV->getStartValue(), WideIV->getStepValue(),
More information about the llvm-commits
mailing list