public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jeff Law <jeffreyalaw@gmail.com>,
	Jakub Jelinek <jakub@redhat.com>,
	 GCC patches <gcc-patches@gcc.gnu.org>,
	"MacLeod, Andrew" <amacleod@redhat.com>
Subject: Re: [PATCH] [PR tree-optimization/107394] Canonicalize global franges as they are read back.
Date: Fri, 28 Oct 2022 10:23:44 +0200	[thread overview]
Message-ID: <CAGm3qMV_Ga4B6U2Qyu1Q+m8B5SadcX=6sbz27FhCVAmXdESGxA@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc2+ZOE7pX0JYPUyvSwPTQghMxuGJusGK4MXD_7j0YFHxA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2625 bytes --]

On Fri, Oct 28, 2022, 08:49 Richard Biener <richard.guenther@gmail.com>
wrote:

> On Fri, Oct 28, 2022 at 12:45 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> > On 10/25/22 15:01, Aldy Hernandez via Gcc-patches wrote:
> > > [Richi/Jakub/FP experts, does this sound like the right solution, or
> am I
> > > missing some subtle IPA/inlining issue?]
> > >
> > > The problem here is that we're inlining a global range with NANs into
> > > a function that has been tagged with __attribute__((optimize
> > > ("-ffinite-math-only"))).  As the global range is copied from
> > > SSA_NAME_RANGE_INFO, its NAN bits are copied, which then cause
> > > frange::verify_range() to fail a sanity check making sure no NANs
> > > creep in when !HONOR_NANS.
> > >
> > > I think what we should do is nuke the NAN bits as we're restoring the
> > > global range.  For that matter, if we use the frange constructor,
> > > everything except that NAN sign will be done automatically, including
> > > dropping INFs to the min/max representable range when appropriate.
> > >
> > >       PR tree-optimization/107394
> > >
> > > gcc/ChangeLog:
> > >
> > >       * value-range-storage.cc (frange_storage_slot::get_frange): Use
> > >       frange constructor.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > >       * gcc.dg/tree-ssa/pr107394.c: New test.
> >
> > The other approach would be to disabling inlining in this case due to an
> > unsafe attribute mismatch, but we're not currently doing much sanity
> > checking in this space and it might be a huge can of worms.  I'm
> > inclined to ACK, but give Jakub and Richi until Monday to chime in first.
>
> We are actually quite careful in this regard but maybe our reasoning
> is wrong.  We are allowing inlining of -fno-finite-math-only into
> -ffinite-math-only code but not the other way around.
>
> On the actual patch I think that ranges with Inf/NaNs should be always
> treated as "valid", the optimization to trim them with certain options
> is optimization and thus optional.  So IMHO having verify_range ICE
> on NaNs isn't correct?
>

That was my gut feeling as well, but the assert has caught real issues such
as this one. Also, in your example down thread, we would drop the explicit
NAN to UNDEFINED if expressed as a range (as agreed earlier this cycle). So
we won't ICE...since a range with NAN will never get built.

The assert is there to keep NANs from sneaking in. However, if you still
think it's incorrect I'm happy to remove it.


> That said, the patch is in line with what we do elsewhere at the moment,
> so I guess OK.
>

Thanks.
Aldy


> Richard.
>
> >
> > jeff
> >
>
>

      parent reply	other threads:[~2022-10-28  8:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 21:01 Aldy Hernandez
2022-10-26  7:57 ` Aldy Hernandez
2022-10-27 22:45 ` Jeff Law
2022-10-28  6:48   ` Richard Biener
2022-10-28  6:50     ` Richard Biener
2022-10-28  8:23     ` Aldy Hernandez [this message]

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='CAGm3qMV_Ga4B6U2Qyu1Q+m8B5SadcX=6sbz27FhCVAmXdESGxA@mail.gmail.com' \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jeffreyalaw@gmail.com \
    --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).