From: Richard Biener <richard.guenther@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
"MacLeod, Andrew" <amacleod@redhat.com>,
GCC patches <gcc-patches@gcc.gnu.org>
Subject: Re: [COMMITTED] Be even more conservative in intersection of NANs.
Date: Mon, 5 Sep 2022 12:38:18 +0200 [thread overview]
Message-ID: <CAFiYyc1mKN6uHrR2SuUN7dVJsdrm_h4bPPezdXJfZdmaGQc_GQ@mail.gmail.com> (raw)
In-Reply-To: <CAGm3qMXmTRT+ATSESE03NvEdBWE-pfavtaiGFjZ23--MK-=Y3Q@mail.gmail.com>
On Mon, Sep 5, 2022 at 12:24 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> On Mon, Sep 5, 2022 at 11:53 AM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Mon, Sep 5, 2022 at 11:41 AM Aldy Hernandez <aldyh@redhat.com> wrote:
> > >
> > > On Mon, Sep 5, 2022 at 11:18 AM Richard Biener
> > > <richard.guenther@gmail.com> wrote:
> > > >
> > > > On Mon, Sep 5, 2022 at 11:12 AM Aldy Hernandez <aldyh@redhat.com> wrote:
> > > > >
> > > > > On Mon, Sep 5, 2022 at 11:06 AM Jakub Jelinek <jakub@redhat.com> wrote:
> > > > > >
> > > > > > On Mon, Sep 05, 2022 at 11:00:54AM +0200, Richard Biener wrote:
> > > > > > > On Mon, Sep 5, 2022 at 8:24 AM Aldy Hernandez via Gcc-patches
> > > > > > > <gcc-patches@gcc.gnu.org> wrote:
> > > > > > > >
> > > > > > > > Intersecting two ranges where one is a NAN is keeping the sign bit of
> > > > > > > > the NAN range. This is not correct as the sign bits may not match.
> > > > > > > >
> > > > > > > > I think the only time we're absolutely sure about the intersection of
> > > > > > > > a NAN and something else, is when both are a NAN with exactly the same
> > > > > > > > properties (sign bit). If we're intersecting two NANs of differing
> > > > > > > > sign, we can decide later whether that's undefined or just a NAN with
> > > > > > > > no known sign. For now I've done the latter.
> > > > > > > >
> > > > > > > > I'm still mentally working on intersections involving NANs, especially
> > > > > > > > if we want to keep track of signbits. For now, let's be extra careful
> > > > > > > > and only do things we're absolutely sure about.
> > > > > > > >
> > > > > > > > Later we may want to fold the intersect of [NAN,NAN] and say [3,5]
> > > > > > > > with the posibility of NAN, to a NAN, but I'm not 100% sure.
> > > > > > >
> > > > > > > The intersection of [NAN, NAN] and [3, 5] is empty. The intersection
> > > > > > > of [NAN, NAN] and VARYING is [NAN, NAN].
> > > > > >
> > > > > > I think [3.0, 5.0] printed that way currently means U maybe NAN,
> > > > > > it would be [3.0, 5.0] !NAN if it was known not to be NAN.
> > > > >
> > > > > Right. I don't print any of the "maybe" properties, just if they're
> > > > > definitely set or definitely clear. I'm open to suggestions as to how
> > > > > to display them. Perhaps NAN, !NAN, ?NAN.
> > > >
> > > > There's no NAN tristate. Your "definitely NAN" would be simply
> > > > ][ NAN, that is, the value range only contains NAN. Your !NAN
> > > > is <whatever range> and non NAN. Likewise for the sign, the
> > > > range either includes -NAN and NAN or one or none of those.
> > > > For signed zeros you either have [-0, upper-bound] or [0, upper-bound]
> > > > where it either includes both -0 and 0 or just one of them
> > >
> > > But there is a tristate. We may definitely have a NAN, definitely not
> > > have a NAN, or the state of the NAN is unknown.
> >
> > Sure. But we are talking about sets of values a variable can have
> > (a value "range" where "range" is a bit misleading for something
> > like a NAN). The set of possible values either includes
> > NAN (or -NAN and +NAN) or it doesn't include NAN (or -NAN and +NAN).
> > A set cannot include or not include a "maybe NAN".
> >
> > > Say [3,5] ?NAN.
> > > That's [3,5] with the possibility of a NAN. On the true side of x >=
> > > 5.0, we'd have [5.0, INF] !NAN. On the false side we'd have [-INF,
> > > 5.0] ?NAN.
> >
> > On the true side of x >= 5.0 the set of values is described by
> > the [5., +INF] range. On the false side the set is described
> > by the union of the range [-INF, 5.0] and the { -NAN, +NAN }
> > set.
> >
> > There's no may-NAN. There's also no ?4.0, the range either
> > includes 4.0 or it doesn't.
>
> Ah, ok. I see where the confusion lies. You're missing that we don't
> have sub-ranges like we do for irange. We only have two endpoints and
> a set of flags. So we can't represent [3,4] U NAN "elegantly".
> However, we can do it with [3,4] ?NAN. This is by design, but not
> permanent. I don't have infinite time to work on frange on this cycle
> (I have other things like wide-ints conversion, prange, removal of
> legacy, etc etc), so I wanted something that worked with endpoints,
> signs, and NANs, that's about it. If at a later time we decide to go
> full throttle with the ability to represent sub-ranges, we can do so.
> Heck, you're welcome to try-- just let me finish the initial
> implementation and get it working correctly first.
>
> It is more important right now to get the usage than the
> representation right. We could always add sub-ranges, or change the
> representation altogether. What is very important we agree on is the
> usage, so your suggestions about the FP classification functions below
> are golden. I'll look into that.
>
> Does that make sense?
Not really. I didn't ask for sub-ranges for NAN, but even with a "flag"
it should still semantically be [3, 4] U NAN or [3, 4]. It's not necessary
but confusing to leave the notion of a SET here.
> BTW, [NAN, NAN] is a special case. It doesn't behave like a
> singleton. Both endpoints must match. We assert this much. We don't
> propagate it. We can't do equality to it. The fact that it lives in
> the endpoints is just an implementation detail.
And even here, having [NAN, NAN] but [3, 4] with maybe-NAN flag
is just inconsistent. Why's that necessary? Is there no "empty range"
(aka UNDEFINED) for frange?
>
> Aldy
>
> >
> > Note the frange class should probably have APIs that match
> > the FP classification functions isfinite(), isnormal(),
> > isnan(), isinf () and signbit() likewise compares like
> > isunordered() . Note isnormal () exposes that FP numbers can
> > be denormal, not sure if that's worth tracking.
> >
> > > With this representation we can fold __builtin_isnan() even on an
> > > unknown value... say on the true side of x == y we know that both x
> > > and y cannot be NANs...but on the false side we know nothing so there
> > > is the possibility of a NAN.
> > >
> > > I do like your idea for signed zeros. I think I could make it work
> > > and get rid of the sign bit.
> > >
> > > Aldy
> > >
> > > >
> > > > > I'm mostly worried about removing a NAN from the IL that was going to
> > > > > signal, or some such. While I agree with you Richard, I just want to
> > > > > make real sure, because getting something wrong in the frange or
> > > > > range-ops bowels means the problem becomes pervasive to all of ranger
> > > > > ...and threader...and loop ch...and vrp, etc etc. I just want to take
> > > > > more time to test things. I promise it won't stay varying too long.
> > > >
> > > > There's sNANs and qNANs, but I think for value-ranges we should
> > > > concern ourselves only with qNANs for now and leave sNANs VARYING.
> > > > All operations only ever produce qNANs (loads can produce sNANs).
> > > >
> > > > Richard.
> > > >
> > > > > Aldy
> > > > >
> > > >
> > >
> >
>
next prev parent reply other threads:[~2022-09-05 10:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 6:23 Aldy Hernandez
2022-09-05 9:00 ` Richard Biener
2022-09-05 9:06 ` Jakub Jelinek
2022-09-05 9:11 ` Aldy Hernandez
2022-09-05 9:18 ` Richard Biener
2022-09-05 9:41 ` Aldy Hernandez
2022-09-05 9:53 ` Richard Biener
2022-09-05 10:24 ` Aldy Hernandez
2022-09-05 10:38 ` Richard Biener [this message]
2022-09-05 11:45 ` Aldy Hernandez
2022-09-05 12:16 ` Richard Biener
2022-09-06 7:21 ` Aldy Hernandez
2022-09-06 9:09 ` Richard Biener
2022-09-06 10:26 ` Aldy Hernandez
2022-09-05 9:13 ` Richard Biener
2022-09-05 9:28 ` Aldy Hernandez
2022-09-05 9:41 ` Richard Biener
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=CAFiYyc1mKN6uHrR2SuUN7dVJsdrm_h4bPPezdXJfZdmaGQc_GQ@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.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).