public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: GCC patches <gcc-patches@gcc.gnu.org>,
	Andrew MacLeod <amacleod@redhat.com>,
	 Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH] Add support for floating point endpoints to frange.
Date: Fri, 26 Aug 2022 21:16:09 +0200	[thread overview]
Message-ID: <CAGm3qMW=00SwDqO-7T5Q5aA=CAbtHbkit6sW2j3dY+PAtjVHUA@mail.gmail.com> (raw)
In-Reply-To: <CA+=Sn1n3R4Phg4STrdBx7D2FSSZsXYUP1O=oVxgA1Ra_N=tTBg@mail.gmail.com>

On Fri, Aug 26, 2022 at 7:40 PM Andrew Pinski <pinskia@gmail.com> wrote:
>
> On Fri, Aug 26, 2022 at 8:55 AM Aldy Hernandez <aldyh@redhat.com> wrote:
> >
> > [pinskia: I'm CCing you as the author of the match.pd pattern.]
> >
> > So, as I wrap up the work here (latest patch attached), I see there's
> > another phiopt regression (not spaceship related).  I was hoping
> > someone could either give me a hand, or offer some guidance.
> >
> > The failure is in gcc.dg/tree-ssa/phi-opt-24.c.
> >
> > We fail to transform the following into -A:
> >
> > /* { dg-options "-O2 -fno-signed-zeros -fdump-tree-phiopt" } */
> >
> > float f0(float A)
> > {
> >   //     A == 0? A : -A    same as -A
> >   if (A == 0)  return A;
> >   return -A;
> > }
> >
> > This is because the abs/negative match.pd pattern here:
> >
> > /* abs/negative simplifications moved from fold_cond_expr_with_comparison,
> >    Need to handle (A - B) case as fold_cond_expr_with_comparison does.
> >    Need to handle UN* comparisons.
> >    ...
> >    ...
> >
> > Sees IL that has the 0.0 propagated.
> >
> > Instead of:
> >
> >   <bb 2> [local count: 1073741824]:
> >   if (A_2(D) == 0.0)
> >     goto <bb 4>; [34.00%]
> >   else
> >     goto <bb 3>; [66.00%]
> >
> >   <bb 3> [local count: 708669601]:
> >   _3 = -A_2(D);
> >
> >   <bb 4> [local count: 1073741824]:
> >   # _1 = PHI <A_2(D)(2), _3(3)>
> >
> > It now sees:
> >
> >   <bb 4> [local count: 1073741824]:
> >   # _1 = PHI <0.0(2), _3(3)>
> >
> > which it leaves untouched, causing the if conditional to survive.
> >
> > Is this something that can be done by improving the match.pd pattern,
> > or should be done elsewhere?
>
> Oh the pattern which is supposed to catch this does:
>   (simplify
>    (cnd (cmp @0 zerop) integer_zerop (negate@1 @0))
>     (if (!HONOR_SIGNED_ZEROS (type))
>      @1))

On trunk without any patches, for the following snippet with -O2
-fno-signed-zeros -fdump-tree-phiopt-folding...

float f0(float A)
{
  //     A == 0? A : -A    same as -A
  if (A == 0)  return A;
  return -A;
}

...the phiopt2 dump file has:

Applying pattern match.pd:4805, gimple-match.cc:69291, which
corresponds to the aforementioned pattern.  So it looks like that was
the pattern that was matching that isn't any more?

Are you saying this pattern should only work with integers?

Aldy


  parent reply	other threads:[~2022-08-26 19:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 11:42 Aldy Hernandez
2022-08-26 15:55 ` Aldy Hernandez
2022-08-26 17:40   ` Andrew Pinski
2022-08-26 18:11     ` Aldy Hernandez
2022-08-26 18:11       ` Aldy Hernandez
2022-08-26 19:16     ` Aldy Hernandez [this message]
2022-08-26 19:44       ` Andrew Pinski
2022-08-29 13:45         ` Aldy Hernandez
2022-08-29 13:54           ` Jakub Jelinek
2022-08-29 14:07             ` Toon Moene
2022-08-29 14:15               ` Aldy Hernandez
2022-08-29 14:30                 ` Toon Moene
2022-08-29 14:36                   ` Aldy Hernandez
2022-08-29 14:42                     ` Toon Moene
2022-08-30  9:27                       ` Aldy Hernandez
2022-08-31 15:22                       ` Jeff Law
2022-08-31 15:19                 ` Jeff Law
2022-08-29 14:08             ` Aldy Hernandez
2022-08-29 14:17               ` Jakub Jelinek
2022-08-29 14:20                 ` Aldy Hernandez
2022-08-29 14:27                   ` Jakub Jelinek
2022-08-29 14:30                     ` Aldy Hernandez
2022-08-31 15:24                       ` Jeff Law
2022-08-30 22:32             ` Joseph Myers
2022-08-31 15:16             ` Jeff Law

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='CAGm3qMW=00SwDqO-7T5Q5aA=CAbtHbkit6sW2j3dY+PAtjVHUA@mail.gmail.com' \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=pinskia@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).