[llvm] [VPlan] Add VPValue for VF, use it for VPWidenIntOrFpInductionRecipe. (PR #95305)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 03:58:10 PDT 2024
================
@@ -934,8 +934,19 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
IRBuilder<> Builder(State.CFG.PrevBB->getTerminator());
// FIXME: Model VF * UF computation completely in VPlan.
- VFxUF.setUnderlyingValue(
- createStepForVF(Builder, TripCountV->getType(), State.VF, State.UF));
+ if (VF.getNumUsers()) {
+ Value *RuntimeVF =
+ createStepForVF(Builder, TripCountV->getType(), State.VF, 1);
+ VF.setUnderlyingValue(RuntimeVF);
+ VFxUF.setUnderlyingValue(
+ State.UF > 1
+ ? Builder.CreateMul(
+ RuntimeVF, ConstantInt::get(TripCountV->getType(), State.UF))
+ : RuntimeVF);
+ } else {
+ VFxUF.setUnderlyingValue(
----------------
fhahn wrote:
Yes, `VFxUF` is used to increment the canonical induction, which is present in almost all cases, but could also be done only if users exist.
> ... Code for VF is only generated if there are users of VF, to avoid unnecessary test changes.
> Code for VF must be generated regardless of direct users, issues is its position and possible repetition?
There are cases where VF separately isn't used, only as part of `VFxUF`. If only VFxUF is used, the constant multiply of VF * UF is folded, hence always generating VF separately would lead to additional test changes. Some alternatives are mentioned in my latest comment above.
https://github.com/llvm/llvm-project/pull/95305
More information about the llvm-commits
mailing list