Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libm/arch/i387 Drop in a fabs() after the fsqrt().



details:   https://anonhg.NetBSD.org/src/rev/d04ef2abbc6d
branches:  trunk
changeset: 327255:d04ef2abbc6d
user:      dsl <dsl%NetBSD.org@localhost>
date:      Mon Mar 03 08:00:50 2014 +0000

description:
Drop in a fabs() after the fsqrt().
While it may seem pointless, it the rouding mode is set to round towards
minus infinity then acos(-1) calculates atan2(sqrt(1.0 - 1.0), -1) the subtract
generates -0.0 which sqrt() preserves.
atan2(-0, -1) is -pi, but acos(-1) is expected to be +pi.
This might 'fix' the test failures seen in some environments, but they
are not failing due to an obvously incorrent x87 rounding mode.

diffstat:

 lib/libm/arch/i387/e_acos.S |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r 03fc06e24042 -r d04ef2abbc6d lib/libm/arch/i387/e_acos.S
--- a/lib/libm/arch/i387/e_acos.S       Mon Mar 03 05:05:09 2014 +0000
+++ b/lib/libm/arch/i387/e_acos.S       Mon Mar 03 08:00:50 2014 +0000
@@ -7,7 +7,7 @@
 
 #include "abi.h"
 
-RCSID("$NetBSD: e_acos.S,v 1.8 2003/07/26 19:24:57 salo Exp $")
+RCSID("$NetBSD: e_acos.S,v 1.9 2014/03/03 08:00:50 dsl Exp $")
 
 /* acos = atan (sqrt(1 - x^2) / x) */
 ENTRY(__ieee754_acos)
@@ -18,6 +18,7 @@
        fld1
        fsubp                           /* 1 - x^2 */
        fsqrt                           /* sqrt (1 - x^2) */
+       fabs                            /* Change -0.0 to +0.0 */
        fxch    %st(1)
        fpatan
        XMM_DOUBLE_EPILOGUE



Home | Main Index | Thread Index | Old Index