NetBSD Problem Report #59310
From www@netbsd.org Thu Apr 17 13:21:26 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 3FC3D1A9239
for <gnats-bugs@gnats.NetBSD.org>; Thu, 17 Apr 2025 13:21:26 +0000 (UTC)
Message-Id: <20250417132124.7D95B1A923D@mollari.NetBSD.org>
Date: Thu, 17 Apr 2025 13:21:24 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: t_fe_round:fe_nearbyint_rint tests are failing
X-Send-Pr-Version: www-1.0
>Number: 59310
>Category: port-sparc64
>Synopsis: t_fe_round:fe_nearbyint_rint tests are failing
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-sparc64-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 17 13:25:00 +0000 2025
>Last-Modified: Thu Apr 17 14:00:04 +0000 2025
>Originator: Taylor R Campbell
>Release: current
>Organization:
The SparcBSD Roundation
>Environment:
>Description:
Failures are happening both under qemu and on real hardware. Curiously, they are not happening on sparc32 -- only sparc64.
t_fe_round:fe_nearbyint_rint failures (https://www.netbsd.org/~martin/sparc64-atf/965_atf.html#lib_libm_t_fe_round_fe_nearbyint_rint):
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [0] FE_DOWNWARD nearbyintl(3.750000): got 4.000000, expected 3
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [0] FE_DOWNWARD rintl(3.750000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [0] FE_DOWNWARD rintl(3.750000): got 4.000000, expected 3
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [1] FE_DOWNWARD rintl(-3.750000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [4] FE_DOWNWARD nearbyintl(-9223.062500): got -9223.000000, expected -9224
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [4] FE_DOWNWARD rintl(-9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [4] FE_DOWNWARD rintl(-9223.062500): got -9223.000000, expected -9224
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [5] FE_DOWNWARD nearbyintl(9222.937500): got 9223.000000, expected 9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [5] FE_DOWNWARD rintl(9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [5] FE_DOWNWARD rintl(9222.937500): got 9223.000000, expected 9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [6] FE_DOWNWARD rintl(-9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [7] FE_DOWNWARD rintl(9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [10] FE_UPWARD nearbyintl(-123.750000): got -124.000000, expected -123
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [10] FE_UPWARD rintl(-123.750000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [10] FE_UPWARD rintl(-123.750000): got -124.000000, expected -123
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [11] FE_UPWARD rintl(123.750000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [12] FE_UPWARD rintl(-9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [13] FE_UPWARD rintl(9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [14] FE_UPWARD nearbyintl(-9222.937500): got -9223.000000, expected -9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [14] FE_UPWARD rintl(-9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [14] FE_UPWARD rintl(-9222.937500): got -9223.000000, expected -9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [15] FE_UPWARD nearbyintl(9223.062500): got 9223.000000, expected 9224
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [15] FE_UPWARD rintl(9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [15] FE_UPWARD rintl(9223.062500): got 9223.000000, expected 9224
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [16] FE_TOWARDZERO nearbyintl(1.937500): got 2.000000, expected 1
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [16] FE_TOWARDZERO rintl(1.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [16] FE_TOWARDZERO rintl(1.937500): got 2.000000, expected 1
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [17] FE_TOWARDZERO nearbyintl(-1.937500): got -2.000000, expected -1
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [17] FE_TOWARDZERO rintl(-1.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [17] FE_TOWARDZERO rintl(-1.937500): got -2.000000, expected -1
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [18] FE_TOWARDZERO rintl(0.250000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [19] FE_TOWARDZERO rintl(9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [20] FE_TOWARDZERO nearbyintl(9222.937500): got 9223.000000, expected 9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [20] FE_TOWARDZERO rintl(9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [20] FE_TOWARDZERO rintl(9222.937500): got 9223.000000, expected 9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [21] FE_TOWARDZERO nearbyintl(-9222.937500): got -9223.000000, expected -9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [21] FE_TOWARDZERO rintl(-9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:294: [21] FE_TOWARDZERO rintl(-9222.937500): got -9223.000000, expected -9222
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [24] FE_TONEAREST rintl(-9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [25] FE_TONEAREST rintl(9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [26] FE_TONEAREST rintl(-9222.937500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [27] FE_TONEAREST rintl(9223.062500) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [28] FE_TONEAREST rintl(-9223.531250) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [29] FE_TONEAREST rintl(9222.468750) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [30] FE_TONEAREST rintl(-9222.468750) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:263: [31] FE_TONEAREST rintl(9223.531250) failed to raise FE_INEXACT
t_fe_round:fe_nearbyintl_rintl failures (https://www.netbsd.org/~martin/sparc64-atf/965_atf.html#lib_libm_t_fe_round_fe_nearbyintl_rintl):
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [0] FE_TOWARDZERO rintl(9007199254740992.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [1] FE_DOWNWARD rintl(9007199254740992.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [2] FE_UPWARD rintl(9007199254740992.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [2] FE_UPWARD rintl(9007199254740992.500000): got 9007199254740992.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [2] FE_UPWARD nearbyintl(9007199254740992.500000): got 9007199254740992.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [3] FE_TONEAREST rintl(9007199254740992.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [4] FE_TOWARDZERO rintl(9007199254740993.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [4] FE_TOWARDZERO rintl(9007199254740993.500000): got 9007199254740994.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [4] FE_TOWARDZERO nearbyintl(9007199254740993.500000): got 9007199254740994.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [5] FE_DOWNWARD rintl(9007199254740993.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [5] FE_DOWNWARD rintl(9007199254740993.500000): got 9007199254740994.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:421: [5] FE_DOWNWARD nearbyintl(9007199254740993.500000): got 9007199254740994.000000, expected 9007199254740993
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [6] FE_UPWARD rintl(9007199254740993.500000) failed to raise FE_INEXACT
*** Check failed: /home/martin/current/src/tests/lib/libm/t_fe_round.c:390: [7] FE_TONEAREST rintl(9007199254740993.500000) failed to raise FE_INEXACT
>How-To-Repeat:
cd /usr/tests/lib/libm
atf-run t_fe_round | atf-report
>Fix:
Yes, please!
>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59310 CVS commit: src/tests/lib/libm
Date: Thu, 17 Apr 2025 13:45:22 +0000
Module Name: src
Committed By: riastradh
Date: Thu Apr 17 13:45:22 UTC 2025
Modified Files:
src/tests/lib/libm: t_fe_round.c
Log Message:
t_fe_round: Mark xfail on sparc64.
PR port-sparc64/59310: t_fe_round:fe_nearbyint_rint tests are failing
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libm/t_fe_round.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/59310: t_fe_round:fe_nearbyint_rint tests are failing
Date: Thu, 17 Apr 2025 13:58:25 +0000
All the test cases that are failing are in long double functions with
non-default rounding modes.
On sparc64, long double is implemented via softfloat ABI, from what I
understand -- `objdump --disassemble=3Drintl libm.so' shows various
_Qp_* function calls:
00000000000776e0 <rintl>:
...
77760: 40 04 54 c8 call 18ca80 <_Qp_stoq@plt>
...
77790: 40 04 57 b4 call 18d660 <_Qp_add@plt>
...
777b8: 40 04 55 32 call 18cc80 <_Qp_sub@plt>
...
777f4: 40 04 55 a3 call 18ce80 <_Qp_feq@plt>
...
77824: 40 04 54 97 call 18ca80 <_Qp_stoq@plt>
...
77850: 40 04 57 84 call 18d660 <_Qp_add@plt>
I bet the reason these are failing is that the C99 fesetround() in
libm doesn't update _softfloat_float_rounding_mode, so the _Qp_*
functions are all working in round-to-nearest:
227 int
228 fesetround(int round)
229 {
230 fenv_t r;
231=20
232 _DIAGASSERT((round & ~_ROUND_MASK) =3D=3D 0);
233 if (round & ~_ROUND_MASK)
234 return -1;
235=20
236 __stxfsr(&r);
237 r &=3D ~(_ROUND_MASK << _ROUND_SHIFT);
238 r |=3D round << _ROUND_SHIFT;
239 __ldxfsr(r);
240=20
241 /* Success */
242 return 0;
243 }
https://nxr.netbsd.org/xref/src/lib/libm/arch/sparc64/fenv.c?r=3D1.4#227
In contrast, the legacy BSD fpsetround() in libc does set
_softfloat_float_rounding_mode:
26 fp_rnd
27 fpsetround(fp_rnd rnd_dir)
28 {
29 fp_rnd old;
30 fp_rnd new;
31=20
32 __asm("st %%fsr,%0" : "=3Dm" (*&old));
33=20
34 #ifdef SOFTFLOATSPARC64_FOR_GCC
=3D> 35 _softfloat_float_rounding_mode =3D rnd_dir;
36 #endif
37=20
38 new =3D old;
39 new &=3D ~(0x03U << 30);
40 new |=3D ((rnd_dir & 0x03U) << 30);
41=20
42 __asm("ld %0,%%fsr" : : "m" (*&new));
43=20
44 return ((uint32_t)old >> 30) & 0x03;
45 }
https://nxr.netbsd.org/xref/src/lib/libc/arch/sparc64/gen/fpsetround.c?r=3D=
1.9#35
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.