Source-Changes-HG archive

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

[src/trunk]: src Disable x87 implementations of sin, cos, tan.



details:   https://anonhg.NetBSD.org/src/rev/c68829b70783
branches:  trunk
changeset: 445637:c68829b70783
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Nov 07 04:00:12 2018 +0000

description:
Disable x87 implementations of sin, cos, tan.

The x87 hardware uses a bad approximation to pi for argument
reduction, and consequently yields bad answers for inputs near pi or
pi/2.

Tweak one tanf test whose doubly rounded output is a little too far
from the correct answer on the doubly rounded input.

diffstat:

 lib/libm/Makefile      |  10 +++++-----
 tests/lib/libm/t_cos.c |  12 +-----------
 tests/lib/libm/t_sin.c |  16 +---------------
 tests/lib/libm/t_tan.c |  18 ++----------------
 4 files changed, 9 insertions(+), 47 deletions(-)

diffs (159 lines):

diff -r 741d6bfd7e22 -r c68829b70783 lib/libm/Makefile
--- a/lib/libm/Makefile Wed Nov 07 03:59:36 2018 +0000
+++ b/lib/libm/Makefile Wed Nov 07 04:00:12 2018 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.204 2018/06/13 08:19:36 kamil Exp $
+#  $NetBSD: Makefile,v 1.205 2018/11/07 04:00:12 riastradh Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -123,14 +123,14 @@
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
            e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
            e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
-           s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S s_cos.S \
-           s_cosf.S s_finite.S s_finitef.S s_floor.S s_floorf.S \
+           s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S \
+           s_finite.S s_finitef.S s_floor.S s_floorf.S \
            s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_logbl.S \
            s_rint.S s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
-           s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S 
+           s_significandf.S lrint.S
 # do not pick up the i387 asm version for the following functions;
 # it is incorrect
-.for f in modf ilogb ilogbl ilogbf
+.for f in cos cosf modf ilogb ilogbl ilogbf sin sinf tan tanf
 s_${f}.o s_${f}.pico s_${f}.po s_${f}.go s_${f}.d: s_${f}.c
 .endfor
 
diff -r 741d6bfd7e22 -r c68829b70783 tests/lib/libm/t_cos.c
--- a/tests/lib/libm/t_cos.c    Wed Nov 07 03:59:36 2018 +0000
+++ b/tests/lib/libm/t_cos.c    Wed Nov 07 04:00:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_cos.c,v 1.5 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_cos.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #include <float.h>
 #include <math.h>
 
-#if defined(__i386__) || defined(__x86_64__)
-const int TRIG_BUSTED = 1;
-#else
-const int TRIG_BUSTED = 0;
-#endif
-
 static const struct {
        int             angle;
        double          x;
@@ -86,15 +80,11 @@
                double cos_theta = angles[i].y;
 
                assert(cos_theta != 0);
-               if (TRIG_BUSTED && fabs(cos_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_fail("cos near +/-pi/2 is busted");
                if (!(fabs((cos(theta) - cos_theta)/cos_theta) <= eps)) {
                        atf_tc_fail_nonfatal("cos(%d deg = %.17g) = %.17g"
                            " != %.17g",
                            deg, theta, cos(theta), cos_theta);
                }
-               if (TRIG_BUSTED && fabs(cos_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_pass();
        }
 }
 
diff -r 741d6bfd7e22 -r c68829b70783 tests/lib/libm/t_sin.c
--- a/tests/lib/libm/t_sin.c    Wed Nov 07 03:59:36 2018 +0000
+++ b/tests/lib/libm/t_sin.c    Wed Nov 07 04:00:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sin.c,v 1.5 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_sin.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #include <float.h>
 #include <math.h>
 
-#if defined(__i386__) || defined(__x86_64__)
-const int TRIG_BUSTED = 1;
-#else
-const int TRIG_BUSTED = 0;
-#endif
-
 static const struct {
        int             angle;
        double          x;
@@ -93,19 +87,11 @@
                        ok = (fabs((sin(theta) - sin_theta)/sin_theta) <= eps);
                }
 
-               if (TRIG_BUSTED &&
-                   sin_theta != 0 &&
-                   fabs(sin_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_fail("sin near +/- pi is busted");
                if (!ok) {
                        atf_tc_fail_nonfatal("sin(%d deg = %.17g) = %.17g"
                            " != %.17g",
                            deg, theta, sin(theta), sin_theta);
                }
-               if (TRIG_BUSTED &&
-                   sin_theta != 0 &&
-                   fabs(sin_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_pass();
        }
 }
 
diff -r 741d6bfd7e22 -r c68829b70783 tests/lib/libm/t_tan.c
--- a/tests/lib/libm/t_tan.c    Wed Nov 07 03:59:36 2018 +0000
+++ b/tests/lib/libm/t_tan.c    Wed Nov 07 04:00:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_tan.c,v 1.6 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_tan.c,v 1.7 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #include <float.h>
 #include <math.h>
 
-#if defined(__i386__) || defined(__x86_64__)
-const int TRIG_BUSTED = 1;
-#else
-const int TRIG_BUSTED = 0;
-#endif
-
 static const struct {
        int             angle;
        double          x;
@@ -52,7 +46,7 @@
        {    0,  0.000000000000000,  0.0000000000000000, 999 },
        {   30,  0.5235987755982988, 0.57735026918962573, 999 },
        {   45,  0.785398163397448,  0.9999999999999992, 999 },
-       {   60,  1.047197551196598,  1.7320508075688785, 999 },
+       {   60,  1.047197551196598,  1.7320508075688785,  1.7320509 },
        {  120,  2.094395102393195, -1.7320508075688801, -1.7320505 },
        {  135,  2.356194490192345, -1.0000000000000002, 999 },
        {  150,  2.617993877991494, -0.57735026918962629, -0.57735032 },
@@ -89,19 +83,11 @@
                        ok = (fabs((tan(theta) - tan_theta)/tan_theta) <= eps);
                }
 
-               if (TRIG_BUSTED &&
-                   tan_theta != 0 &&
-                   fabs(tan_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_fail("tan near +/- pi is busted");
                if (!ok) {
                        atf_tc_fail_nonfatal("tan(%d deg = %.17g) = %.17g"
                            " != %.17g",
                            deg, theta, tan(theta), tan_theta);
                }
-               if (TRIG_BUSTED &&
-                   tan_theta != 0 &&
-                   fabs(tan_theta) < 2*DBL_EPSILON)
-                       atf_tc_expect_pass();
        }
 }
 



Home | Main Index | Thread Index | Old Index