public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	 Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] phiopt, v2: Adjust instead of reset phires range
Date: Thu, 22 Dec 2022 23:11:22 +0100	[thread overview]
Message-ID: <CAGm3qMWd_vXpqfj05RPFHjf-gTd+yk-B=YiGqOnh1mOOULojrA@mail.gmail.com> (raw)
In-Reply-To: <Y6TPrATjd0SO/UrA@tucnak>

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

LGTM

On Thu, Dec 22, 2022, 22:44 Jakub Jelinek <jakub@redhat.com> wrote:

> On Thu, Dec 22, 2022 at 08:46:33PM +0100, Aldy Hernandez wrote:
> > I haven't looked at your problem above, but have you tried using
> > int_range_max (or even int_range<2>) instead of value_range above?
> >
> > value_range is deprecated and uses the legacy anti-range business,
> > which has a really hard time representing complex ranges, as well as
> > union/intersecting them.
>
> You're right.  With int_range_max it works as I expected.
> And no, floating point isn't possible here.
> If value_range is right now just the legacy single range or anti-range,
> then it explains why it didn't work - while on the first testcase
> we could have anti-range ~[0, 0], on the second case [-128, -1] U [1, 127]
> is turned into simple legacy [-128, 127].
>
> So, ok for trunk if this passes bootstrap/regtest?
>
> 2022-12-22  Jakub Jelinek  <jakub@redhat.com>
>             Aldy Hernandez  <aldyh@redhat.com>
>
>         * tree-ssa-phiopt.cc (value_replacement): Instead of resetting
>         phires range info, union it with oarg.
>
> --- gcc/tree-ssa-phiopt.cc.jj   2022-12-22 12:52:36.588469821 +0100
> +++ gcc/tree-ssa-phiopt.cc      2022-12-22 13:11:51.145060050 +0100
> @@ -1492,11 +1492,25 @@ value_replacement (basic_block cond_bb,
>                     break;
>                   }
>               if (equal_p)
> -               /* After the optimization PHI result can have value
> -                  which it couldn't have previously.
> -                  We could instead of resetting it union the range
> -                  info with oarg.  */
> -               reset_flow_sensitive_info (gimple_phi_result (phi));
> +               {
> +                 tree phires = gimple_phi_result (phi);
> +                 if (SSA_NAME_RANGE_INFO (phires))
> +                   {
> +                     /* After the optimization PHI result can have value
> +                        which it couldn't have previously.  */
> +                     int_range_max r;
> +                     if (get_global_range_query ()->range_of_expr (r,
> phires,
> +                                                                   phi))
> +                       {
> +                         int_range<2> tmp (carg, carg);
> +                         r.union_ (tmp);
> +                         reset_flow_sensitive_info (phires);
> +                         set_range_info (phires, r);
> +                       }
> +                     else
> +                       reset_flow_sensitive_info (phires);
> +                   }
> +               }
>               if (equal_p && MAY_HAVE_DEBUG_BIND_STMTS)
>                 {
>                   imm_use_iterator imm_iter;
>
>
>         Jakub
>
>

      reply	other threads:[~2022-12-22 22:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 10:30 [PATCH] phiopt: Drop SSA_NAME_RANGE_INFO in maybe equal case [PR108166] Jakub Jelinek
2022-12-22 11:13 ` Aldy Hernandez
2022-12-22 11:33 ` Richard Biener
2022-12-22 12:09   ` Aldy Hernandez
2022-12-22 12:54     ` [PATCH] phiopt: Adjust instead of reset phires range Jakub Jelinek
2022-12-22 19:46       ` Aldy Hernandez
2022-12-22 21:44         ` [PATCH] phiopt, v2: " Jakub Jelinek
2022-12-22 22:11           ` 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='CAGm3qMWd_vXpqfj05RPFHjf-gTd+yk-B=YiGqOnh1mOOULojrA@mail.gmail.com' \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    /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).