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.
This commit is contained in:
riastradh 2018-11-07 04:00:12 +00:00
parent a8a8e5f56a
commit 6059a086c9
4 changed files with 9 additions and 47 deletions

View File

@ -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 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
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

View File

@ -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 @@ ATF_TC_BODY(cos_angles, tc)
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();
}
}

View File

@ -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 @@ ATF_TC_BODY(sin_angles, tc)
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();
}
}

View File

@ -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 @@ static const struct {
{ 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 @@ ATF_TC_BODY(tan_angles, tc)
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();
}
}