[llvm] [FuncSpec] Only compute Latency bonus when necessary (PR #113159)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 08:27:28 PDT 2024
================
@@ -154,37 +154,55 @@ static Constant *findConstantFor(Value *V, ConstMap &KnownConstants) {
return KnownConstants.lookup(V);
}
-Bonus InstCostVisitor::getBonusFromPendingPHIs() {
- Bonus B;
+Cost InstCostVisitor::getCodeSizeBonusFromPendingPHIs() {
+ Cost CodeSize;
while (!PendingPHIs.empty()) {
Instruction *Phi = PendingPHIs.pop_back_val();
// The pending PHIs could have been proven dead by now.
if (isBlockExecutable(Phi->getParent()))
- B += getUserBonus(Phi);
+ CodeSize += getUserCodeSizeBonus(Phi);
}
- return B;
+ return CodeSize;
}
-/// Compute a bonus for replacing argument \p A with constant \p C.
-Bonus InstCostVisitor::getSpecializationBonus(Argument *A, Constant *C) {
+/// Compute the codesize savings for replacing argument \p A with constant \p C.
+Cost InstCostVisitor::getCodeSizeBonus(Argument *A, Constant *C) {
LLVM_DEBUG(dbgs() << "FnSpecialization: Analysing bonus for constant: "
<< C->getNameOrAsOperand() << "\n");
- Bonus B;
+ Cost CodeSize;
for (auto *U : A->users())
if (auto *UI = dyn_cast<Instruction>(U))
if (isBlockExecutable(UI->getParent()))
- B += getUserBonus(UI, A, C);
+ CodeSize += getUserCodeSizeBonus(UI, A, C);
LLVM_DEBUG(dbgs() << "FnSpecialization: Accumulated bonus {CodeSize = "
- << B.CodeSize << ", Latency = " << B.Latency
- << "} for argument " << *A << "\n");
- return B;
+ << CodeSize << "} for argument " << *A << "\n");
+ return CodeSize;
+}
+
+Cost InstCostVisitor::getLatencyBonus() {
----------------
hazzlim wrote:
Good point - I have added an explanatory comment.
https://github.com/llvm/llvm-project/pull/113159
More information about the llvm-commits
mailing list