[llvm] [VPlan] Add VPValue for VF, use it for VPWidenIntOrFpInductionRecipe. (PR #95305)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 05:34:09 PDT 2024


================
@@ -814,8 +814,21 @@ 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));
+  Value *RuntimeVF = nullptr;
+  if (VF.getNumUsers()) {
+    RuntimeVF = createStepForVF(Builder, TripCountV->getType(), State.VF, 1);
+    VF.setUnderlyingValue(RuntimeVF);
+  }
+  if (RuntimeVF) {
+    VFxUF.setUnderlyingValue(
----------------
david-arm wrote:

Given RuntimeVF is only non-null if `VF.getNumUsers() != 0` wouldn't it be neater to simply fold this into the `if (VF.getNumUsers()) {` block? i.e.

```
  if (VF.getNumUsers()) {
    RuntimeVF = createStepForVF(Builder, TripCountV->getType(), State.VF, 1);
    VF.setUnderlyingValue(RuntimeVF);
    VFxUF.setUnderlyingValue(
        State.UF > 1 ? Builder.CreateMul(
                           VF.getLiveInIRValue(),
                           ConstantInt::get(TripCountV->getType(), State.UF))
                     : VF.getLiveInIRValue());
  } else {
    VFxUF.setUnderlyingValue(
        createStepForVF(Builder, TripCountV->getType(), State.VF, State.UF));
  }

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


More information about the llvm-commits mailing list