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

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 04:33:38 PST 2023


================
@@ -809,20 +908,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() << "FnSpecialization: Force is on\n");
           return true;
+        }
         // Minimum inlining bonus.
-        if (Score > MinInliningBonus * FuncSize / 100)
+        if (Score > MinInliningBonus * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Sufficient inlining bonus( " << 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: Insufficinet CodeSize Saving("
+                     << B.CodeSize << " > "
+                     << MinCodeSizeSavings * FuncSize / 100 << ")\n");
           return false;
+        }
         // Minimum latency savings.
-        if (B.Latency < MinLatencySavings * FuncSize / 100)
+        if (B.Latency < MinLatencySavings * FuncSize / 100) {
+          LLVM_DEBUG(dbgs()
+                     << "FnSpecialization: Insufficinet Latency Saving("
+                     << B.Latency << " > " << MinLatencySavings * FuncSize / 100
----------------
labrinea wrote:

use less than here, not greater than

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


More information about the llvm-commits mailing list