Optimizer is putting result of a log into the wrong reg
Thu Sep 23 07:59:00 GMT 1999
> 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:
fldln2; fxch; fyl2x
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));
The asm statement is wrong, it doesn't tell the compiler that one extra
stack reg is needed.
More information about the Gcc-bugs