This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Optimization bug(?) in egcs 1.0.3a on i686
- To: egcs-bugs at cygnus dot com
- Subject: Optimization bug(?) in egcs 1.0.3a on i686
- From: Trond Myklebust <trond dot myklebust at fys dot uio dot no>
- Date: Thu, 9 Jul 1998 19:29:47 +0200 (CEST)
- Reply-To: trond dot myklebust at fys dot uio dot no
Hi,
The following test-case seems to miscompile on my i686 when I
compile using egcs 1.0.3a with '-O2'. The program will segfault upon
entry to the inlined 'pow' function (included below).
Cheers,
Trond
test.c------------------
#include <math.h>
main()
{
volatile double a;
double c;
a = 32.0;
c = pow(a, 1.0/3.0);
}
-------------------------
(listing of the 'pow' function from __math.h glibc-2.0.7)
extern __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;
}