Re: gcc -ffast-math defect with tan(x)

2009-11-25 Thread Eric Backus
Eric Backus agilent.com> writes: > Dave Korn googlemail.com> writes: > > > This will require a newlib patch and a new cygwin dll release to solve, > > it'll take a little while I'm afraid. > > Impressive, 5 hours from defect report to complete debugging and understanding > of an assembly l

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Greg Chicares
On 2009-11-17 14:32Z, Dave Korn wrote: [...] > WTF? The fptan has returned two QNaNs for no apparent reason? "When stack overflow occurs during FPTAN and overflow is masked, both ST(0) and ST(1) contain quiet NaNs." [intel 80387 manual] >> R7: Special 0xc000 Real Indefinite (

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Eric Backus
Dave Korn googlemail.com> writes: > Needs moar 'ffree st(0)'. > > This will require a newlib patch and a new cygwin dll release to solve, > it'll take a little while I'm afraid. > > cheers, > DaveK Impressive, 5 hours from defect report to complete debugging and understanding of

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Dave Korn
Dave Korn wrote: > maybe _f_tan needs to be 'popping' (or in some way marking > invalid) that unused +1.0 constant rather than just skipping the stack pointer > over it. Needs moar 'ffree st(0)'. This will require a newlib patch and a new cygwin dll release to solve, it'll take a little whi

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Dave Korn
Eric Backus wrote: > One experiment that I did, which confused me more than anything else, is > replace the calls to tan() with calls to log() (and change all the 0.0 values > to something OK for log() like 1.0). The generated assembly code appears to > be identical except that _f_tan is repla

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Eric Backus
Dave Korn googlemail.com> writes: > Thanks for the STC. The difference between -ffast-math and -fno-fast-math > is that the fast version calls the _f_tan newlib fast math function rather > than tan. I think this is likely to be a calling-convention issue but I'm > still debugging it. > >

Re: gcc -ffast-math defect with tan(x)

2009-11-17 Thread Dave Korn
eric_bac...@agilent wrote: > > I get this output from both gcc-3 (which is 3.4.4) and from gcc-4 (which is > 4.3.4), when -ffast-math is used. If I remove -ffast-math, I get the > expected output of 0 for both d1 and d2. If I compile with -mno-cygwin on > gcc-3, either with or without -ffast

gcc -ffast-math defect with tan(x)

2009-11-17 Thread eric_backus
Hello fellow cygwinners, I'm seeing incorrect behavior when I use the "-ffast-math" option to gcc on cygwin. Here is a Short Test Case: #include #include int main(void) { double d1 = 0.0; double d2 = 0.0; d1 = tan(d1); d2 = tan(d2); (void) printf("d1 = %lg, expecting 0 (