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/Transforms/Utils/SimplifyCFG.cpp | |
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/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 76f09c0..21f8d54 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -381,7 +381,7 @@ static InstructionCost computeSpeculationCost(const User *I, assert((!isa<Instruction>(I) || isSafeToSpeculativelyExecute(cast<Instruction>(I))) && "Instruction is not safe to speculatively execute!"); - return TTI.getUserCost(I, TargetTransformInfo::TCK_SizeAndLatency); + return TTI.getInstructionCost(I, TargetTransformInfo::TCK_SizeAndLatency); } /// If we have a merge point of an "if condition" as accepted above, @@ -3626,8 +3626,8 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU, // Account for the cost of duplicating this instruction into each // predecessor. Ignore free instructions. - if (!TTI || - TTI->getUserCost(&I, CostKind) != TargetTransformInfo::TCC_Free) { + if (!TTI || TTI->getInstructionCost(&I, CostKind) != + TargetTransformInfo::TCC_Free) { NumBonusInsts += PredCount; // Early exits once we reach the limit. @@ -3799,7 +3799,8 @@ static bool mergeConditionalStoreToAddress( return false; // Not in white-list - not worthwhile folding. // And finally, if this is a non-free instruction that we are okay // speculating, ensure that we consider the speculation budget. - Cost += TTI.getUserCost(&I, TargetTransformInfo::TCK_SizeAndLatency); + Cost += + TTI.getInstructionCost(&I, TargetTransformInfo::TCK_SizeAndLatency); if (Cost > Budget) return false; // Eagerly refuse to fold as soon as we're out of budget. } |