https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117081
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
r15-1619-g3b9b8d6cfdf593 changes IRA to increase saving and restoring
callee-saved
register cost by REG_FREQ_MAX, which is defined as 1000. As the result, IRA
avoids
using callee-saved registers. For
void foo (void);
void bar (void);
int
test (int a)
{
int r;
if (r = -a)
foo ();
else
bar ();
return r;
}
we now generates
0000000000000000 <test>:
0: 89 f8 mov %edi,%eax
2: 48 83 ec 18 sub $0x18,%rsp
6: f7 d8 neg %eax
8: 89 44 24 0c mov %eax,0xc(%rsp)
c: 85 ff test %edi,%edi
e: 74 10 je 20 <test+0x20>
10: e8 00 00 00 00 call 15 <test+0x15>
15: 8b 44 24 0c mov 0xc(%rsp),%eax
19: 48 83 c4 18 add $0x18,%rsp
1d: c3 ret
1e: 66 90 xchg %ax,%ax
20: e8 00 00 00 00 call 25 <test+0x25>
25: 8b 44 24 0c mov 0xc(%rsp),%eax
29: 48 83 c4 18 add $0x18,%rsp
2d: c3 ret
instead of
0000000000000000 <test>:
0: 53 push %rbx
1: 89 fb mov %edi,%ebx
3: f7 db neg %ebx
5: 74 09 je 10 <test+0x10>
7: e8 00 00 00 00 call c <test+0xc>
c: 89 d8 mov %ebx,%eax
e: 5b pop %rbx
f: c3 ret
10: e8 00 00 00 00 call 15 <test+0x15>
15: 89 d8 mov %ebx,%eax
17: 5b pop %rbx
18: c3 ret
callee-saved register, rbx, is used since we need to preserve r across calls.
We can't use a caller-saved register for it.