Daniel Dickman <[email protected]> writes:

> With numpy/i386 we don't fix any of the currently broken tests and
> surprisingly one new regression is introduced:
>
> -13 failed, 10900 passed, 88 skipped, 108 deselected, 19 xfailed, 2
> xpassed, 5 warnings in 206.14 seconds
> +14 failed, 10899 passed, 88 skipped, 108 deselected, 19 xfailed, 2
> xpassed, 5 warnings in 205.49 seconds
>
> The new breakage is due to a test that checks for errors that <= 2
> ulps using sin on 32-bit floats vs sin on 64-bit floats (shown below).
>
> Still, it may be worth committing the proposed change and then
> separately seeing if we can improve the C versions of these functions.

The msun trig_test.c also behaves somewhat inconsistently. The
regressing case:

>> ==== run-trig_test-2 ====
>> 2 tests the accuracy of these functions over the primary range
>> ./trig_test -r 2
>>
>> trig_test.c:257: 'fpequal_cs(_x, _y, 1)' evaluated to false
>> *** Error 1 in . (Makefile:143 'run-trig_test-2')
>> FAILED

This failure can be reduced to a trivial program which does change
its behavior for the worse if s_cos.S is taken out:

#include <math.h>
#include <stdio.h>

int main(int a, char**b) {
        double y = -0.34061437849088045332;
        printf("cos(%lf)=%le delta=%e\n", y, cos(y), 0.94254960031831729956 - 
cos(y));
}

In HEAD:

cos(-0.340614)=9.425496e-01 delta=-1.110223e-16

while with the patch below:

cos(-0.340614)=9.425496e-01 delta=0.000000e+00



>From b822366bb59d131aa5de7ecb2153c9715b4e6073 Mon Sep 17 00:00:00 2001
From: Greg Steuck <[email protected]>
Date: Sun, 9 Jan 2022 13:45:51 -0800
Subject: [PATCH] Unplug assembly implementations of trig functions on x86
 platforms

The same change was done by NetBSD some time back as:

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.
---
 lib/libm/Makefile              | 9 ++++-----
 regress/lib/libm/msun/Makefile | 1 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/libm/Makefile b/lib/libm/Makefile
index 47cd94cac06..cd39bbe5c48 100644
--- a/lib/libm/Makefile
+++ b/lib/libm/Makefile
@@ -22,11 +22,10 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S 
e_log.S e_log10.S \
            e_sqrtl.S \
            invtrig.c \
            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_floor.S s_floorf.S \
+           s_floor.S s_floorf.S \
            s_log1p.S s_log1pf.S s_logb.S s_logbf.S \
            s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S s_rint.S s_rintf.S\
-           s_scalbnf.S s_significand.S s_significandf.S \
-           s_sin.S s_sinf.S s_tan.S s_tanf.S
+           s_scalbnf.S s_significand.S s_significandf.S
 .elif (${MACHINE_ARCH} == "amd64")
 .PATH: ${.CURDIR}/arch/amd64
 CPPFLAGS+=-I${.CURDIR}/arch/amd64
@@ -35,11 +34,11 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S 
e_log.S e_log10.S \
            e_sqrtl.S \
            invtrig.c \
            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_floor.S s_floorf.S \
+           s_floor.S s_floorf.S \
            s_log1p.S s_log1pf.S s_logb.S s_logbf.S \
            s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S \
            s_rint.S s_rintf.S s_scalbnf.S s_significand.S \
-           s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S
+           s_significandf.S
 .elif (${MACHINE_ARCH} == "hppa")
 .PATH: ${.CURDIR}/arch/hppa
 ARCH_SRCS = e_sqrt.c e_sqrtf.c e_remainder.c e_remainderf.c \
diff --git a/regress/lib/libm/msun/Makefile b/regress/lib/libm/msun/Makefile
index 1d6e9530c24..6f8bddf1831 100644
--- a/regress/lib/libm/msun/Makefile
+++ b/regress/lib/libm/msun/Makefile
@@ -58,7 +58,6 @@ FAILING+=     run-ctrig_test-1
 FAILING+=      run-exponential_test-1 
 FAILING+=      run-invtrig_test-7
 FAILING+=      run-next_test-{1,2,4}
-FAILING+=      run-trig_test-3
 . elif ${MACHINE} == arm64
 FAILING+=      run-cexp_test-{1,7}
 FAILING+=      run-ctrig_test-{1,5}
-- 
2.34.1

Reply via email to