Skip to content

Commit 7c3c352

Browse files
committed
[VPlan] Separate ctors for VPWidenIntOrFpInduction. (NFC)
VPWidenIntOrFpInductionRecipes can either be constructed with a PHI and an optional cast or a PHI and a trunc instruction. Reflect this in 2 separate constructors. This also simplifies a follow-up change.
1 parent 75b622a commit 7c3c352

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8628,7 +8628,7 @@ VPWidenIntOrFpInductionRecipe *VPRecipeBuilder::tryToOptimizeInductionTruncate(
86288628
Legal->getInductionVars().lookup(cast<PHINode>(I->getOperand(0)));
86298629
VPValue *Start = Plan.getOrAddVPValue(II.getStartValue());
86308630
return new VPWidenIntOrFpInductionRecipe(cast<PHINode>(I->getOperand(0)),
8631-
Start, nullptr, I);
8631+
Start, I);
86328632
}
86338633
return nullptr;
86348634
}

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,17 +1007,20 @@ class VPWidenIntOrFpInductionRecipe : public VPRecipeBase {
10071007
PHINode *IV;
10081008

10091009
public:
1010-
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, Instruction *Cast,
1011-
TruncInst *Trunc = nullptr)
1010+
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start,
1011+
Instruction *Cast = nullptr)
10121012
: VPRecipeBase(VPWidenIntOrFpInductionSC, {Start}), IV(IV) {
1013-
if (Trunc)
1014-
new VPValue(Trunc, this);
1015-
else
1016-
new VPValue(IV, this);
1013+
new VPValue(IV, this);
10171014

10181015
if (Cast)
10191016
new VPValue(Cast, this);
10201017
}
1018+
1019+
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, TruncInst *Trunc)
1020+
: VPRecipeBase(VPWidenIntOrFpInductionSC, {Start}), IV(IV) {
1021+
new VPValue(Trunc, this);
1022+
}
1023+
10211024
~VPWidenIntOrFpInductionRecipe() override = default;
10221025

10231026
/// Method to support type inquiry through isa, cast, and dyn_cast.

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
4848
if (II.getKind() == InductionDescriptor::IK_IntInduction ||
4949
II.getKind() == InductionDescriptor::IK_FpInduction) {
5050
VPValue *Start = Plan->getOrAddVPValue(II.getStartValue());
51-
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, nullptr);
51+
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start);
5252
} else {
5353
Plan->addVPValue(Phi, VPPhi);
5454
continue;

0 commit comments

Comments
 (0)