[PATCH] D119880: [FuncSpec] Support function specialization across multiple arguments.

Alexandros Lamprineas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 10:32:41 PDT 2022


labrinea added a comment.

That's true; the new formula is not in the current revision. The idea is to keep a sublinear number of specializations when the number of candidates grows enormously (not expected to happen in real life code). So imagine we had 1000 candidates n/2 would be 500 whereas `log10(n^4)+1` will be 13. I measured the instruction count of clang when compiling the llvm test suite with `log10(n^5)+1` ( this function has a steeper curve - see https://www.google.com/search?q=plot+log10(x%5E5)%2B1 ) and it had a significant impact on ClamAV (1% more instructions over baseline compared to 0,57% increase with `log10(x^4)+1`).

Regarding your previous question; in order to use stable sort we would need to flatten the nested structure of `SmallDenseMap<Function *, SpecializationMap>` into a wider `SpecializationMap`, which would contain specializations of several functions in one data structure. The problem is that `calculateGains` currently expects an empty `SpecializationMap`, which corresponds to a single function, hence it would require heavy adaptation. I can experiment and see if it's worth pursuing this idea (maybe in follow up patches?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119880



More information about the llvm-commits mailing list