[llvm] [VPlan] Replace UnrollPart for VPScalarIVSteps with start index op (NFC) (PR #170906)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 18 13:34:36 PST 2026
================
@@ -3826,9 +3826,9 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe {
};
/// A recipe for handling phi nodes of integer and floating-point inductions,
-/// producing their scalar values.
-class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
- public VPUnrollPartAccessor<3> {
+/// producing their scalar values. Before unrolling the recipe has 3 operands:
+/// IV, step and VF. Unrolling adds an extra operand StartIndex.
----------------
ayalz wrote:
The VF operand is redundant after unrolling, and w/o unrolling (IC=1); it's only use is for constructing StartIdx during unrolling. Should it be dropped altogether, and have addStartIndexForScalarSteps() accesses VPlan's VF to compute StartIdx, or have the unroller (use and) replace the VF operand by StartIdx, potentially discarding it when not unrolling.
Trying to reason what operands are needed when:
- w/o unrolling (IC=1) and only first lane is used (required if VF is scalable): the recipe is **redundant**, collected by simplifyRecipe().
- w/o unrolling (IC=1) and all lanes are used (VF is fixed): the recipe needs only **IV and Step**, to generate IV, IV+Step, ..., IV+(Step*(VF-1)) where VF is taken from State.
- w/ unrolling, part 0 acts as "w/o unrolling" above.
- w/ unrolling, part >0 and only first lane is used: the recipe needs only **IV and StartIdx**, to generate their sum.
- w/ unrolling, part >0 and all lanes are used: the recipe needs **IV, Step and StartIdx**.
Perhaps subsequent replicate-by-VF will be better in cleaning this up.
https://github.com/llvm/llvm-project/pull/170906
More information about the llvm-commits
mailing list