From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id ee901481 for ; Thu, 6 Feb 2020 14:52:12 +0000 (UTC) Received: (qmail 5414 invoked by uid 550); 6 Feb 2020 14:52:09 -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 5389 invoked from network); 6 Feb 2020 14:52:09 -0000 Date: Thu, 6 Feb 2020 09:51:56 -0500 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20200206145156.GF1663@brightrain.aerifal.cx> References: <20200114185058.GV23985@port70.net> <20200114185835.GG30412@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) Sender: Rich Felker Subject: Re: [musl] Q: dealing with missing removal of excess precision On Tue, Jan 14, 2020 at 10:53:41PM +0300, Alexander Monakov wrote: > On Tue, 14 Jan 2020, Rich Felker wrote: > > > > otoh it would be nice if there was a way to tell the compiler not to > > > remove it (e.g. in case the asm already took care of it) even in c99 > > > standard mode. > > > > Perhaps this happens if the output constraint is tied to a float > > rather than a long double? > > Precisely. That's what previously posted patches do, and they match > existing hand-tuned assembly. > > I misspoke when saying that Glibc might return a value with excess precision. > I was looking at fmod-like functions and missed a slightly subtle point that > fprem does not introduce excess precision. So I don't actually have any > example where Glibc might misbehave in that regard. I think I might like to go ahead and apply these patches now, or at least some of them -- the ones fixing excess precision -- rather waiting, because I got a report of a nasty bug stemming from excess precision of the inverse trig functions: https://github.com/OSGeo/PROJ/issues/1906 The problem is that, by returning excess precision, these functions violate hard constraints on their range (either entire range, or range for a given input domain) -- invariants like acos(x)<=M_PI or implications like atan2(y,x)>=M_PI_2 => "(x,y) outside first quadrant" fail to hold. Arguably this is just a 1ulp error issue, but I don't think we have any actual inaccuracies of that degree at "important" angles where the result is not the correctly rounded one, even with the generic C implementations. Rather the problem is stemming purely from wrongly retaining excess precision and the fact that the LD80 approximation of pi is greater than the double approximation of pi. If writing and testing the remaining i386 functions before release is not practical, I wonder if just removing the asm for now, and adding back the new code in next release cycle would be a good idea. Or I could just leave it, but I don't like making a release with "known bugs of consequence" like this. Rich