Skip to content

Commit 79be94c

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.
1 parent d8208b0 commit 79be94c

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
@@ -2974,6 +2974,24 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
29742974
// is scalarized or not. Therefore, we handle GEPs with the memory
29752975
// instruction cost.
29762976
return 0;
2977+
case Instruction::Call: {
2978+
if (!isSingleScalar()) {
2979+
// TODO: Handle remaining call costs here as well.
2980+
if (VF.isScalable())
2981+
return InstructionCost::getInvalid();
2982+
break;
2983+
}
2984+
2985+
auto *CalledFn =
2986+
cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
2987+
if (CalledFn->isIntrinsic())
2988+
break;
2989+
2990+
SmallVector<Type *, 4> Tys;
2991+
for (VPValue *ArgOp : drop_end(operands()))
2992+
Tys.push_back(Ctx.Types.inferScalarType(ArgOp));
2993+
return Ctx.TTI.getCallInstrCost(CalledFn, ResultTy, Tys, Ctx.CostKind);
2994+
}
29772995
case Instruction::Add:
29782996
case Instruction::Sub:
29792997
case Instruction::FAdd:

0 commit comments

Comments
 (0)