From nobody Tue Jun 11 02:57:52 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VytfC0Jqnz5NSn2 for ; Tue, 11 Jun 2024 02:58:27 +0000 (UTC) (envelope-from kargls@comcast.net) Received: from resqmta-a2p-658918.sys.comcast.net (resqmta-a2p-658918.sys.comcast.net [IPv6:2001:558:fd01:2bb4::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4VytfB5PzKz4vMr for ; Tue, 11 Jun 2024 02:58:26 +0000 (UTC) (envelope-from kargls@comcast.net) Authentication-Results: mx1.freebsd.org; none Received: from resomta-a2p-647655.sys.comcast.net ([96.103.145.235]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resqmta-a2p-658918.sys.comcast.net with ESMTPS id GepvsEP5waLJkGriEsT3hw; Tue, 11 Jun 2024 02:58:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1718074698; bh=9v6Xc2S/uuN2YQFOTqlYJeElIta2L0eczBP0+LNAxB4=; h=Received:Received:Message-ID:Date:MIME-Version:Subject:To:From: Content-Type:Xfinity-Spam-Result; b=R2zKg9uP6fNezuWB2t36v8mxGmPR6zGwfPk1jCRZvPL4Hoz0k+mc6CQxNJnQfm/ar WTqp+VOZh0AHu/UWdI6abtiFkIA52mbqC9cYzW0i/IdLI39nZo2YBLt+aUvwQYvztx 8X02rHGkwPHBsrZqCHTMSdYP2dcW9oUS37Ac0B7ZljBAeeG5/XIY8zcL0Os4TA0pi8 pqX8Nch+c8LDDkFVhb9jtx1wSla4Kpva9Oc1xTOH+3dSri0dLKyIt44vJAfFD4vMb3 U7eY4BRsZVyJgsCuR3/11tLbg6NoeSAOF0IDjRpK3BPSmtF4MB9QuHwx1ZuS6jd4SF afhnd4cklwoEA== Received: from [10.0.0.95] ([76.146.78.191]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resomta-a2p-647655.sys.comcast.net with ESMTPSA id GrhqsfSpcfo1cGrhrsObbb; Tue, 11 Jun 2024 02:57:57 +0000 Message-ID: <2f772a89-50c5-4005-876e-8893e9f59e7c@comcast.net> Date: Mon, 10 Jun 2024 19:57:52 -0700 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: 888796ade284 - main - libm: fma: correct zero sign with small inputs To: Ryan Libby , Ed Maste , kargl@freebsd.org Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202406081556.458FuJYN022360@gitrepo.freebsd.org> Content-Language: en-US From: Steve Kargl In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfKd+yzzCJ9ABzc10O3zITYWGm/c2nTGn3hm3LwnyFGTLWplepUZBriP1sQEYc2UF4/A2i1HE5Kb8xjPPFw5xbQRLYswr6A61V9rJiiSoNexvbISXbJkX tcwnfGT7JDkARuLiR7LQbtsnjyOYW7rpI0M/8QxiVSvLKXXXY3RmHGPiGWpTQ121WgrsHQiUsiqQK7DZPyH7nO5jxRdE2fQJAz/+JnXmSPiURoYyEyP085bC FG2zGPY/q7xBmm9CfP8YeyIU6tTH8SYjIS0JBdkGcNyM5JDtAc29+p2oFmpp9+glndfcRfDxqDqcPrnG09XLX8zLktsB5VgPwTrbhWU5tTcpwy4W86jcDns/ ThfqZGpGTqpuLWAYWrdvJxKoyTOISA== X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:7922, ipnet:2001:558::/29, country:US] X-Rspamd-Queue-Id: 4VytfB5PzKz4vMr On 6/10/24 16:31, Ryan Libby wrote: > On Sat, Jun 8, 2024 at 8:56 AM Ed Maste wrote: >> The branch main has been updated by emaste: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=888796ade2842486d3167067e8034254c38aadd3 >> >> commit 888796ade2842486d3167067e8034254c38aadd3 >> Author: Ed Maste >> AuthorDate: 2024-03-19 14:31:39 +0000 >> Commit: Ed Maste >> CommitDate: 2024-06-08 15:55:36 +0000 >> >> libm: fma: correct zero sign with small inputs >> >> PR: 277783 >> Reported by: Victor Stinner >> Submitted by: kargl >> MFC after: 1 week >> Differential Revision: https://reviews.freebsd.org/D44433 >> --- >> lib/msun/src/s_fma.c | 4 +++- >> lib/msun/src/s_fmal.c | 4 +++- >> 2 files changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c >> index b8a342646d85..4d08b40cc71a 100644 >> --- a/lib/msun/src/s_fma.c >> +++ b/lib/msun/src/s_fma.c >> @@ -267,7 +267,9 @@ fma(double x, double y, double z) >> */ >> fesetround(oround); >> volatile double vzs = zs; /* XXX gcc CSE bug workaround */ >> - return (xy.hi + vzs + ldexp(xy.lo, spread)); >> + xs = ldexp(xy.lo, spread); >> + xy.hi += vzs; >> + return (xy.hi == 0 ? xs : xy.hi + xs); >> } >> >> if (oround != FE_TONEAREST) { >> diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c >> index 3d333632127c..12f9c364670b 100644 >> --- a/lib/msun/src/s_fmal.c >> +++ b/lib/msun/src/s_fmal.c >> @@ -248,7 +248,9 @@ fmal(long double x, long double y, long double z) >> */ >> fesetround(oround); >> volatile long double vzs = zs; /* XXX gcc CSE bug workaround */ >> - return (xy.hi + vzs + ldexpl(xy.lo, spread)); >> + xs = ldexpl(xy.lo, spread); >> + xy.hi += vzs; >> + return (xy.hi == 0 ? xs : xy.hi + xs); >> } >> >> if (oround != FE_TONEAREST) { > This seems to have caused the lib/msun/fma_tests:zeroes test to fail in > the FE_ROUNDDOWN mode on amd64, now finding 0 while expecting -0. I > don't know if the test is wrong or too strict, or if the new result is > wrong. > > https://ci.freebsd.org/job/FreeBSD-main-amd64-test/25249/testReport/junit/lib.msun/fma_test/zeroes/ > > Reproduces with > kyua debug -k /usr/tests/Kyuafile lib/msun/fma_test:zeroes The test is unreadable except by the original author. I'll note that there is a comment in fma_test.c /*  * This is needed because clang constant-folds fma in ways that are incorrect  * in rounding modes other than FE_TONEAREST.  */ static volatile double one = 1.0; and the failing tests are     testall(-one, one, one, rd ? -0.0 : 0.0, ALL_STD_EXCEPT, 0);     testall(one, -one, one, rd ? -0.0 : 0.0, ALL_STD_EXCEPT, 0);     testall(-one, -one, -one, rd ? -0.0 : 0.0, ALL_STD_EXCEPT, 0); If one compares against MPFR,    fesetround(FE_TONEAREST);    dx = -1;    dy = dz = 1;    mpfr_fma(a, x, y, z, MPFR_RNDN);    mpfr_printf("% Re % e\n", a, fma(dx, dy, dz));    fesetround(FE_DOWNWARD);    mpfr_fma(a, x, y, z, MPFR_RNDD);    mpfr_printf("% Re % e\n", a, fma(dx, dy, dz));    fesetround(FE_UPWARD);    mpfr_fma(a, x, y, z, MPFR_RNDU);    mpfr_printf("% Re % e\n", a, fma(dx, dy, dz));    fesetround(FE_TOWARDZERO);    mpfr_fma(a, x, y, z, MPFR_RNDZ);    mpfr_printf("% Re % e\n", a, fma(dx, dy, dz)); % gcc13 -fno-builtin -o z a.c -I/usr/local/include -L/usr/local/lib -lmpfr -lgmp -lm % ./z  0.0000000000000000e+00  0.000000e+00 -0.0000000000000000e+00 -0.000000e+00  0.0000000000000000e+00  0.000000e+00  0.0000000000000000e+00  0.000000e+00  0.0000000000000000e+00  0.000000e+00 -0.0000000000000000e+00 -0.000000e+00  0.0000000000000000e+00  0.000000e+00  0.0000000000000000e+00  0.000000e+00  0.0000000000000000e+00  0.000000e+00 -0.0000000000000000e+00 -0.000000e+00  0.0000000000000000e+00  0.000000e+00  0.0000000000000000e+00  0.000000e+00 cc gives a similar result. -- steve