Optimizer is putting result of a log into the wrong reg

Bernd Schmidt bernds@cygnus.co.uk
Thu Sep 30 19:57:00 GMT 1999


On 23 Sep 1999, Ulrich Drepper wrote:

> Bernd Schmidt <bernds@cygnus.co.uk> writes:
> 
> >   register double __result;
> >   __asm __volatile__ ("fldln2; fxch; fyl2x":"=t" (__result):"0" (__x));
> >   return __result;

> What we really would have to write is something like
> 
>   __asm __volatile__ ("fldln2; fxch; fyl2x" :"=t" (__result):"0" (__x):"st7");
> 
> but this isn't possible.  So, what's the best way to write it?

The comment at the top of reg-stack.c says
   6. Some asm statements may need extra stack space for internal
      calculations.  This can be guaranteed by clobbering stack registers
      unrelated to the inputs and outputs.

So, it seems that you need to to write it this way:

  __asm __volatile__ ("fldln2; fxch; fyl2x":"=t" (__result):"0" (__x) : "st(1)");

That appears to fix the problem for me.

Bernd



More information about the Gcc-bugs mailing list