[llvm] [VPlan] Add VPInstruction::StepVector and use it in VPWidenIntOrFpInductionRecipe (PR #129508)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon May 5 06:36:28 PDT 2025


================
@@ -1844,23 +1854,30 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
 class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
   TruncInst *Trunc;
 
+  bool isUnrolled() const { return getNumOperands() == 6; }
+
 public:
   VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
-                                VPValue *VF, const InductionDescriptor &IndDesc,
-                                DebugLoc DL)
+                                VPValue *VF, VPValue *StepVector,
+                                const InductionDescriptor &IndDesc, DebugLoc DL)
       : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start,
                                Step, IndDesc, DL),
         Trunc(nullptr) {
     addOperand(VF);
+    // Dummy StepVector replaced in convertToConcreteRecipes
+    addOperand(StepVector);
   }
 
   VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
-                                VPValue *VF, const InductionDescriptor &IndDesc,
+                                VPValue *VF, VPValue *StepVector,
+                                const InductionDescriptor &IndDesc,
                                 TruncInst *Trunc, DebugLoc DL)
       : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start,
                                Step, IndDesc, DL),
         Trunc(Trunc) {
     addOperand(VF);
+    // Dummy StepVector replaced in convertToConcreteRecipes
----------------
fhahn wrote:

Ah yes, don't think there's a good way to retrieve it here; how about introducing stepvector just before unrolling, similarly to `materializeBroadcasts`? Would that work without the need of adding a dummy operand up-front?

https://github.com/llvm/llvm-project/pull/129508


More information about the llvm-commits mailing list