From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Patches for math subtree
Date: Sat, 7 Dec 2019 15:38:04 -0500 [thread overview]
Message-ID: <20191207203804.GC1666@brightrain.aerifal.cx> (raw)
In-Reply-To: <FE498902828045B7BE18810130943437@H270>
On Sat, Dec 07, 2019 at 09:15:34PM +0100, Stefan Kanthak wrote:
> Just some optimisations.
>
> --- -/src/math/i386/remquo.s
> +++ +/src/math/i386/remquo.s
> @@ -23,23 +23,17 @@
> remquo:
> mov 20(%esp),%ecx
> fldl 12(%esp)
> fldl 4(%esp)
> mov 19(%esp),%dh
> xor 11(%esp),%dh
> 1: fprem1
> fnstsw %ax
> sahf
> jp 1b
> fstp %st(1)
> - mov %ah,%dl
> - shr %dl
> - and $1,%dl
> - mov %ah,%al
> - shr $5,%al
> - and $2,%al
> - or %al,%dl
> - mov %ah,%al
> - shl $2,%al
> - and $4,%al
> - or %al,%dl
> + setc %dl
> + shl $2,%ah
> + adc %dl,%dl
> + shl $5,%ah
> + adc %dl,%dl
> test %dh,%dh
>
> --- -/src/math/ceil.c
> +++ +/src/math/ceil.c
> @@ -18,10 +18,10 @@
> + /* special case because of non-nearest rounding modes */
> + if (e < 0x3ff) {
> + FORCE_EVAL(y);
> + return u.i >> 63 ? -0.0 : 1.0;
> + }
> /* y = int(x) - x, where int(x) is an integer neighbor of x */
> if (u.i >> 63)
> y = x - toint + toint - x;
> else
> y = x + toint - toint - x;
> - /* special case because of non-nearest rounding modes */
> - if (e <= 0x3ff-1) {
> - FORCE_EVAL(y);
> - return u.i >> 63 ? -0.0 : 1;
> - }
>
> --- -/src/math/floor.c
> +++ +/src/math/floor.c
> @@ -18,10 +18,10 @@
> + /* special case because of non-nearest rounding modes */
> + if (e < 0x3ff) {
> + FORCE_EVAL(y);
> + return u.i >> 63 ? -1.0 : 0.0;
> + }
> /* y = int(x) - x, where int(x) is an integer neighbor of x */
> if (u.i >> 63)
> y = x - toint + toint - x;
> else
> y = x + toint - toint - x;
> - /* special case because of non-nearest rounding modes */
> - if (e <= 0x3ff-1) {
> - FORCE_EVAL(y);
> - return u.i >> 63 ? -1 : 0;
> - }
Do you have any explanation of why these are optimizations?
Rich
next prev parent reply other threads:[~2019-12-07 20:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-07 20:15 Stefan Kanthak
2019-12-07 20:38 ` Rich Felker [this message]
2019-12-08 14:54 ` Rich Felker
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191207203804.GC1666@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
https://git.vuxu.org/mirror/musl/
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).