[llvm] [GlobalMerge] Aggressively merge constants to reduce TOC entries (PR #111756)
Zaara Syeda via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 12:00:04 PDT 2024
syzaara wrote:
> ```
> static const int a[4000];
> static const int b[4000];
> static const int c[3000];
> static const int d[3000];
>
> int foo(int *, int*);
>
> int int1() {
> return foo(a, c);
> }
>
> int int2() {
> return foo(b, d);
> }
>
> int int3() {
> return foo(a, c);
> }
>
> int int4() {
> return foo(b, d);
> }
> ```
>
> If you put "a" and "c" together, and "b" and "d" together, each function has one TOC load. If you merge a+b and c+d instead, each function has two TOC loads.
I see what you mean now. I tried prototyping another approach where we merge the same way as we currently do and then follow that on with merging any left overs. I then compared it with this approach of blindly merging all constants together using SPEC. The results showed that there was negligible impact on performance but the TOC size was ~2% smaller if we merge all constants without looking at use. Since reducing TOC size is beneficial, we would like to move forward with this patch. As a next step, our goal is to use this approach in GlobalMerge to replace the PPCMergeStringPoolPass as this can handle everything that PPCMergeStringPoolPass was meant to handle while using the existing infrastructure. Additionally, we hope to move away from PPCMergeStringPoolPass to GlobalMerge since PPCMergeStringPoolPass has observed some intermittent issues on some of the buildbots in the past.
https://github.com/llvm/llvm-project/pull/111756
More information about the llvm-commits
mailing list