Mail Archives: djgpp-workers/1999/03/19/20:13:56
I wrote:
>
> The Beyonder <beyonder69 AT geocities DOT com> wrote:
>
> > Now during compilation it just gets stuck on "Generating Tri table...".
> > SIN alone works, and so does COS... but ACOS alone just stalls (I can
> > quit using CTRL-C).
> >
> > Is it ACOS or my programming?
>
> This appears to be a bug in the FPU emulation. I can reproduce it on an
> FPU-less machine; any call to `acos' appears to enter some kind of
> infinite loop.
It turns out this is due to a compiler bug that breaks the emulator in
`fsqrt'. It compiles the test for the main loop into
xorl %edx, %edx
testl %edx, %edx
je loop_top
(!!!!)
It was probably never noticed before because GCC 2.7.2.1 did not have
this bug. It seems to be fixed in EGCS 1.1.2 (but not 1.1.1.)
Here is a patch which works around it.
*** src/libemu/src/emu387.cc Fri Mar 19 16:53:54 1999
--- src/libemu/src/emu387.new Fri Mar 19 16:54:44 1999
***************
*** 2033,2038 ****
--- 2033,2041 ----
int exp = (st().exp - EXP_BIAS - 1)/2 - 64;
while (!(((long *)&result)[1] & 0x80000000))
{
+ /* GCC between 2.8 and EGCS 1.1.1 optimizes this loop
+ all wrong; the asm works around it. */
+ asm volatile("" : : : "memory");
left = (left << 2) + (((unsigned *)&val)[1] >> 30);
djshld(&val);
djshld(&val);
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -