This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
SH-ELF: gcc-3.0.2 and PR always saved unnecessarily
- To: gcc-bugs at gcc dot gnu dot org
- Subject: SH-ELF: gcc-3.0.2 and PR always saved unnecessarily
- From: tm at kloo dot net (tm)
- Date: Mon, 5 Nov 2001 16:21:27 -0800 (PST)
- Cc: tm at kloo dot net
version: gcc-3.0.2
host: i386-linux
target: sh-elf
I've noticed that GCC generates code which always saves the PR, which is rather
wasteful on short leaf functions.
For example, this code:
void main(void) { }
when compiled with -O2 -m4 -S produces:
_main:
mov.l r14,@-r15
sts.l pr,@-r15
mov r15,r14
mov r14,r15
lds.l @r15+,pr
rts
mov.l @r15+,r14
I've narrowed this down to config/sh/sh.c, to this chunk of code:
int
initial_elimination_offset (from, to)
int from;
int to;
{
int regs_saved;
int total_saved_regs_space;
int total_auto_space;
int save_flags = target_flags;
int live_regs_mask, live_regs_mask2;
if (from == RETURN_ADDRESS_POINTER_REGNUM)
/* Kludge: since we assume that the return address is on the stack,
make it so. N.B. We rely on RETURN_ADDRESS_POINTER_REGNUM being
processed before ARG_POINTER_REGNUM here. */
regs_ever_live[PR_REG] = 1;
It looks like this kludge has been removed from gcc in CVS. Does anybody
know if this code is also obsolete in gcc-3.0.2 as well?
Toshi
~