From 7c3c352d82131b960726560869945201410f9eb7 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sun, 5 Dec 2021 12:14:58 +0000 Subject: [PATCH] [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. --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlan.h | 15 +++++++++------ llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 5ca0adb4242c..050879144afd 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -8628,7 +8628,7 @@ VPWidenIntOrFpInductionRecipe *VPRecipeBuilder::tryToOptimizeInductionTruncate( Legal->getInductionVars().lookup(cast(I->getOperand(0))); VPValue *Start = Plan.getOrAddVPValue(II.getStartValue()); return new VPWidenIntOrFpInductionRecipe(cast(I->getOperand(0)), - Start, nullptr, I); + Start, I); } return nullptr; } diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 810dd5030f95..80a1784cf8c4 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -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. diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index ded5bc04beb5..7a936b77db47 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -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;