[llvm] [CGData][GMF] Skip No Params (PR #116548)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 11:24:18 PST 2024
================
@@ -159,22 +169,33 @@ static bool isProfitable(
unsigned InstCount = SFS[0]->InstCount;
if (InstCount < GlobalMergingMinInstrs)
return false;
+ double Benefit =
+ InstCount * (StableFunctionCount - 1) * GlobalMergingInstOverhead;
- unsigned ParamCount = SFS[0]->IndexOperandHashMap->size();
- if (ParamCount > GlobalMergingMaxParams)
- return false;
-
- unsigned Benefit = InstCount * (StableFunctionCount - 1);
- unsigned Cost =
- (GlobalMergingParamOverhead * ParamCount + GlobalMergingCallOverhead) *
- StableFunctionCount +
- GlobalMergingExtraThreshold;
+ 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;
----------------
ellishg wrote:
As I understand if, if a group of mergable functions have too many params, we can't merge any of them. Could we eliminate functions until the params are small enough and only merge a subset of the group?
https://github.com/llvm/llvm-project/pull/116548
More information about the llvm-commits
mailing list