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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 7 07:06:04 PDT 2025


================
@@ -1223,6 +1223,15 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
     WideIV->setStartValue(NewStart);
     auto *NewStep = Plan.getOrAddLiveIn(ConstantInt::get(NewIVTy, 1));
     WideIV->setStepValue(NewStep);
+    // TODO: Remove once VPWidenIntOrFpInductionRecipe is fully expanded.
+    auto *OldStepVector = cast<VPInstructionWithType>(
+        WideIV->getStepVector()->getDefiningRecipe());
+    assert(OldStepVector->getOpcode() == VPInstruction::StepVector);
+    auto *NewStepVector = new VPInstructionWithType(
+        VPInstruction::StepVector, {}, NewIVTy, OldStepVector->getDebugLoc());
+    NewStepVector->insertAfter(WideIV->getStepVector()->getDefiningRecipe());
+    WideIV->setStepVector(NewStepVector);
----------------
lukel97 wrote:

Good idea, done now

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


More information about the llvm-commits mailing list