[VPlan] Separate ctors for VPWidenIntOrFpInduction. (NFC)
authorFlorian Hahn <flo@fhahn.com>
Sun, 5 Dec 2021 12:14:58 +0000 (12:14 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sun, 5 Dec 2021 12:15:18 +0000 (12:15 +0000)
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
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

index 5ca0adb..0508791 100644 (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;
 }
index 810dd50..80a1784 100644 (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.
index ded5bc0..7a936b7 100644 (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;