mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <>
To: Markus Wichmann <>
Subject: Re: [musl] ASM-to-C conversion for i386
Date: Mon, 27 Dec 2021 11:30:56 -0500	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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).


  parent reply	other threads:[~2021-12-27 16:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-26 20:42 Markus Wichmann
2021-12-26 21:20 ` Markus Wichmann
2021-12-27 13:08 ` Markus Wichmann
2021-12-27 15:00 ` Rich Felker
2021-12-27 16:27   ` Markus Wichmann
2021-12-27 16:30   ` Rich Felker [this message]
2021-12-27 18:04     ` Markus Wichmann
2021-12-27 18:41       ` Rich Felker
2021-12-28  8:42         ` Markus Wichmann
2021-12-29 10:02   ` Markus Wichmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).