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 18830 invoked from network); 11 Aug 2021 17:57:38 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2021 17:57:38 -0000 Received: (qmail 7993 invoked by uid 550); 11 Aug 2021 17:57:36 -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 7975 invoked from network); 11 Aug 2021 17:57:36 -0000 Date: Wed, 11 Aug 2021 13:57:23 -0400 From: Rich Felker To: Stefan Kanthak Cc: Szabolcs Nagy , musl@lists.openwall.com Message-ID: <20210811175723.GC13220@brightrain.aerifal.cx> References: <0C6AAAD55DA44C6189B2FF4F5FB2C3E7@H270> <20210810213455.GB37904@port70.net> <5C60D05C95724A36B3DB9942D06CFE5F@H270> <20210811024010.GA13220@brightrain.aerifal.cx> <7143269BEC424DE6A3B0218C4268C4C8@H270> <20210811160938.GB13220@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] Properly simplified nextafter() 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) > $ 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. Rich