[llvm] [VPlan] Move call widening decision to VPlan. (NFCI) (PR #195518)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 03:49:59 PDT 2026


================
@@ -3436,34 +3440,10 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
   case Instruction::Call: {
     auto *CalledFn =
         cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
-
-    SmallVector<const VPValue *> ArgOps(drop_end(operands()));
-    SmallVector<Type *, 4> Tys;
-    for (const VPValue *ArgOp : ArgOps)
-      Tys.push_back(Ctx.Types.inferScalarType(ArgOp));
-
-    if (CalledFn->isIntrinsic() &&
-        VPCostContext::isFreeScalarIntrinsic(CalledFn->getIntrinsicID())) {
-      assert(getCostForIntrinsics(CalledFn->getIntrinsicID(), ArgOps, *this,
-                                  ElementCount::getFixed(1), Ctx) == 0 &&
-             "scalarizing intrinsic should be free");
-      return InstructionCost(0);
-    }
-
     Type *ResultTy = Ctx.Types.inferScalarType(this);
-    InstructionCost ScalarCallCost =
-        Ctx.TTI.getCallInstrCost(CalledFn, ResultTy, Tys, Ctx.CostKind);
-    if (isSingleScalar()) {
-      if (CalledFn->isIntrinsic())
-        ScalarCallCost = std::min(
-            ScalarCallCost,
-            getCostForIntrinsics(CalledFn->getIntrinsicID(), ArgOps, *this,
-                                 ElementCount::getFixed(1), Ctx));
-      return ScalarCallCost;
-    }
-
-    return ScalarCallCost * VF.getFixedValue() +
-           Ctx.getScalarizationOverhead(ResultTy, ArgOps, VF);
+    SmallVector<const VPValue *> ArgOps(drop_end(operands()));
+    return computeScalarCallCost(CalledFn, ResultTy, ArgOps, isSingleScalar(),
+                                 VF, Ctx);
----------------
artagnon wrote:

```suggestion
    ArrayRef<const VPValue *> ArgOps(drop_end(operands()));
    return computeScalarCallCost(CalledFn, ResultTy, ArgOps, isSingleScalar(),
                                 VF, Ctx);
```

Not sure if the ArrayRef construction is necessary?

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


More information about the llvm-commits mailing list