[llvm] [CGData][GMF] Skip No Params (PR #116548)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 09:28:43 PST 2024
================
@@ -159,22 +169,28 @@ static bool isProfitable(
unsigned InstCount = SFS[0]->InstCount;
if (InstCount < GlobalMergingMinInstrs)
return false;
-
- unsigned ParamCount = SFS[0]->IndexOperandHashMap->size();
- if (ParamCount > GlobalMergingMaxParams)
- return false;
-
- unsigned Benefit = InstCount * (StableFunctionCount - 1);
- unsigned Cost =
- (GlobalMergingParamOverhead * ParamCount + GlobalMergingCallOverhead) *
- StableFunctionCount +
- GlobalMergingExtraThreshold;
+ double Benefit =
+ InstCount * (StableFunctionCount - 1) * GlobalMergingInstOverhead;
+
+ double Cost = 0.0;
+ SmallSet<stable_hash, 8> UniqueHashVals;
+ for (auto &SF : SFS) {
+ UniqueHashVals.clear();
+ for (auto &[IndexPair, Hash] : *SF->IndexOperandHashMap)
+ UniqueHashVals.insert(Hash);
+ unsigned ParamCount = UniqueHashVals.size();
+ if (ParamCount > GlobalMergingMaxParams)
+ return false;
+ if (GlobalMergingSkipNoParams && ParamCount == 0)
----------------
ellishg wrote:
I was also thinking this. To be explicit, does ICF get the same size win as when `GlobalMergingMaxParams = 0`? If so I think it would be worth saying this in the flag description to help users understand the pass a bit better.
https://github.com/llvm/llvm-project/pull/116548
More information about the llvm-commits
mailing list