From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Michael Matz <matz@suse.de>,
Richard Biener <richard.guenther@gmail.com>,
GCC patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] [PR68097] frange::set_nonnegative should not contain -NAN.
Date: Tue, 20 Sep 2022 20:08:38 +0200 [thread overview]
Message-ID: <CAGm3qMURo4qabQ1fAfeDyRU2JrT3iSuTMsvnEn1d2YtkNMUS1w@mail.gmail.com> (raw)
In-Reply-To: <YynXxIxqlmZ8Q6Tc@tucnak>
On Tue, Sep 20, 2022 at 5:10 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Tue, Sep 20, 2022 at 04:58:38PM +0200, Aldy Hernandez wrote:
> > > > > deal with NaNs just fine and is required to correctly capture the sign of
> > > > > 'x'. If frange::set_nonnegative is supposed to be used in such contexts
> > > > > (and I think it's a good idea if that were the case), then set_nonnegative
> > > > > does _not_ imply no-NaN.
> > > > >
> > > > > In particular I would assume that, given an VAYRING frange FR, that
> > > > > FR.set_nonnegative() would result in an frange {[+0.0,+inf],+nan} .
> > > >
> > > > That was my understanding as well, and what my original patch did.
> > > > But again, I'm just the messenger.
> > >
> > > Ah, I obviously haven't followed the thread carefully then. If that's
> > > what it was doing then IMO it was the right thing.
> >
> > This brings me back to my original patch :).
> >
> > Richard, do you agree nonnegative should be [0.0, +INF] U +NAN.
>
> I agree with that. And similarly if there is negative that does the
> opposite [-INF, -0.0] U -NAN.
> Though, in most other places when we see that something may be a NaN, I
> think we need to set both +NAN and -NAN, because at least the 2008 version
> of IEEE 754 says:
Yeah, every other place does update_nan() with no arguments which sets
+-NAN. The only use of update_nan(bool signbit) is this patch.
>
> "When either an input or result is NaN, this standard does not interpret the sign of a NaN. Note, however,
> that operations on bit strings — copy, negate, abs, copySign — specify the sign bit of a NaN result,
> sometimes based upon the sign bit of a NaN operand. The logical predicate totalOrder is also affected by
> the sign bit of a NaN operand. For all other operations, this standard does not specify the sign bit of a NaN
> result, even when there is only one input NaN, or when the NaN is produced from an invalid
> operation."
Ughh, that means that my upcoming PLUS_EXPR implementation will have
to keep better track of NAN signs.
Pushed original patch.
Thanks.
Aldy
>
> So not sure if we should count on what NaN sign bit we get normally and what
> we get for canonical NaN. If we could rely on it, then the rule is
> that if at least one input to binary operation is NaN, then that NaN is
> copied to result, but if both are NaNs, which one is picked isn't specified,
> so we might need just union the +NAN and -NAN bits from the operands.
> But there are still sNaNs and those ought to be turned into some qNaN and
> dunno if that can change the NaN bit (say turn the sNaN into canonical
> qNaN).
> If neither operand is NaN, but result is NaN because of invalid operation
> (0/0, inf-inf, inf+-inf, sqrt (-1) and the like),
> the result is qNaN, but dunno if we can rely that it will be one with
> positive sign.
>
> Jakub
>
next prev parent reply other threads:[~2022-09-20 18:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 7:59 Aldy Hernandez
2022-09-19 8:14 ` Richard Biener
2022-09-19 12:51 ` Aldy Hernandez
2022-09-19 13:42 ` Richard Biener
2022-09-19 13:58 ` Michael Matz
2022-09-20 5:25 ` Aldy Hernandez
2022-09-20 12:51 ` Michael Matz
2022-09-20 14:58 ` Aldy Hernandez
2022-09-20 15:09 ` Jakub Jelinek
2022-09-20 18:08 ` Aldy Hernandez [this message]
2022-09-20 5:32 ` Aldy Hernandez
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=CAGm3qMURo4qabQ1fAfeDyRU2JrT3iSuTMsvnEn1d2YtkNMUS1w@mail.gmail.com \
--to=aldyh@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=matz@suse.de \
--cc=richard.guenther@gmail.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).