This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, i386] Optionally use %xmm0 to return float and/or double values (take 3)


On Thu, Jan 27, 2005 at 12:57:25PM -0500, Geert Bosch wrote:
> It seems that this may not be suitable for stage 3. Changing
> calling conventions is always risky/tricky, even if it is for
> local functions, and a best-case speedup of 1% when compiling
> with specific options really isn't a compelling reason.

I think with -O2 there would be bigger speedup, as more functions
wouldn't be inlined.

> I'm especially worried about programs with assumptions that
> static functions still follow normal calling conventions.

If a program makes those assumptions and the functions are
static and not __attribute__((used)) nor their address is taken
in the source (these all are requirement for the optimization),
they are already broken.  GCC HEAD will use regparm(3) resp.
regparm(2) calling convention for them transparently.

> I know that's wrong, but it does happen. Would one still be
> able to call these functions from GDB? Also, I assume that

Calling such functions doesn't work properly in gdb's inferior, true.
But I'd call that a gdb bug, because the debug information is correct
(and e.g. gdb prints the values correctly and knows that with say
typedef struct { double d; } double_t;
static double foo (double x, float y, double_t z)
{
  printf ("%f %f %f\n", x, y, z.d);
  return x + y + z.d;
}
x is in %xmm0, y in %xmm1 and z at *(double_t*)(%ebp+8).
BTW, already with just Paolo's patch one can't print the return
values in such functions and with my patch on top of that also the
arguments passed in inferior are not put into the registers it
expects.

> when taking the address of a static function, this
> optimization doesn't apply, right?

Yeah, if address is taken (and not optimized out soon enough), then
cgraph doesn't consider the function as local.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]