Skip to content

Commit b826b60

Browse files
committed
[VPlan] Compute cost single-scalar calls in computeCost. (NFC)
Compute the cost of non-intrinsic, single-scalar calls directly in VPReplicateRecipe::computeCost. This starts moving call cost computations to VPlan, handling the simplest case first. (Cherry-picked from 79be94c)
1 parent bd19976 commit b826b60

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,24 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
29472947
// is scalarized or not. Therefore, we handle GEPs with the memory
29482948
// instruction cost.
29492949
return 0;
2950+
case Instruction::Call: {
2951+
if (!isSingleScalar()) {
2952+
// TODO: Handle remaining call costs here as well.
2953+
if (VF.isScalable())
2954+
return InstructionCost::getInvalid();
2955+
break;
2956+
}
2957+
2958+
auto *CalledFn =
2959+
cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
2960+
if (CalledFn->isIntrinsic())
2961+
break;
2962+
2963+
SmallVector<Type *, 4> Tys;
2964+
for (VPValue *ArgOp : drop_end(operands()))
2965+
Tys.push_back(Ctx.Types.inferScalarType(ArgOp));
2966+
return Ctx.TTI.getCallInstrCost(CalledFn, ResultTy, Tys, Ctx.CostKind);
2967+
}
29502968
case Instruction::Add:
29512969
case Instruction::Sub:
29522970
case Instruction::FAdd:

0 commit comments

Comments
 (0)