An x86 -fpic and -fomit-frame-pointer bug
H.J. Lu
hjl@lucon.org
Sun Jun 21 13:24:00 GMT 1998
> >
> > It shows you are the only one who ever tried my testcase :-). Here
> > is the complete testcase.
>
> Thanks. BUT, egcs-1.0.3a is buggy, too:
>
> Interestingly, gcc-2.8.1 is OK:
>
> $ LD_RUN_PATH=/tools/gnu/lib/gcc-lib/i586-linux/2.8.1 gmake CC=/tools/gnu/packages/gcs/2.8.1/bin/gcc
> /tools/gnu/packages/gcs/2.8.1/bin/gcc -S -O2 -fno-exceptions main.cc
> /tools/gnu/packages/gcs/2.8.1/bin/gcc -S -fomit-frame-pointer -O3 -fpic -fno-exceptions cexp.cc
> /tools/gnu/packages/gcs/2.8.1/bin/gcc -o main main.s cexp.s -lstdc++
> for f in main; do echo "Running: $f"; $f; \
> if [ $? != 0 ]; then echo Failed; fi; done
> Running: main
> 22.1672, 1.04274
>
gcc-2.8.1 is buggy too. Try this cexp.cc on gcc-2.8.1.
BTW, it should be fixed in egcs 1.1. I have proposed 2 solutions and
sent in a kludge to disable -fomit-frame-pointer for PIC.
H.J.
---cexp.cc---
#include "cexp.h"
__inline double exp (double __x);
__inline double
exp (double __x)
{
register double __value, __exponent;
#if 1
#if 1
__asm __volatile__
("fldl2e # e^x = 2^(x * log2(e))\n\t"
"fmul %%st(1) # x * log2(e)\n\t"
"fstl %%st(1)\n\t"
"frndint # int(x * log2(e))\n\t"
"fxch\n\t"
"fsub %%st(1) # fract(x * log2(e))\n\t"
"f2xm1 # 2^(fract(x * log2(e))) - 1\n\t"
: "=t" (__value), "=u" (__exponent) : "0" (__x));
#endif
__value += 1.0;
__asm __volatile__
("fscale"
: "=t" (__value) : "0" (__value), "u" (__exponent));
return __value;
#else
return __x;
#endif
}
__inline double sin (double __x);
__inline double
sin (double __x)
{
#if 1
register double __value;
__asm __volatile__
("fsin"
: "=t" (__value) : "0" (__x));
return __value;
#else
return __x;
#endif
}
__inline double cos (double __x);
__inline double
cos (double __x)
{
#if 1
register double __value;
__asm __volatile__
("fcos"
: "=t" (__value): "0" (__x));
return __value;
#else
return __x;
#endif
}
template <class FLOAT> complex<FLOAT>
exp (const complex<FLOAT>& x)
{
return polar (FLOAT (exp (x.real ())), x.imag ());
}
template c exp (ccr);
More information about the Gcc-bugs
mailing list