From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15108 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] math: move i386 sqrtf to C Date: Thu, 9 Jan 2020 12:00:02 -0500 Message-ID: <20200109170002.GW30412@brightrain.aerifal.cx> References: <20200106174346.6489-1-amonakov@ispras.ru> 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="58964"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-15124-gllmg-musl=m.gmane-mx.org@lists.openwall.com Thu Jan 09 18:01:35 2020 Return-path: Envelope-to: gllmg-musl@m.gmane-mx.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1ipbAS-000cp6-TA for gllmg-musl@m.gmane-mx.org; Thu, 09 Jan 2020 18:00:21 +0100 Original-Received: (qmail 19629 invoked by uid 550); 9 Jan 2020 17:00:16 -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 19608 invoked from network); 9 Jan 2020 17:00:15 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:15108 Archived-At: On Thu, Jan 09, 2020 at 06:55:11PM +0300, Alexander Monakov wrote: > I should have asked earlier, but - is everyone happy with this style of > expressing removal of excess precision, or should I use eval_as_float? > > +{ > + long double t; > [...] > + return (float)t; > +} musl requires C99+ with conforming floating point behavior so I think this is okay, and I'd prefer to avoid having dependency on libm.h machinery that's not strictly needed in src/math/$(ARCH) since it increases the cost of changing that machinery (requires looking at arch-specific files). My recollection was that eval_as_float is mostly an artifact of nsz's math functions supporting and being compatible with somewhat non-conforming compilers. If we want to ensure correct rounding (important for sqrt[f]) even on broken compilers (some ppl use gcc 3.x, and pcc may be broken too?) perhaps we should just do the store from asm too? Note that eval_as_float only helps if -ffloat-store is used, which is a nasty hack and also nonconforming, arguably worse than the behavior without it, so we should probably drop use of that as a fallback, and use fp_barrier[f] instead if needed. Rich