[llvm] [CGData] Global Merge Functions (PR #112671)

Zhaoxuan Jiang via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 17 01:25:40 PST 2024


================
@@ -117,7 +149,38 @@ static void removeIdenticalIndexPair(
       SF->IndexOperandHashMap->erase(Pair);
 }
 
-void StableFunctionMap::finalize() {
+static bool isProfitable(
+    const SmallVector<std::unique_ptr<StableFunctionMap::StableFunctionEntry>>
+        &SFS) {
+  unsigned StableFunctionCount = SFS.size();
+  if (StableFunctionCount < GlobalMergingMinMerges)
+    return false;
+
+  unsigned InstCount = SFS[0]->InstCount;
+  if (InstCount < GlobalMergingMinInstrs)
+    return false;
+
+  unsigned ParamCount = SFS[0]->IndexOperandHashMap->size();
----------------
nocchijiang wrote:

The number of unique values of `SFS[0]->IndexOperandHashMap` is more accurate, if a given constant is used multiple times in the stable function.

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


More information about the llvm-commits mailing list