Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 27 Feb 2019 18:08:53 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: FE Exception triggered by comparison

* Rich Felker <dalias@...c.org> [2019-02-27 11:42:25 -0500]:
> On Wed, Feb 27, 2019 at 07:32:01PM +0300, Alexander Monakov wrote:
> > On Thu, 28 Feb 2019, Damian McGuckin wrote:
> > 
> > > > Hm, no, for x86 with GCC you should not see that: the compiler knows how to
> > > > expand isnan efficiently.  Are you perhaps on OS X and the 'gcc' command
> > > > actually invokes Clang/LLVM?
> > > 
> > > No.
> > > 
> > > > If not, can you show output of 'gcc -v', command-line flags you used, and
> > > > the assembly you're seeing?
> > > 
> > > 	gcc -O3 -S -msse4.2 -mfma mynan.c
> > 
> > Ah, in this case you're falling victim of a problem in your Glibc version:
> > while GCC is sufficiently new to know how to expand isnan efficiently,
> > Glibc math.h defines isnan as a macro that redirects to __isnan that GCC
> > does not recognize. Newer Glibc versions use __builtin_isnan where suitable,
> > which leads to optimal assembly.
> > 
> > (musl does not use this builtin, expanding the macro to a bit test instead)
> 
> 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.

yeah, a target may have slow fpreg->greg moves to do the bit checks,
but fast single instruction check on the fpreg and then the builtin
would be preferred.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.