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 7181 invoked from network); 27 Dec 2021 16:31:12 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 27 Dec 2021 16:31:12 -0000 Received: (qmail 9980 invoked by uid 550); 27 Dec 2021 16:31:10 -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 9942 invoked from network); 27 Dec 2021 16:31:09 -0000 Date: Mon, 27 Dec 2021 11:30:56 -0500 From: Rich Felker To: Markus Wichmann Cc: musl@lists.openwall.com Message-ID: <20211227163056.GV7074@brightrain.aerifal.cx> References: <20211226204238.GA1949@voyager> <20211227150010.GU7074@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211227150010.GU7074@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] ASM-to-C conversion for i386 On Mon, Dec 27, 2021 at 10:00:11AM -0500, Rich Felker wrote: > On Sun, Dec 26, 2021 at 09:42:38PM +0100, Markus Wichmann wrote: > > For the maths code, > > One thing I found right away on the math code: You can't use "=t" for > output in a float or double variable unless the asm naturally > guarantees there's no excess precision (e.g. fmod where the operation > is exact and the precision is necessarily bounded by the input > precision). Otherwise you need "=t" to a temporary long double output > to then let the compiler convert down to float or double (e.g. at time > of return; I think we're still using explicit cast there too in case > some compilers get this wrong). One thought, and I'm not sure if this is a good idea or a bad one but worth discussing: Using your acos.c as an example, where you have the comment: atan2(fabs(sqrt((1-x)*(1+x))), x) The actual code could be written as: return (double)x87_fpatan(x, x87_fabs(x87_fsqrt((1-x)*(1+x)))); with the appropriate "x87.h" defining each of these with the appropriate asm & constraints. This kinda makes the individual functions self-documenting and non-error-prone (repetition of error-prone constraints, especially the hidden requirement that, in "=t"(x), x have type long double). Rich