From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6463 invoked by alias); 28 Mar 2013 12:16:57 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 6419 invoked by uid 89); 28 Mar 2013 12:16:49 -0000 X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 28 Mar 2013 12:16:46 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1ULBl5-0007Oj-0F from Thomas_Schwinge@mentor.com ; Thu, 28 Mar 2013 05:16:43 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 28 Mar 2013 05:16:42 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Thu, 28 Mar 2013 12:16:40 +0000 From: Thomas Schwinge To: , CC: , , Subject: Re: [attention machine maintainers] [PATCH] issignaling In-Reply-To: References: <8762148l9v.fsf@schwinge.name> <87r4j73cqo.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Thu, 28 Mar 2013 12:16:00 -0000 Message-ID: <87fvzf1zz4.fsf@schwinge.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Virus-Found: No X-SW-Source: 2013-03/txt/msg00163.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 8800 Hi! I plan to shortly "move" this patch (as present in the tschwinge/issignaling branch) into master with the following changes merged in, unless there are any further comments at this point. On Tue, 26 Mar 2013 17:33:46 +0000, "Joseph S. Myers" wrote: > On Fri, 22 Mar 2013, Thomas Schwinge wrote: >=20 > > PowerPC -m64: > >=20 > > math/basic-test.out: > > Failure: double x =3D (double) (long double) sNaN, !issignaling > >=20 > > That is, this type cast -- which is a IEEE 754-2008 general-computation= al > > convertFormat operation (IEEE 754-2008, 5.4.2) -- does not turn the sNaN > > into a qNaN (whilst raising an INVALID exception; not checked here), > > which is contrary to IEEE 754-2008 5.1 and 7.2. This I consider a > > compiler issue (powerpc-linux-gnu-gcc (Sourcery CodeBench 2012.09-92) > > 4.7.2). >=20 > Such a bug (assuming present in GCC trunk for 4.9) should be filed in GCC= =20 > Bugzilla (and I suppose a new math-tests.h macro used to disable the test= =20 > in question for older compilers). Though I guess it might only be desire= d=20 > to change this for -fsignaling-nans. I will add the following, file in GCC Bugzilla, add its PR number to the math_tests.h comment (also for the 32-bit x86 issue discussed before): --- math/basic-test.c +++ math/basic-test.c @@ -175,10 +175,13 @@ NAME (void) \ { \ x1 =3D (FLOAT) sNaN_var; \ check (" "#FLOAT" x =3D ("#FLOAT") ("#DOUBLE") sNaN, isnan", isnan (= x1)); \ - /* Upon type conversion, a sNaN is converted into a qNaN plus an */ = \ - /* INVALID exception (not checked here). */ \ - check (" "#FLOAT" x =3D ("#FLOAT") ("#DOUBLE") sNaN, !issignaling", = \ - !issignaling (x1)); \ + if (SNAN_TESTS_TYPE_CAST) \ + { \ + /* Upon type conversion, a sNaN is converted into a qNaN plus an */ \ + /* INVALID exception (not checked here). */ \ + check (" "#FLOAT" x =3D ("#FLOAT") ("#DOUBLE") sNaN, !issignaling", \ + !issignaling (x1)); \ + } \ } \ x2 =3D (FLOAT) Inf_var; \ check (" "#FLOAT" x =3D ("#FLOAT") ("#DOUBLE") Inf", isinf (x2) !=3D 0);= \ --- sysdeps/generic/math-tests.h +++ sysdeps/generic/math-tests.h @@ -34,3 +34,9 @@ (sizeof (x) =3D=3D sizeof (float) ? SNAN_TESTS_float \ : sizeof (x) =3D=3D sizeof (double) ? SNAN_TESTS_double \ : SNAN_TESTS_long_double) + +/* Indicate whether to run tests involving type casts of sNaN values. The= se + are run unless overridden. */ +#ifndef SNAN_TESTS_TYPE_CAST +# define SNAN_TESTS_TYPE_CAST 1 +#endif --- /dev/null +++ sysdeps/powerpc/math-tests.h @@ -0,0 +1,26 @@ +/* Configuration for math tests. PowerPC version. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* On PowerPC, in versions of GCC up to at least 4.7.2, a type cast -- whi= ch is + a IEEE 754-2008 general-computational convertFormat operation (IEEE + 754-2008, 5.4.2) -- does not turn a sNaN into a qNaN (whilst raising an + INVALID exception), which is contrary to IEEE 754-2008 5.1 and 7.2. Th= is + renders certain tests infeasible in this scenario. */ +#define SNAN_TESTS_TYPE_CAST 0 + +#include_next > > --- NEWS > > +++ NEWS > > @@ -26,6 +26,8 @@ Version 2.18 > >=20=20 > > * Added a benchmark framework to track performance of functions in gli= bc. > >=20=20 > > +* New macro named issignaling to check for a signaling NaN (s= NaN). > > + This is currently GNU-specific. >=20 > "GNU-specific" is a bit misleading there. I think you mean "only defined= =20 > if _GNU_SOURCE is defined" (but you should note it comes from draft TS=20 > 18661). >=20 > > +@comment math.h > > +@comment GNU > > +@deftypefn {Macro} int issignaling (@emph{float-type} @var{x}) > > +This macro returns a nonzero value if @var{x} is a signaling NaN > > +(sNaN). It is a GNU extension. >=20 > A GNU extension based on draft TS 18661. I plan to change the wording as follows in both cases: --- NEWS +++ NEWS @@ -27,7 +27,7 @@ Version 2.18 * Added a benchmark framework to track performance of functions in glibc. =20 * New macro named issignaling to check for a signaling NaN (sNaN). - This is currently GNU-specific. + It is based on draft TS 18661 and currently enabled as a GNU extension. =0C Version 2.17 =20 --- manual/arith.texi +++ manual/arith.texi @@ -391,7 +391,8 @@ to @comment GNU @deftypefn {Macro} int issignaling (@emph{float-type} @var{x}) This macro returns a nonzero value if @var{x} is a signaling NaN -(sNaN). It is a GNU extension. +(sNaN). It is based on draft TS 18661 and currently enabled as a GNU +extension. @end deftypefn =20 Another set of floating-point classification functions was provided by > > +#undef __issignaling >=20 > Why the #undef? In case a machine-specific header file is defining a macro of the same name; though you're correct that is not needed at this point. Removed. > > +int __issignaling (double x) >=20 > Return type on a separate line. Changed. --- sysdeps/ieee754/dbl-64/s_issignaling.c +++ sysdeps/ieee754/dbl-64/s_issignaling.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignaling -int __issignaling (double x) +int +__issignaling (double x) { #ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN u_int32_t hxi; --- sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c +++ sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignaling -int __issignaling (double x) +int +__issignaling (double x) { u_int64_t xi; EXTRACT_WORDS64 (xi, x); --- sysdeps/ieee754/flt-32/s_issignalingf.c +++ sysdeps/ieee754/flt-32/s_issignalingf.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignalingf -int __issignalingf (float x) +int +__issignalingf (float x) { u_int32_t xi; GET_FLOAT_WORD (xi, x); --- sysdeps/ieee754/ldbl-128/s_issignalingl.c +++ sysdeps/ieee754/ldbl-128/s_issignalingl.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignalingl -int __issignalingl (long double x) +int +__issignalingl (long double x) { u_int64_t hxi, lxi __attribute__ ((unused)); GET_LDOUBLE_WORDS64 (hxi, lxi, x); --- sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c +++ sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignalingl -int __issignalingl (long double x) +int +__issignalingl (long double x) { u_int64_t xi; /* For inspecting NaN status, we only have to look at the first of the p= air --- sysdeps/ieee754/ldbl-96/s_issignalingl.c +++ sysdeps/ieee754/ldbl-96/s_issignalingl.c @@ -19,8 +19,8 @@ #include #include =20 -#undef __issignalingl -int __issignalingl (long double x) +int +__issignalingl (long double x) { u_int32_t exi, hxi, lxi; GET_LDOUBLE_WORDS (exi, hxi, lxi, x); I also removed one =C2=BB#error untested=C2=AB after Dave's testing: --- sysdeps/ieee754/ldbl-128/s_issignalingl.c +++ sysdeps/ieee754/ldbl-128/s_issignalingl.c @@ -31,7 +31,6 @@ int __issignalingl (long double x) return ((hxi & UINT64_C (0x7fff800000000000)) =3D=3D UINT64_C (0x7fff800000000000)); #else -# error untested /* To keep the following comparison simple, toggle the quiet/signaling b= it, so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as we= ll as common practice for IEEE 754-1985). */ > > +{ > > +#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN > > + u_int32_t hxi; >=20 > (I tend to think that the C99 names such as uint32_t should be preferred,= =20 > but since the libm code seems to be using the legacy names universally,=20 > any such change should probably first be made globally to existing code i= f=20 > there's consensus, rather than making this code in particular different.) Exactly my thoughts. Gr=C3=BC=C3=9Fe, Thomas --=-=-= Content-Type: application/pgp-signature Content-length: 489 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJRVDSgAAoJENuKOtuXzphJyf8IAJNrpgiPQw5R6BhPYbsmGamE PKw6o7k1UD0id4yM303vlX5VwYt5DdQwI0deDqxU3G5vQo9SfbNT4RArk1tR2SxK m6wof3Mv8CkHYhNkTOgx4M2cS12v4iv/pz5Alvzhtx6P/AF0mbGEkilC8yCbhhwv WJ2y/Ii5AqXHZalFmgbpnEuPQvHkjwCMiTQ19wYMIJeOecGba8kI/risPvt09zJ9 5P5Ivpf5eDHlzhE8Dr2RyJEdqilmhTkTe7B5yWQZs0XiYxocMs/73pEyLtLuQR5g p+5+ALUwCN9+fj1tmJGy88a040jj+MS8Bwmsym1YhBFOjCj4U6BOeQcZhKT8N60= =GkNm -----END PGP SIGNATURE----- --=-=-=--