This reminds me of a PR that Bernd did: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
It is also support for adding the r0-r3 registers to the epilogue/prologue push-pop for sake of reducing code size, though in a sense even more aggressive; it tries to merge the local stack allocation SP sub/add with the stm/ldm.
Bernd's patch was for Thumb-1, though I don't see why it can't be implemented for ARM/Thumb-2 too.
Chung-Lin
On 2010/9/7 21:36, Julian Brown wrote:
On Tue, 07 Sep 2010 21:06:10 +0800 Yao Qiyao.qi@linaro.org wrote:
Julian Brown wrote:
So yeah, I think there is indeed a possible improvement here (and we don't even need to break the EABI, I don't think). Unless I've overlooked something, anyway...
Julian, I revert back the first example, and add your comments in it. https://wiki.linaro.org/YaoQi/Sandbox/Thumb2SizeOptimize
In order to teach gcc chooses low register when keeping stack alignment, which part of gcc shall I have a look? Is it about RA or regrename?
No, all the code to generate prologues& epilogues is target-specific, and happens after register allocation. Take a look at e.g. arm.c:arm_expand_prologue and friends. (Beware though, they can be quite fiddly!)
Julian