[llvm] [VPlan] Add VPInstruction::StepVector and use it in VPWidenIntOrFpInductionRecipe (PR #129508)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 06:49:20 PDT 2025
================
@@ -2586,6 +2595,29 @@ void VPlanTransforms::handleUncountableEarlyExit(
LatchExitingBranch->eraseFromParent();
}
+void VPlanTransforms::materializeStepVectors(VPlan &Plan) {
+ for (auto &Phi : Plan.getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
+ auto *IVR = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
+ if (!IVR)
+ continue;
+
+ // Infer an up-to-date type since
+ // optimizeVectorInductionWidthForTCAndVFUF may have truncated the start
+ // and step values.
+ Type *Ty = IVR->getPHINode()->getType();
+ if (TruncInst *Trunc = IVR->getTruncInst())
+ Ty = Trunc->getType();
+ if (Ty->isFloatingPointTy())
+ Ty = IntegerType::get(Ty->getContext(), Ty->getScalarSizeInBits());
+
+ VPBuilder Builder(Plan.getVectorPreheader());
+ VPInstruction *StepVector = Builder.createNaryOp(
+ VPInstruction::StepVector, {}, Ty, {}, IVR->getDebugLoc());
+ assert(IVR->getNumOperands() == 3);
----------------
fhahn wrote:
```suggestion
assert(IVR->getNumOperands() == 3 && "can only add step vector before unrolling");
```
https://github.com/llvm/llvm-project/pull/129508
More information about the llvm-commits
mailing list