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: hjl at lucon dot org (H.J. Lu)
- Date: Wed, 8 Jul 1998 13:52:16 -0700 (PDT)
- Cc: aj at arthur dot rhein-neckar dot de, egcs-bugs at cygnus dot com
>
> Yes! I have a test case!
>
Thanks a lot. Here is the simplied version. The good news is the
current egcs in CVS seems ok. The bad news is the current egcs in
CVS is basically broken :-(.
H.J.
----
static __inline double
__log2 (double __x)
{
register double __value;
__asm __volatile__
("fld1\n\t"
"fxch\n\t"
"fyl2x"
: "=t" (__value) : "0" (__x));
return __value;
}
static __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;
}
}
__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;
}
double pc_ceiling;
double pc_step;
double pc_threshold_dB = 17;
double pc_threshold;
main () {
double pc_command[1 ];
int i_pc_loopdelay;
for (i_pc_loopdelay = 0; i_pc_loopdelay < 1 ; i_pc_loopdelay++)
pc_command[i_pc_loopdelay] = 0;
pc_ceiling = pow (10.0, -4.9691 / 10.0);
pc_step = pow (10.0, 0.5 / 10.0);
pc_threshold = pow (10.0, pc_threshold_dB / 10.0);
return 0;
}