https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116028
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Looking at the r15-1045 vs. r15-8061 differences (just two random snapshots
before r15-1619 and after r15-7895) I see that for the pseudo containing the i
parameter value from the start of the function until *i = 0; store after the
call in r15-1045 IRA decided to use register 19 to it, there are plenty of call
saved registers (but obviously they need to be saved/restored before use).
Whereas current-ish trunk decided to use register 1 for it and LRA spills it to
the stack early, before the conditional jump to almost return and pops it in
between the printf call and *i = 0 store (so only needed conditionally).
Now, what the trunk RA does seems to me actually better for -fno-shrink-wrap:
- str x19, [sp, 16]
- mov x19, x0
+ str x0, [sp, 24]
...
- str wzr, [x19]
+ ldr x1, [sp, 24]
+ str wzr, [x1]
.L1:
- ldr x19, [sp, 16]
It would be even better (especially if the argument is often zero) to move the
spill
after the conditional jump, i.e.
- str x0, [sp, 24]
cbz x0, .L1
+ str x0, [sp, 24]
because the spill slot is only accessed if x0 is non-zero, and doing that would
guess
fix up the shrink wrapping.
Do we have some RTL pass which does insn sinking?
Or should LRA do it itself?
Or shrink-wrapping pass do it if those stores would prevent shrink-wrapping
otherwise?