This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] stdarg optimization (4.1 projects, stage 1.2)
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>,gcc-patches at gcc dot gnu dot org
- Date: Sun, 8 May 2005 22:50:23 +0200
- Subject: Re: [PATCH] stdarg optimization (4.1 projects, stage 1.2)
- References: <20050331233319.GA17420@devserv.devel.redhat.com> <20050408220812.GA11237@redhat.com>
Hi Jakub, Richard,
I briefly looked at this optimization for SPARC and I now wonder if it worth
the cycles there:
#include <stdarg.h>
int foo(int i, ...)
{
va_list ap;
int j;
va_start(ap, i);
j = va_arg(ap, int);
va_end(ap);
return j;
}
at -O0:
foo:
save %sp, -120, %sp
st %i1, [%fp+72]
st %i2, [%fp+76]
st %i3, [%fp+80]
st %i4, [%fp+84]
st %i5, [%fp+88]
st %i0, [%fp+68]
add %fp, 72, %g1
st %g1, [%fp-24]
ld [%fp-24], %i5
mov %i5, %g1
ld [%g1], %g1
st %g1, [%fp-20]
add %i5, 4, %g1
st %g1, [%fp-24]
ld [%fp-20], %g1
mov %g1, %i0
restore
jmp %o7+8
nop
at -O1:
foo:
add %sp, -120, %sp
mov %o1, %o0
jmp %o7+8
sub %sp, -120, %sp
And of course the 6 registers are not spilled to the variable part of the
frame, but to the fixed part. Same for the 64-bit ABI.
So the best solution could be to define a target hook, defaulting to false and
set to true on SPARC, so as to always return false in gate_optimize_stdarg.
What do you think? Thanks in advance.
Btw, Jakub, TARGET_STDARG_OPTIMIZE_HOOK is not documented AFAICS.
--
Eric Botcazou