This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
GCC 3.1/arm: too many return instructions
- From: Philip Blundell <pb at nexus dot co dot uk>
- To: rearnsha at arm dot com, gcc-patches at gcc dot gnu dot org
- Date: 20 Mar 2002 14:22:16 +0000
- Subject: GCC 3.1/arm: too many return instructions
The code in the 3.1 branch, and presumably the mainline, is a bit prone
to generate function epilogues containing an excessive number of return
instructions:
add sp, sp, #4
ldmfd sp!, {r4, r5, r6, r7, r8, r9, sl, fp, pc}
mov pc, lr
More or less any function that spills its local variables onto the stack
will be affected. For example, compiling this with -O2 under arm-linux
shows the problem:
f()
{
int a, b, c, d, e, f, h, i, j, k;
a = g(); b = g(); c = g(); d = g(); e = g(); f = g(); h = g(); i =
g(); j = g(); k = g();
return a * b * c * d * e * f * h * i * j * k;
}
I've appended a patch below.
p.
2002-03-20 Philip Blundell <pb@nexus.co.uk>
* config/arm/arm.c (arm_output_epilogue): Don't generate separate
return instruction if PC was popped.
Index: arm.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.196.2.3
diff -u -r1.196.2.3 arm.c
--- arm.c 18 Mar 2002 13:45:29 -0000 1.196.2.3
+++ arm.c 20 Mar 2002 14:10:51 -0000
@@ -7669,7 +7670,7 @@
to load use the LDR instruction - it is faster. */
if (saved_regs_mask == (1 << LR_REGNUM))
{
- /* The excpetion handler ignores the LR, so we do
+ /* The exception handler ignores the LR, so we do
not really need to load it off the stack. */
if (eh_ofs)
asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
@@ -7695,7 +7696,10 @@
REGNO (eh_ofs));
#endif
- if (! really_return)
+ if (! really_return
+ || (ARM_FUNC_TYPE (func_type) == ARM_FT_NORMAL
+ && current_function_pretend_args_size == 0
+ && saved_regs_mask & (1 << PC_REGNUM)))
return "";
/* Generate the return instruction. */