Skip to content

Commit

Permalink
[CostModel] getUserCost for intrinsic throughput
Browse files Browse the repository at this point in the history
Last part of recommitting 'Unify Intrinsic Costs'
259eb61. This patch now uses
getUserCost from getInstructionThroughput.

Differential Revision: https://reviews.llvm.org/D80012
  • Loading branch information
sparker-arm committed May 26, 2020
1 parent 6f54318 commit bd9dce8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 8 additions & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Expand Up @@ -776,6 +776,14 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
TTI::TargetCostKind CostKind) {
auto *TargetTTI = static_cast<T *>(this);

// FIXME: We shouldn't have to special-case intrinsics here.
if (CostKind == TTI::TCK_RecipThroughput) {
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(U)) {
IntrinsicCostAttributes CostAttrs(*II);
return TargetTTI->getIntrinsicInstrCost(CostAttrs, CostKind);
}
}

// FIXME: Unlikely to be true for anything but CodeSize.
if (const auto *CB = dyn_cast<CallBase>(U)) {
const Function *F = CB->getCalledFunction();
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Expand Up @@ -260,7 +260,8 @@ int TargetTransformInfo::getUserCost(const User *U,
ArrayRef<const Value *> Operands,
enum TargetCostKind CostKind) const {
int Cost = TTIImpl->getUserCost(U, Operands, CostKind);
assert(Cost >= 0 && "TTI should not produce negative costs!");
assert((CostKind == TTI::TCK_RecipThroughput || Cost >= 0) &&
"TTI should not produce negative costs!");
return Cost;
}

Expand Down Expand Up @@ -1419,11 +1420,7 @@ int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const {
return TTIImpl->getShuffleCost(SK_PermuteTwoSrc, Ty, 0, nullptr);
}
case Instruction::Call:
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
IntrinsicCostAttributes CostAttrs(*II);
return getIntrinsicInstrCost(CostAttrs, CostKind);
}
return -1;
return getUserCost(I, CostKind);
default:
// We don't have any information on this instruction.
return -1;
Expand Down

0 comments on commit bd9dce8

Please sign in to comment.