This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Macros using __NO_LONG_DOUBLE_MATH


> Joseph Myers wrote:
> On Mon, 8 Jun 2015, Wilco Dijkstra wrote:
> 
> > > I don't see how such a change would benefit using GCC built-in functions
> > > anyway.  Presumably you'd do
> > >
> > > # if __GNUC_PREREQ (6, 0)
> >
> > I'm using __GNUC_PREREQ (4, 4) && !defined __SUPPORT_SNAN__ to enable
> > inlining - better to have inlining even if it isn't 100% optimal rather
> > than no inlining and having to go through the PLT to call a
> > 4-instruction function...
> 
> Do you have at least microbenchmarks to confirm the existing GCC inline
> expansions are better than the glibc out-of-line calls?  Such
> microbenchmarks should preferably go in glibc's benchmark suite.

I wrote a quick test, and __builtin_isinf_sign is 3.5 times faster than
__isinf if the value is not an infinity (common case). __builtin_isinf
is twice as fast as __builtin_isinf_sign if the sign might be used, even
if the value is not an infinity... Isnan etc show similar gains of ~6.5x.

So yes that shows that PLT entries remain expensive even with modern
branch predictors.

> Logically glibc should be built with -fsignaling-nans, but it's possible
> we get away without that in most cases (as in: most functions *should*
> raise "invalid" for signaling NaN operands, so an implementation of is*
> that spuriously raises that for signaling NaNs wouldn't actually cause
> problems, and we may not rely on avoiding optimizations that are invalid
> for signaling NaNs).  Of course some issues could be covered up by lack of
> test coverage (and at least tests of signaling NaNs ought to be built with
> that option).

Making GLIBC support sNaN correctly is likely a lot of work - many functions
start like this: if (isinf(x) || x == 0.0)... And there seems to be no test 
coverage besides test-snan.c (which I changed to build with -fsignaling-nans
so it passes with the new math.h).

Anyway I created GCC bug 66462 to fix the built-ins.

Wilco



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]