From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: FE Exception triggered by comparison
Date: Wed, 27 Feb 2019 20:14:07 +0300 (MSK) [thread overview]
Message-ID: <alpine.LNX.2.20.13.1902272002350.30425@monopod.intra.ispras.ru> (raw)
In-Reply-To: <20190227164225.GV23599@brightrain.aerifal.cx>
On Wed, 27 Feb 2019, Rich Felker wrote:
> Are there reasons we should perhaps use the __builtin versions of
> these when __GNUC__ indicates they're available? I like our bit test
> versions we have now, and I think they're sufficiently efficient, but
> I'm open to changes if there's a good reason.
Well, it really depends on what one considers 'sufficiently efficient'.
Instead of comparing a register with itself and testing flags (2 instructions)
you get (for 'int f(double x){return isnan(x);}'):
f:
movabsq $9223372036854775807, %rdx
movq %xmm0, %rax
andq %rdx, %rax
movabsq $9218868437227405312, %rdx
cmpq %rdx, %rax
seta %al
movzbl %al, %eax
ret
(note that movq %xmm0, %rax is going to be more costly than a normal
move as it crosses from fp to integer domain in the cpu)
I think musl bit test can be implemented more efficiently via right-shifting
the representation in %rax first, avoiding 64-bit immediates, but even then
I'd say the "native" version is preferable.
Alexander
next prev parent reply other threads:[~2019-02-27 17:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-24 13:28 Damian McGuckin
2019-02-24 17:12 ` Markus Wichmann
2019-02-24 19:25 ` Szabolcs Nagy
2019-02-24 20:04 ` Jens Gustedt
2019-02-24 21:50 ` Damian McGuckin
2019-02-25 5:21 ` Damian McGuckin
2019-02-25 15:51 ` Markus Wichmann
2019-02-26 3:55 ` Damian McGuckin
2019-02-27 14:14 ` Alexander Monakov
2019-02-27 15:38 ` Damian McGuckin
2019-02-27 16:00 ` Alexander Monakov
2019-02-27 16:09 ` Damian McGuckin
2019-02-27 16:14 ` Markus Wichmann
2019-02-27 16:20 ` Damian McGuckin
2019-02-28 1:07 ` Damian McGuckin
2019-02-28 1:27 ` Rich Felker
2019-02-28 2:28 ` Damian McGuckin
2019-02-27 16:32 ` Alexander Monakov
2019-02-27 16:42 ` Rich Felker
2019-02-27 17:08 ` Szabolcs Nagy
2019-02-27 17:14 ` Alexander Monakov [this message]
2019-02-27 17:26 ` Rich Felker
2019-02-27 19:36 ` Szabolcs Nagy
2019-02-27 19:48 ` Alexander Monakov
2019-02-27 20:16 ` Szabolcs Nagy
2019-02-27 20:35 ` Rich Felker
2019-02-27 21:03 ` Szabolcs Nagy
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=alpine.LNX.2.20.13.1902272002350.30425@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--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).