public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Marc Glisse <marc.glisse@inria.fr>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: update address taken: don't drop clobbers
Date: Mon, 07 Jul 2014 17:20:00 -0000	[thread overview]
Message-ID: <53BAD6F3.5090801@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1407051342330.2225@laptop-mg.saclay.inria.fr>

On 07/06/14 08:23, Marc Glisse wrote:
> What is the lifetime of an SSA_NAME with a default definition? The way
> we handle it now, we start from the uses and go back to all blocks that
> can reach one of the uses, since there is no defining statement where we
> could stop
Right, that's exactly what I would expect given the typical definition 
of liveness.


  (intuitively we should stop where the clobber was, if not
> earlier). This huge lifetime makes it very likely for such an SSA_NAME
> to conflict with others. And if an abnormal phi is involved, and thus we
> must coalesce, there is a problem.
So this suggests another approach.  Could we just assume that it's 
always safe to coalesce with a default definition?


>
> The patch attached (it should probably use ssa_undefined_value_p with a
> new extra argument to say whether we care about partially-undefined)
> makes the lifetime of undefined local variables empty and lets the
> original patch work with:
>        def = get_or_create_ssa_default_def (cfun, sym);
> instead of creating a new variable.
Not a terrible suggestion either and accomplishes the same thing as the 
mental model I had of special casing this stuff in the coalescing code.

I guess this is the first thing we probably should sort out.  Do we want 
to handle this is the conflict, coalescing or lifetime analysis.

We've certainly had similar hacks in the code which built the conflict 
matrix for the register allocator in the past (old local-alloc/global 
variant, pre IRA).   By not recoding those conflicts, coalescing just 
magically works.

By handling it when we build the lifetimes, they'll magically coalesce 
because there's no conflicts as well.  It may help other code which 
utilizes lifetimes as well.  But a part of me doesn't like it because it 
is different than the traditionally formulated life analysis.

The question I havent thought much about is would the coalescing code do 
the right thing if we have one of these undefined SSA_NAMEs that 
coalesce into two different partitions.

ie, let's say we have two PHI nodes in different blocks.  Each PHI has 
one or more source/dest operations that are marked as 
SSA_NAME_OCCURS_IN_ABNORMAL_PHI.  Furthermore, they all reference a 
single RHS undefined SSA_NAME.

When we coalesce the undefined SSA_NAME with all the others in the first 
PHI, doesn't that mean that we then have to coalesce all the SSA_NAMES 
in both PHIs together (because that undefined SSA_NAME appears on the 
RHS on the 2nd PHI too).

Does this then argue that each use of an undefined SSA_NAME should be a 
unique SSA_NAME?

Ugh, I wonder if I just opened a can of worms here...

>
> However, I am not convinced reusing the same variable is necessarily the
> best thing. For warnings, we can create a new variable with the same
> name (with .1 added by gcc at the end) and copy the location info (I am
> not doing that yet), so little is lost. A new variable expresses more
> clearly that the value it holds is random crap. If I reuse the same
> variable, the SRA patch doesn't warn because SRA explicitly sets
> TREE_NO_WARNING (this can probably be changed, but that's starting to be
> a lot of changes). Creating a new variable is also more general. When
> reading *ssa_name after *ssa_name={v}{CLOBBER}; or after free(ssa_name);
> we have no variable to reuse so we will need to create a new undefined
> variable, and if a variable is global or a PARM_DECL, its default
> definition is not an undefined value (though it will probably happen in
> a different pass, so it doesn't have to behave the same).
My concern about using another variable was primarily that it was being 
used to hide a deeper issue.


>
> (Side note: we don't seem to have any code to notice that:
> a=phi<undef,b>
> b=phi<undef,a>
> means both phis can be replaced with undefined variables.)
Various passes will consider the undef value to be whatever value is 
convenient for optimization.  So for the first, we'd consider the undef 
value to be the same as "b" because that allows the PHI to be propagated 
away.

Obviously when there are many different values in the RHS, it's a lot 
less likely that we'll be able to propagate away the PHI.

Jeff

  parent reply	other threads:[~2014-07-07 17:20 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28 22:33 Marc Glisse
2014-06-29 23:38 ` SRA: " Marc Glisse
2014-07-07  8:56   ` Richard Biener
2014-07-07  9:32     ` Marc Glisse
2014-07-07 18:32       ` Richard Biener
2014-07-07 20:15         ` Marc Glisse
2014-07-07 16:59     ` Jeff Law
2014-07-10 14:55   ` Richard Biener
2014-07-10 15:01     ` Jakub Jelinek
2014-06-30 19:31 ` update address taken: " Jeff Law
2014-07-06 14:24   ` Marc Glisse
2014-07-06 14:54     ` pinskia
2014-07-06 15:01       ` Marc Glisse
2014-07-07 10:21     ` Richard Biener
2014-07-07 17:20     ` Jeff Law [this message]
2014-07-08 13:31       ` Marc Glisse
2014-07-10 15:10 ` Richard Biener
2014-07-10 15:49   ` Michael Matz
2014-07-10 18:23     ` Jeff Law
2014-07-11  8:10       ` Richard Biener
2014-07-11  8:14         ` Richard Biener
2014-07-11 12:06       ` Michael Matz
2014-07-11 17:16         ` Jeff Law
2014-07-12  6:15   ` Marc Glisse
2014-07-24 13:06     ` Richard Biener
2014-07-27 11:53   ` Marc Glisse
2014-07-27 18:01   ` Marc Glisse
2014-09-07 15:28     ` Marc Glisse
2014-10-15 14:36       ` Marc Glisse
2014-10-15 16:12         ` Jeff Law
2014-10-16 11:20           ` Richard Biener
2014-10-16 14:11             ` Marc Glisse
2014-10-16 14:34               ` Richard Biener
2014-10-16 17:29               ` Jeff Law
2014-10-16 17:58                 ` Richard Biener
2014-10-16 18:37                   ` Jeff Law
2014-10-17 20:46                     ` Marc Glisse
2014-10-24 20:22                       ` Jeff Law
2014-10-25  8:06                         ` Marc Glisse
2014-10-31 21:06                           ` Jeff Law
2014-10-25 17:14                         ` Marc Glisse
2014-10-31 11:12                           ` Richard Biener
2014-11-02 10:34                             ` Marc Glisse
2014-11-03  9:06                               ` Richard Biener
2014-10-31 21:16                           ` Jeff Law
2014-10-16 17:23             ` Jeff Law
2014-10-18 22:23   ` Marc Glisse
2014-10-24 20:19     ` 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=53BAD6F3.5090801@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    /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).