diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2022-08-18 11:55:23 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2022-08-18 11:55:23 +0100 |
commit | fdec50182d85ec0b8518af3baae37ae28b102f1c (patch) | |
tree | f620576762fe4f39bf29b33faa01c4f7938b2d2f /llvm/lib/Analysis | |
parent | 27cbfa7cc8cdab121842adf4dd31f6811f523928 (diff) | |
download | llvm-fdec50182d85ec0b8518af3baae37ae28b102f1c.zip llvm-fdec50182d85ec0b8518af3baae37ae28b102f1c.tar.gz llvm-fdec50182d85ec0b8518af3baae37ae28b102f1c.tar.bz2 |
[CostModel] Replace getUserCost with getInstructionCost
* Replace getUserCost with getInstructionCost, covering all cost kinds.
* Remove getInstructionLatency, it's not implemented by any backends, and we should fold the functionality into getUserCost (now getInstructionCost) to make it easier for targets to handle the cost kinds with their existing cost callbacks.
Original Patch by @samparker (Sam Parker)
Differential Revision: https://reviews.llvm.org/D79483
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/CodeMetrics.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Analysis/TargetTransformInfo.cpp | 13 |
3 files changed, 11 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp index ded842b..2637e2f 100644 --- a/llvm/lib/Analysis/CodeMetrics.cpp +++ b/llvm/lib/Analysis/CodeMetrics.cpp @@ -177,7 +177,7 @@ void CodeMetrics::analyzeBasicBlock( if (InvI->cannotDuplicate()) notDuplicatable = true; - NumInsts += TTI.getUserCost(&I, TargetTransformInfo::TCK_CodeSize); + NumInsts += TTI.getInstructionCost(&I, TargetTransformInfo::TCK_CodeSize); } if (isa<ReturnInst>(BB->getTerminator())) diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 0992a4f..86e0b4b 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1361,8 +1361,8 @@ bool CallAnalyzer::isGEPFree(GetElementPtrInst &GEP) { Operands.push_back(SimpleOp); else Operands.push_back(Op); - return TTI.getUserCost(&GEP, Operands, - TargetTransformInfo::TCK_SizeAndLatency) == + return TTI.getInstructionCost(&GEP, Operands, + TargetTransformInfo::TCK_SizeAndLatency) == TargetTransformInfo::TCC_Free; } @@ -1639,7 +1639,7 @@ bool CallAnalyzer::visitPtrToInt(PtrToIntInst &I) { if (auto *SROAArg = getSROAArgForValueOrNull(I.getOperand(0))) SROAArgValues[&I] = SROAArg; - return TTI.getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == + return TTI.getInstructionCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == TargetTransformInfo::TCC_Free; } @@ -1662,7 +1662,7 @@ bool CallAnalyzer::visitIntToPtr(IntToPtrInst &I) { if (auto *SROAArg = getSROAArgForValueOrNull(Op)) SROAArgValues[&I] = SROAArg; - return TTI.getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == + return TTI.getInstructionCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == TargetTransformInfo::TCC_Free; } @@ -1692,7 +1692,7 @@ bool CallAnalyzer::visitCastInst(CastInst &I) { break; } - return TTI.getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == + return TTI.getInstructionCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == TargetTransformInfo::TCC_Free; } @@ -2390,7 +2390,7 @@ bool CallAnalyzer::visitUnreachableInst(UnreachableInst &I) { bool CallAnalyzer::visitInstruction(Instruction &I) { // Some instructions are free. All of the free intrinsics can also be // handled by SROA, etc. - if (TTI.getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == + if (TTI.getInstructionCost(&I, TargetTransformInfo::TCK_SizeAndLatency) == TargetTransformInfo::TCC_Free) return true; diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index 382ed27..001075d 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -221,10 +221,10 @@ unsigned TargetTransformInfo::getEstimatedNumberOfCaseClusters( } InstructionCost -TargetTransformInfo::getUserCost(const User *U, - ArrayRef<const Value *> Operands, - enum TargetCostKind CostKind) const { - InstructionCost Cost = TTIImpl->getUserCost(U, Operands, CostKind); +TargetTransformInfo::getInstructionCost(const User *U, + ArrayRef<const Value *> Operands, + enum TargetCostKind CostKind) const { + InstructionCost Cost = TTIImpl->getInstructionCost(U, Operands, CostKind); assert((CostKind == TTI::TCK_RecipThroughput || Cost >= 0) && "TTI should not produce negative costs!"); return Cost; @@ -1149,11 +1149,6 @@ bool TargetTransformInfo::hasActiveVectorLength(unsigned Opcode, Type *DataType, return TTIImpl->hasActiveVectorLength(Opcode, DataType, Alignment); } -InstructionCost -TargetTransformInfo::getInstructionLatency(const Instruction *I) const { - return TTIImpl->getInstructionLatency(I); -} - TargetTransformInfo::Concept::~Concept() = default; TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {} |