public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Andrew Pinski <apinski@marvell.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/7] Duplicate the range information of the phi onto the new ssa_name
Date: Tue, 22 Jun 2021 17:19:24 -0700	[thread overview]
Message-ID: <CA+=Sn1mDfrsGYzaJDqfWzmJRUc_bQ573aD-oi8uGdN00R9YQiA@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc35MHs-_Z+Z1+m1ZJOjejtnBA54dgePeKBgbY54EBc5hw@mail.gmail.com>

On Sun, Jun 20, 2021 at 11:50 PM Richard Biener via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Sat, Jun 19, 2021 at 9:49 PM apinski--- via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > From: Andrew Pinski <apinski@marvell.com>
> >
> > Since match_simplify_replacement uses gimple_simplify, there is a new
> > ssa name created sometimes and then we go and replace the phi edge with
> > this new ssa name, the range information on the phi is lost.
> > I don't have a testcase right now where we lose the range information
> > though but it does show up when enhancing match.pd to handle
> > some min/max patterns and g++.dg/warn/Wstringop-overflow-1.C starts
> > to fail.
> >
> > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
> >
> > gcc/ChangeLog:
> >
> >         * tree-ssa-phiopt.c (match_simplify_replacement): Duplicate range
> >         info if we're the only things setting the target PHI.
> > ---
> >  gcc/tree-ssa-phiopt.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
> > index 24cbce9955a..feb8ca8d0d1 100644
> > --- a/gcc/tree-ssa-phiopt.c
> > +++ b/gcc/tree-ssa-phiopt.c
> > @@ -894,6 +894,14 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
> >        gsi_move_before (&gsi1, &gsi);
> >        reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move));
> >      }
> > +  /* Duplicate range info if we're the only things setting the target PHI.  */
> > +  tree phi_result = PHI_RESULT (phi);
> > +  if (!gimple_seq_empty_p (seq)
> > +      && EDGE_COUNT (gimple_bb (phi)->preds) == 2
> > +      && !POINTER_TYPE_P (TREE_TYPE (phi_result))
>
> Please use INTEGRAL_TYPE_P (...)

Yes, using INTEGRAL_TYPE_P makes more sense here.
Note I copied exactly what was already done in minmax_replacement.

>
> > +      && SSA_NAME_RANGE_INFO (phi_result)
>
> && !SSA_NAME_RANGE_INFO (result)
>
> ?  Why conditional on !gimple_seq_empty_p (seq)?

The way I understand it is if !gimple_seq_empty_p (seq) is true then
the result will be a new SSA name and therefore !SSA_NAME_RANGE_INFO
(result) will also be true

> It looks like we could do this trick (actually in both directions,
> wherever the range
> info is missing?) in replace_phi_edge_with_variable instead?

Let me look into doing that.

Thanks,
Andrew

>
> Thanks,
> Richard.
>
> )
> > +    duplicate_ssa_name_range_info (result, SSA_NAME_RANGE_TYPE (phi_result),
> > +                                  SSA_NAME_RANGE_INFO (phi_result));
> >    if (seq)
> >      gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
> >
> > --
> > 2.27.0
> >

  reply	other threads:[~2021-06-23  0:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19 19:47 [PATCH 1/7] Reset the range info on the moved instruction in PHIOPT apinski
2021-06-19 19:47 ` [PATCH 2/7] Duplicate the range information of the phi onto the new ssa_name apinski
2021-06-21  6:49   ` Richard Biener
2021-06-23  0:19     ` Andrew Pinski [this message]
2021-06-23  7:29       ` Richard Biener
2021-06-21  6:42 ` [PATCH 1/7] Reset the range info on the moved instruction in PHIOPT 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='CA+=Sn1mDfrsGYzaJDqfWzmJRUc_bQ573aD-oi8uGdN00R9YQiA@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=apinski@marvell.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).