From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15002 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] fmax(), fmaxf(), fmaxl(), fmin(), fminf(), fminl() simplified Date: Wed, 11 Dec 2019 11:49:55 +0100 Message-ID: <20191211104955.GN23985@port70.net> References: <557979287957451E9255CCBC4CD7CBE5@H270> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="95542"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: musl@lists.openwall.com To: Stefan Kanthak Original-X-From: musl-return-15018-gllmg-musl=m.gmane.org@lists.openwall.com Wed Dec 11 11:50:10 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iezZK-000OmB-Af for gllmg-musl@m.gmane.org; Wed, 11 Dec 2019 11:50:10 +0100 Original-Received: (qmail 3788 invoked by uid 550); 11 Dec 2019 10:50:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3761 invoked from network); 11 Dec 2019 10:50:07 -0000 Mail-Followup-To: Stefan Kanthak , musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <557979287957451E9255CCBC4CD7CBE5@H270> Xref: news.gmane.org gmane.linux.lib.musl.general:15002 Archived-At: * Stefan Kanthak [2019-12-11 10:55:29 +0100]: > Still more optimisations/simplifications in the math subtree. > > JFTR: I'm NOT subscribed to your mailing list, so CC: me in replies! > > --- -/src/math/fmax.c > +++ +/src/math/fmax.c > @@ -3,11 +3,9 @@ > double fmax(double x, double y) > { > - if (isnan(x)) > + if (x != x) these two are not equivalent for snan input, but we dont care about snan, nor the compiler by default, so the compiler can optimize one to the other (although musl uses explicit int arithmetics instead of __builtin_isnan so it's a bit harder). in any case the two are equivalent for practical purposes and using isnan better documents the intention, you should change the isnan definition if you think it's not efficient. > return y; > - if (isnan(y)) > - return x; > /* handle signed zeros, see C99 Annex F.9.9.2 */ > - if (signbit(x) != signbit(y)) > + if (x == y) > return signbit(x) ? y : x; > return x < y ? y : x; nice trick, but the fenv behaviour is not right. you should run any such change through libc-test git://repo.or.cz/libc-test and look for regressions.