[PATCH] D150649: [FuncSpec] Enable specialization of literal constants.

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 22:24:49 PDT 2023


ChuanqiXu added a comment.

The code change looks trivial. So it looks good if the measured data (including compilation time and performance) don't have a regression.



================
Comment at: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:495-507
+    // Check the function entry frequency only once. We sink this code here to
+    // postpone BFI until we know for sure there are Specialization candidates,
+    // otherwise we are adding unnecessary overhead.
+    if (!HasCheckedEntryFreq) {
+      // Reject cold functions (for some definition of 'cold').
+      uint64_t EntryFreq = (GetBFI)(*F).getEntryFreq();
+      if (!ForceSpecialization && EntryFreq < MinEntryFreq)
----------------
Can't we move this out of the loop simply?


================
Comment at: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:527
         Score += getSpecializationBonus(A.Formal, A.Actual, KnownConstants);
+      Score /= SpecCost;
 
----------------
What's the reason that we use `/` instead of `-` here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150649/new/

https://reviews.llvm.org/D150649



More information about the llvm-commits mailing list