This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: serious inline math pb i386
- To: nbecker at fred dot net
- Subject: Re: serious inline math pb i386
- From: Andreas Jaeger <aj at arthur dot rhein-neckar dot de>
- Date: Wed, 8 Jul 1998 07:54:02 +0200 (CEST)
- CC: egcs-bugs at cygnus dot com
Hi,
This looks more like a bug in glibc's __math.h file. I'm appending
the current glibc2 version of pow. Please note the `long long int',
which is AFAIK the missing change.
The bug should be fixed in the latest glibc version of RedHat already.
If this doesn't fix your problem, please try to reproduce the bug
(e.g. calling pow in a loop) and send a bug report for glibc (!) with
the glibcbug script.
Andreas
__MATH_INLINE double pow (double __x, double __y);
__MATH_INLINE double
pow (double __x, double __y)
{
register double __value, __exponent;
long long int __p = (long long int) __y;
if (__x == 0.0 && __y > 0.0)
return 0.0;
if (__y == (double) __p)
{
double __r = 1.0;
if (__p == 0)
return 1.0;
if (__p < 0)
{
__p = -__p;
__x = 1.0 / __x;
}
while (1)
{
if (__p & 1)
__r *= __x;
__p >>= 1;
if (__p == 0)
return __r;
__x *= __x;
}
/* NOTREACHED */
}
__asm __volatile__
("fmul %%st(1) # y * log2(x)\n\t"
"fstl %%st(1)\n\t"
"frndint # int(y * log2(x))\n\t"
"fxch\n\t"
"fsub %%st(1) # fract(y * log2(x))\n\t"
"f2xm1 # 2^(fract(y * log2(x))) - 1\n\t"
: "=t" (__value), "=u" (__exponent) : "0" (__log2 (__x)), "1" (__y));
__value += 1.0;
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__value), "u" (__exponent));
return __value;
}
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@alma.student.uni-kl.de