Hello everyone,

I wanted to highlight this ticket on bugzilla [0]. It is a missed optimization that I worked on. It involves propagating constants across function calls at link-time. I am relatively new to GCC and this would be my first significant contribution. I have developed a prototype of the solution that seems to work well enough to compile and run CPU2017 intrate benchmarks correctly. I am now in the process of running the full suite. Feedback would be appreciated.

Here's an overview of how it works:

ipa-initcall-cp collects all variables with static lifetime that contain only a single constant write. Then, for each read of the variable, we determine (statically) if the write occurs before read. In order to do this, we use both the dominators graph and the static call graph. If the write occurs before all reads, then we can safely substitute the read with the constant being written to the variable. ipa-initcall-cp works across function calls so the read and write do not need to occur on the same function.

There are some issues which still need to be addressed, particularly, ipa-initcall-cp is at the moment just a prototype and as such it will stream in functions and modify them during WPA. I would like to fix this, however I am not sure how to properly use clones when modifying the function body.

I have tested this against applied my patch to GCC version 10.1. If you have any questions, comments, let me know.

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92538

Reply via email to