From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15966 invoked from network); 11 Aug 2021 22:16:25 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2021 22:16:25 -0000 Received: (qmail 23871 invoked by uid 550); 11 Aug 2021 22:16:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 23853 invoked from network); 11 Aug 2021 22:16:22 -0000 Date: Thu, 12 Aug 2021 00:16:10 +0200 From: Szabolcs Nagy To: Rich Felker Cc: Stefan Kanthak , musl@lists.openwall.com Message-ID: <20210811221610.GE37904@port70.net> Mail-Followup-To: Rich Felker , Stefan Kanthak , musl@lists.openwall.com References: <0C6AAAD55DA44C6189B2FF4F5FB2C3E7@H270> <20210810213455.GB37904@port70.net> <5C60D05C95724A36B3DB9942D06CFE5F@H270> <20210811024010.GA13220@brightrain.aerifal.cx> <7143269BEC424DE6A3B0218C4268C4C8@H270> <20210811160938.GB13220@brightrain.aerifal.cx> <20210811175723.GC13220@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210811175723.GC13220@brightrain.aerifal.cx> Subject: Re: [musl] [PATCH] Properly simplified nextafter() * Rich Felker [2021-08-11 13:57:23 -0400]: > On Wed, Aug 11, 2021 at 06:50:28PM +0200, Stefan Kanthak wrote: > > Rich Felker wrote: > > > static __inline unsigned __FLOAT_BITS(float __f) > > > { > > > union {float __f; unsigned __i;} __u; > > > __u.__f = __f; > > > return __u.__i; > > > } > > > > > > #define isnan(x) ( \ > > > sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \ > > > sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \ > > > __fpclassifyl(x) == FP_NAN) > > > > > > So, nope. > > > > GCC typically uses its __builtin_isnan() for isnan(), which doesn't > > use integer instructions or reloads: > > That's only if you #define isnan(x) __builtin_isnan(x) even then it should use int arithmetics, see below > > > $ cat isnan.c > > int foo(double x) { > > return isnan(x); > > } > > int bar(double x) { > > return __builtin_isnan(x); > > } > > $ gcc -S -O3 -o- isnan.c > > .... > > xorl %eax, %eax > > ucomisd %xmm0, %xmm0 > > setp %al > > ret > > .... > > Which glibc, which is what you're using, does. it is also wrong: isnan must not signal for signaling nan. this is a gcc bug, it fails even with -fsignaling-nans https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462 once that's fixed glibc will behave like musl.