public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/109910] New: GCC prologue/epilogue saves/restores callee-saved registers that are never changed
@ 2023-05-19 16:38 gjl at gcc dot gnu.org
2023-05-19 19:43 ` [Bug other/109910] " gjl at gcc dot gnu.org
2023-08-04 19:19 ` gjl at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: gjl at gcc dot gnu.org @ 2023-05-19 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109910
Bug ID: 109910
Summary: GCC prologue/epilogue saves/restores callee-saved
registers that are never changed
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: gjl at gcc dot gnu.org
Target Milestone: ---
Created attachment 55120
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55120&action=edit
args.c: C test case.
There are targets like AVR that can pass values in callee-saved registers.
There is no need to save / restore them if a caller never changes them.
Example:
$ avr-gcc args.c -dp -mmcu=atmega128 -S -Os
typedef __UINT64_TYPE__ uint64_t;
void callee_ld (long double, long double);
void callee_ull (uint64_t, uint64_t);
void noop_ld (long double x, long double y)
{
callee_ld (x, y);
}
void noop_ull (uint64_t x, uint64_t y)
{
callee_ull (x, y);
}
y is passed in R10...R17 which are callee-saved:
noop_ld:
push r10 ; 73 [c=4 l=1] pushqi1/0
push r11 ; 74 [c=4 l=1] pushqi1/0
push r12 ; 75 [c=4 l=1] pushqi1/0
push r13 ; 76 [c=4 l=1] pushqi1/0
push r14 ; 77 [c=4 l=1] pushqi1/0
push r15 ; 78 [c=4 l=1] pushqi1/0
push r16 ; 79 [c=4 l=1] pushqi1/0
push r17 ; 80 [c=4 l=1] pushqi1/0
call callee_ld ; 39 [c=0 l=2] call_insn/1
pop r17 ; 83 [c=4 l=1] popqi
pop r16 ; 84 [c=4 l=1] popqi
pop r15 ; 85 [c=4 l=1] popqi
pop r14 ; 86 [c=4 l=1] popqi
pop r13 ; 87 [c=4 l=1] popqi
pop r12 ; 88 [c=4 l=1] popqi
pop r11 ; 89 [c=4 l=1] popqi
pop r10 ; 90 [c=4 l=1] popqi
ret ; 91 [c=0 l=1] return_from_epilogue
There is no need to save R10..R17 because they are never changed. If any of
these regs is changed by callee_ld, that function will take care of it because
these regs are callee-saved.
No need to mention that this adds considerably to code size, compute and stack
usage.
The AVR backend uses df_regs_ever_live_p to determine whether a register must
be saved / restored in lack of a better alternative like non-existing
df_regs_ever_changed_p.
Configured with: ../../source/gcc-master/configure --target=avr --disable-nls
--with-dwarf2 --with-gnu-as --with-gnu-ld --disable-shared
--enable-languages=c,c++
gcc version 14.0.0 20230518 (experimental) (GCC)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug other/109910] GCC prologue/epilogue saves/restores callee-saved registers that are never changed
2023-05-19 16:38 [Bug other/109910] New: GCC prologue/epilogue saves/restores callee-saved registers that are never changed gjl at gcc dot gnu.org
@ 2023-05-19 19:43 ` gjl at gcc dot gnu.org
2023-08-04 19:19 ` gjl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: gjl at gcc dot gnu.org @ 2023-05-19 19:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109910
--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Note that df_regs_ever_live_p may be used before reload_completed, for example
in INITIAL_ELIMINATION_OFFSET.
Hence, scanning the insns by hand using, say, note_stores, does not work
because reload might still be in progress.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug other/109910] GCC prologue/epilogue saves/restores callee-saved registers that are never changed
2023-05-19 16:38 [Bug other/109910] New: GCC prologue/epilogue saves/restores callee-saved registers that are never changed gjl at gcc dot gnu.org
2023-05-19 19:43 ` [Bug other/109910] " gjl at gcc dot gnu.org
@ 2023-08-04 19:19 ` gjl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: gjl at gcc dot gnu.org @ 2023-08-04 19:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109910
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-08-04
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-04 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19 16:38 [Bug other/109910] New: GCC prologue/epilogue saves/restores callee-saved registers that are never changed gjl at gcc dot gnu.org
2023-05-19 19:43 ` [Bug other/109910] " gjl at gcc dot gnu.org
2023-08-04 19:19 ` gjl at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).