Optimizer is putting result of a log into the wrong reg
Singh, Kirat
Kirat.Singh@gs.com
Thu Sep 30 19:57:00 GMT 1999
cool, so I will whack my local include file to do the right thing. Guess we
should send mail to the glibc list about it too.
Thanks for the help!
-Kirat
-----Original Message-----
From: Bernd Schmidt [SMTP:bernds@cygnus.co.uk]
Sent: Thursday, September 23, 1999 10:59 AM
To: Singh, Kirat
Cc: 'moshier@mediaone.net'; egcs-bugs@egcs.cygnus.com;
drepper@cygnus.com
Subject: RE: Optimizer is putting result of a log into the
wrong reg
> Oops, sorry about that. I am now passing doubles where doubles are
expected
> (I also simplified it a bit). But it *still* puts a NaN into the
variable
> DiscRate whereas it clearly should be 0.
Looking at the assembler output, it seems clear what's going wrong:
FuncB:
pushl %ebp
movl %esp,%ebp
subl $24,%esp
pushl %edi
pushl %esi
pushl %ebx
fldl 24(%ebp)
fldl 40(%ebp)
fldl 56(%ebp)
fldl 72(%ebp)
fldl 80(%ebp)
fldl 96(%ebp)
fldl 104(%ebp)
movl 124(%ebp),%edi
movl 128(%ebp),%esi
movl 132(%ebp),%ebx
movl 136(%ebp),%edx
movl 140(%ebp),%ecx
fldl 112(%ebp)
#APP
fldln2; fxch; fyl2x
#NO_APP
This piece of code loads nine values on the floating point stack,
which has
only eight entries.
This appears to be a bug in glibc-2.1. Here's the log function
(after the
preprocessor is done with it):
extern __inline double
log (double __x)
{
register double __result;
__asm __volatile__ ("fldln2; fxch; fyl2x":"=t" (__result):"0"
(__x));
return __result;
}
The asm statement is wrong, it doesn't tell the compiler that one
extra
stack reg is needed.
Bernd
More information about the Gcc-bugs
mailing list