[llvm] [FuncSpec] Update function specialization to handle phi-chains (PR #71442)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 02:29:30 PST 2023


================
@@ -809,20 +870,40 @@ bool FunctionSpecializer::findSpecializations(Function *F, unsigned FuncSize,
       auto IsProfitable = [](Bonus &B, unsigned Score, unsigned FuncSize,
                              unsigned FuncGrowth) -> bool {
         // No check required.
-        if (ForceSpecialization)
+        if (ForceSpecialization) {
+          LLVM_DEBUG(dbgs() << "Force is on\n");
           return true;
+        }
         // Minimum inlining bonus.
-        if (Score > MinInliningBonus * FuncSize / 100)
+        if (Score > MinInliningBonus * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Min inliningbous: Score = " << Score
+                     << " > " << MinInliningBonus * FuncSize / 100 << "\n");
           return true;
+        }
         // Minimum codesize savings.
-        if (B.CodeSize < MinCodeSizeSavings * FuncSize / 100)
+        if (B.CodeSize < MinCodeSizeSavings * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Min CodeSize Saving: CodeSize = "
----------------
labrinea wrote:

I would rephrase as
"FnSpecialization: Insufficient codesize savings (" << B.CodeSize << " < " << MinCodeSizeSavings * FuncSize / 100 << ")\n");

https://github.com/llvm/llvm-project/pull/71442


More information about the llvm-commits mailing list