public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: Michael Matz <matz@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: RFC: explicitely mark out-of-scope deaths
Date: Thu, 26 May 2011 23:49:00 -0000	[thread overview]
Message-ID: <20110526212142.GA17137@virgil.arch.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1105261516240.9668@wotan.suse.de>

Hi,

On Thu, May 26, 2011 at 03:43:45PM +0200, Michael Matz wrote:
> Index: tree-sra.c
> ===================================================================
> --- tree-sra.c.orig	2011-05-26 14:15:01.000000000 +0200
> +++ tree-sra.c	2011-05-26 14:15:41.000000000 +0200
> @@ -1041,6 +1041,11 @@ build_accesses_from_assign (gimple stmt)
>    if (disqualify_ops_if_throwing_stmt (stmt, lhs, rhs))
>      return false;
>  
> +  /* Scope clobbers don't influence scalarization.  */
> +  if (TREE_CODE (rhs) == CONSTRUCTOR
> +      && TREE_THIS_VOLATILE (rhs))
> +    return false;
> +
>    racc = build_access_from_expr_1 (rhs, stmt, false);
>    lacc = build_access_from_expr_1 (lhs, stmt, true);

I assume DSE does not remove the stores as that would defeat the
purpose of the patch.  If after optimizations such as SRA, these
special stores are the only statements accessing the variable, will
the variable still remain in the function potentially causing an
unnecessary stack frame setup?

If so, then SRA would have to delete these statements in its
modification phase if it has removed all other accesses to the
aggregate.  This is something I can do as a followup, of course.

Thanks,

Martin

>  
> Index: tree-ssa-dce.c
> ===================================================================
> --- tree-ssa-dce.c.orig	2011-05-26 14:15:01.000000000 +0200
> +++ tree-ssa-dce.c	2011-05-26 14:15:41.000000000 +0200
> @@ -846,19 +846,17 @@ propagate_necessity (struct edge_list *e
>  	  else if (gimple_assign_single_p (stmt))
>  	    {
>  	      tree rhs;
> -	      bool rhs_aliased = false;
>  	      /* If this is a load mark things necessary.  */
>  	      rhs = gimple_assign_rhs1 (stmt);
>  	      if (TREE_CODE (rhs) != SSA_NAME
> -		  && !is_gimple_min_invariant (rhs))
> +		  && !is_gimple_min_invariant (rhs)
> +		  && TREE_CODE (rhs) != CONSTRUCTOR)
>  		{
>  		  if (!ref_may_be_aliased (rhs))
>  		    mark_aliased_reaching_defs_necessary (stmt, rhs);
>  		  else
> -		    rhs_aliased = true;
> +		    mark_all_reaching_defs_necessary (stmt);
>  		}
> -	      if (rhs_aliased)
> -		mark_all_reaching_defs_necessary (stmt);
>  	    }
>  	  else if (gimple_code (stmt) == GIMPLE_RETURN)
>  	    {
> @@ -866,7 +864,8 @@ propagate_necessity (struct edge_list *e
>  	      /* A return statement may perform a load.  */
>  	      if (rhs
>  		  && TREE_CODE (rhs) != SSA_NAME
> -		  && !is_gimple_min_invariant (rhs))
> +		  && !is_gimple_min_invariant (rhs)
> +		  && TREE_CODE (rhs) != CONSTRUCTOR)
>  		{
>  		  if (!ref_may_be_aliased (rhs))
>  		    mark_aliased_reaching_defs_necessary (stmt, rhs);
> @@ -884,6 +883,7 @@ propagate_necessity (struct edge_list *e
>  		  tree op = TREE_VALUE (gimple_asm_input_op (stmt, i));
>  		  if (TREE_CODE (op) != SSA_NAME
>  		      && !is_gimple_min_invariant (op)
> +		      && TREE_CODE (op) != CONSTRUCTOR
>  		      && !ref_may_be_aliased (op))
>  		    mark_aliased_reaching_defs_necessary (stmt, op);
>  		}
> Index: gimple.c
> ===================================================================
> --- gimple.c.orig	2011-05-26 14:15:01.000000000 +0200
> +++ gimple.c	2011-05-26 14:15:41.000000000 +0200
> @@ -1425,7 +1425,9 @@ walk_gimple_op (gimple stmt, walk_tree_f
>  	{
>            /* If the RHS has more than 1 operand, it is not appropriate
>               for the memory.  */
> -	  wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt))
> +	  wi->val_only = !(is_gimple_mem_rhs (gimple_assign_rhs1 (stmt))
> +			   || TREE_CODE (gimple_assign_rhs1 (stmt))
> +			      == CONSTRUCTOR)
>                           || !gimple_assign_single_p (stmt);
>  	  wi->is_lhs = true;
>  	}
> Index: tree-ssa-structalias.c
> ===================================================================
> --- tree-ssa-structalias.c.orig	2011-05-26 14:15:01.000000000 +0200
> +++ tree-ssa-structalias.c	2011-05-26 14:15:41.000000000 +0200
> @@ -4355,7 +4355,12 @@ find_func_aliases (gimple origt)
>        tree lhsop = gimple_assign_lhs (t);
>        tree rhsop = (gimple_num_ops (t) == 2) ? gimple_assign_rhs1 (t) : NULL;
>  
> -      if (rhsop && AGGREGATE_TYPE_P (TREE_TYPE (lhsop)))
> +      if (rhsop && TREE_CODE (rhsop) == CONSTRUCTOR
> +	  && TREE_THIS_VOLATILE (rhsop))
> +	/* Ignore clobbers, they don't actually store anything into
> +	   the LHS.  */
> +	;
> +      else if (rhsop && AGGREGATE_TYPE_P (TREE_TYPE (lhsop)))
>  	do_structure_copy (lhsop, rhsop);
>        else
>  	{
> Index: tree-ssa-operands.c
> ===================================================================
> --- tree-ssa-operands.c.orig	2011-05-26 14:15:01.000000000 +0200
> +++ tree-ssa-operands.c	2011-05-26 14:15:41.000000000 +0200
> @@ -955,6 +955,9 @@ get_expr_operands (gimple stmt, tree *ex
>  	constructor_elt *ce;
>  	unsigned HOST_WIDE_INT idx;
>  
> +	if (TREE_THIS_VOLATILE (expr))
> +	  gimple_set_has_volatile_ops (stmt, true);
> +
>  	for (idx = 0;
>  	     VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (expr), idx, ce);
>  	     idx++)
> Index: tree-ssa-sccvn.c
> ===================================================================
> --- tree-ssa-sccvn.c.orig	2011-05-26 14:15:39.000000000 +0200
> +++ tree-ssa-sccvn.c	2011-05-26 14:15:41.000000000 +0200
> @@ -1356,6 +1356,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree
>    else if (is_gimple_reg_type (vr->type)
>  	   && gimple_assign_single_p (def_stmt)
>  	   && gimple_assign_rhs_code (def_stmt) == CONSTRUCTOR
> +	   && !TREE_THIS_VOLATILE (gimple_assign_rhs1 (def_stmt))
>  	   && CONSTRUCTOR_NELTS (gimple_assign_rhs1 (def_stmt)) == 0)
>      {
>        tree base2;

  parent reply	other threads:[~2011-05-26 21:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 14:30 Michael Matz
2011-05-26 15:07 ` Jakub Jelinek
2011-05-26 15:17   ` Richard Guenther
2011-05-26 17:38 ` Steven Bosscher
2011-05-27 15:44   ` Michael Matz
2011-05-27 15:49     ` Jakub Jelinek
2011-05-27 16:45       ` Michael Matz
2011-05-26 23:49 ` Martin Jambor [this message]
2011-05-27 13:24   ` Michael Matz
2011-06-01  9:25 ` Richard Sandiford
2011-06-01  9:44   ` Richard Guenther

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=20110526212142.GA17137@virgil.arch.suse.de \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=matz@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).