From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15111 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] math: move i386 sqrtf to C Date: Fri, 10 Jan 2020 00:18:58 +0100 Message-ID: <20200109231858.GP23985@port70.net> References: <20200106174346.6489-1-amonakov@ispras.ru> <20200109170002.GW30412@brightrain.aerifal.cx> <20200109210003.GO23985@port70.net> <20200109220014.GX30412@brightrain.aerifal.cx> 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="171916"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-15127-gllmg-musl=m.gmane-mx.org@lists.openwall.com Fri Jan 10 00:19:48 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 1iph59-000Oni-3L for gllmg-musl@m.gmane-mx.org; Fri, 10 Jan 2020 00:19:15 +0100 Original-Received: (qmail 14058 invoked by uid 550); 9 Jan 2020 23:19:11 -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 14040 invoked from network); 9 Jan 2020 23:19:10 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20200109220014.GX30412@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:15111 Archived-At: * Rich Felker [2020-01-09 17:00:14 -0500]: > On Thu, Jan 09, 2020 at 10:00:06PM +0100, Szabolcs Nagy wrote: > > > 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. > > > > i think -ffloat-store almost always drops excess precision > > including returns and assignments, so with that no > > annotation is needed. but yes the way the annotation is > > defined now is not useful against broken compilers or > > non-standard excess precision setting, in glibc the > > annotation is defined differently (with inline asm). > > I was thinking in the context of wanting to remove from configure the: > > || { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; } > > which is probably doing more harm than good. Do you know if there are > things that'd break if we did that? I think eval_as_float should > probably be defined as fp_barrierf to make it safe in your code, > conditional on FLT_EVAL_METHOD>0 (and likewise >1 for eval_as_double). i think -fexcess-precision=standard was introduced in gcc 4.5 and to get reliable behaviour before that we needed -ffloat-store. the freebsd math code had volatile hacks to avoid -ffloat-store but those were incomplete (there were only a few bugs e.g. see commit c4359e01303da2755fe7e8033826b132eb3659b1 freebsd sets x87 precision to double so for them some of these were not issues in practice). since we had -ffloat-store i turned off the volatile hacks in commit 6d3f1a39c14b12026df84f386875b094e3652990 and later completely removed the annotations in commit 9b0fcb441a44456c7b071c7cdaf90403f81ec05a on new compilers -fexcess-precision=standard is used, but that turned out to do too many stores on the fdlibm code (which is why glibc kept using =fast), so in commit e216951f509b71da193da2fc63e25b998740d58b i started using float_t and double_t to get fast code in standard mode. (of course this made things worse for -ffloat-store). i think we would need to add back the old annotations to make old compilers safe without -ffloat-store. (fdlibm often raises fenv exceptions via a final rounding before return, those could be often handled more cleanly by __math_oflow etc helpers, but since it was not designed for inline errno handling some normal return paths can raise fp exceptions too and thus need eval_as_* annotation).