https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117938
Uroš Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ubizjak at gmail dot com
Component|target |rtl-optimization
--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
The problem is in the postreload late combine pass.
Looking at _.323r.postreload dump, we have the following sequence that handles
stack pointer adjustments before the second call to 'bar' (insn 199) in foo:
...
176: {sp:DI=ax:DI+0x80;clobber flags:CC;}
REG_ARGS_SIZE 0
177: {sp:DI=sp:DI-0x40;clobber flags:CC;}
REG_ARGS_SIZE 0x40
...
187: {sp:DI=r13:DI-0x40;clobber flags:CC;}
REG_ARGS_SIZE 0x80
...
199: call [`bar'] argc:0x80
REG_CALL_DECL `bar'
REG_EH_REGION 0
...
but in _.325r.late_combine dump, the same sequence got additional (insn 338)
just before the second call to 'bar' (insn 199) in foo:
...
176: {sp:DI=ax:DI+0x80;clobber flags:CC;}
REG_ARGS_SIZE 0
177: {sp:DI=sp:DI-0x40;clobber flags:CC;}
REG_ARGS_SIZE 0x40
...
187: {sp:DI=r13:DI-0x40;clobber flags:CC;}
REG_ARGS_SIZE 0x80
...
338: {sp:DI=ax:DI+0x80;clobber flags:CC;}
REG_ARGS_SIZE 0
199: call [`bar'] argc:0x80
REG_CALL_DECL `bar'
REG_EH_REGION 0
...
The compilation goes down the hill from here, creating wrong code:
...
subq $64, %rsp # 177 [c=4 l=4] *adddi_1/1
...
leaq -64(%r13), %rsp # 534 [c=4 l=4] *leadi
leaq 128(%rax), %rsp # 535 [c=4 l=7] *leadi <--- **here**
...
call bar # 199 [c=0 l=5] *call
...
FWIW, putting (insn 535) in front of (insn 177) in the assembly fixes the
testcase.