From: Paul Khuong <pvk@pv...>  20120529 00:25:57

On Mon, May 28, 2012 at 5:36 PM, Lutz Euler <lutz.euler@...> wrote: > The test is about range reduction for trigonometric functions on large > float arguments, like (sin (expt 2d0 70)). It was introduced with commit > ad9090dc91fc922a with a fix for lp#327192 where Gabor had noticed that > on x86 the above expression returns 0d0 and Paul committed a change > introducing range reduction into the relevant VOPs on x86. > > In short: The test is bogus. Even on x86 it only doesn't fail due to an > (un)lucky choice of test values. Trigonometric functions on large float > arguments on x86 still deliver completely wrong results. The x8664 port > gets everything right but the test punishes that. > Basically, x86 gets things wrong because it does range reduction (even > for arguments below (expt 2 63), it seems) modulo some limitedprecision > approximation of 2 pi. The thing is, branching on C2 and going through FPREM/2Pi is exactly what Intel recommends in their ISA reference: "It is up to the program to check the C2 flag for outofrange conditions. Source values outside the range 263 to +263 can be reduced to the range of the instruction by subtracting an appropriate integer multiple of 2π or by using the FPREM instruction with a divisor of 2π." (I can't tell what section 8.3.8 of volume 1 means when we use FLDPI's 66 bit constant directly). If it's good enough for the official docs, I believe that's good enough for SBCL as well. I think any issue might stem from our using x87 in 64 bit mode. >  Completely revert the fix for lp#327192 on the account that delivering > 0 or some random value are both equally bad (the bug that "tan" > crashes can be fixed independently; there is only an "fldz" missing). Disagree. There's a lot of quibbling to be had wrt whether a FP value denotes a point or a range, but it's pretty clear to me that I should be able to depend on sin^2 + cos^2 = 1. >  Change the test to test for correct results and mark x86 as failing. It's a different test than what was originally intended, but sure. Paul Khuong 