[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.
This commit is contained in:
Florian Hahn 2021-12-05 12:14:58 +00:00
parent 75b622a795
commit 7c3c352d82
No known key found for this signature in database
GPG Key ID: EEF712BB5E80EBBA
3 changed files with 11 additions and 8 deletions

View File

@ -8628,7 +8628,7 @@ VPWidenIntOrFpInductionRecipe *VPRecipeBuilder::tryToOptimizeInductionTruncate(
Legal->getInductionVars().lookup(cast<PHINode>(I->getOperand(0)));
VPValue *Start = Plan.getOrAddVPValue(II.getStartValue());
return new VPWidenIntOrFpInductionRecipe(cast<PHINode>(I->getOperand(0)),
Start, nullptr, I);
Start, I);
}
return nullptr;
}

View File

@ -1007,17 +1007,20 @@ class VPWidenIntOrFpInductionRecipe : public VPRecipeBase {
PHINode *IV;
public:
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, Instruction *Cast,
TruncInst *Trunc = nullptr)
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start,
Instruction *Cast = nullptr)
: VPRecipeBase(VPWidenIntOrFpInductionSC, {Start}), IV(IV) {
if (Trunc)
new VPValue(Trunc, this);
else
new VPValue(IV, this);
new VPValue(IV, this);
if (Cast)
new VPValue(Cast, this);
}
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, TruncInst *Trunc)
: VPRecipeBase(VPWidenIntOrFpInductionSC, {Start}), IV(IV) {
new VPValue(Trunc, this);
}
~VPWidenIntOrFpInductionRecipe() override = default;
/// Method to support type inquiry through isa, cast, and dyn_cast.

View File

@ -48,7 +48,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
if (II.getKind() == InductionDescriptor::IK_IntInduction ||
II.getKind() == InductionDescriptor::IK_FpInduction) {
VPValue *Start = Plan->getOrAddVPValue(II.getStartValue());
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, nullptr);
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start);
} else {
Plan->addVPValue(Phi, VPPhi);
continue;