This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: soft-fp: Refactor exception handling for comparisons
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Carlos O'Donell <carlos at redhat dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 9 Oct 2014 00:31:42 +0000
- Subject: Re: soft-fp: Refactor exception handling for comparisons
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1409182321370 dot 20342 at digraph dot polyomino dot org dot uk> <5435D26F dot 5020806 at redhat dot com>
On Wed, 8 Oct 2014, Carlos O'Donell wrote:
> > +/* Helper for comparisons. EX is 0 not to raise exceptions, 1 to
> > + raise exceptions for signaling NaN operands, 2 to raise exceptions
> > + for all NaN operands. */
> > +
> > +#define _FP_CMP_CHECK_NAN(fs, wc, X, Y, ex) \
> > + do \
> > + { \
> > + if (ex) \
>
> Does the soft-fp code care about implicit boolean coersion?
Not based on existing handling of rsigned in _FP_TO_INT. I've made a note
to review that as a coding style issue (I have a few other residual coding
style issues in this code to deal with, although lots have been fixed).
> If I had to write this it would have written:
>
> if ((ex) == 1
> && (_FP_ISSIGNAN (fs, wc, X)
> || _FP_ISSIGNAN (fs, wc, Y))
> FP_SET_EXCEPTION (FP_EX_INVALID);
>
> if ((ex) == 2)
> FP_SET_EXCEPTION (FP_EX_INVALID);
>
> Since this is *very* easy to read and understand given the description,
> but I don't know if the compiler generates better or worse code given
> the above.
The code is written to make it obvious that things can be folded for
constant arguments to the macros, rather than based on what code a
particular compiler version does or does not generate. (If it's
convenient to do things in a way that doesn't change compiler code
generation at all, so making it obvious that a patch is safe for existing
users not using the new features, that's a bonus, though it wasn't
possible for this patch.)
--
Joseph S. Myers
joseph@codesourcery.com