[IPA branch] Do pre-inline CCP/DCE

Diego Novillo dnovillo@redhat.com
Sun Sep 18 13:15:00 GMT 2005


On 09/18/05 08:26, Jan Hubicka wrote:

>Index: tree-ssa-operands.c
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
>retrieving revision 2.100.2.1
>diff -c -3 -p -r2.100.2.1 tree-ssa-operands.c
>*** tree-ssa-operands.c	18 Aug 2005 14:43:58 -0000	2.100.2.1
>--- tree-ssa-operands.c	18 Sep 2005 12:21:26 -0000
>*************** get_indirect_ref_operands (tree stmt, tr
>*** 1604,1609 ****
>--- 1604,1613 ----
>  	  v_ann = var_ann (ptr);
>  	  if (v_ann->type_mem_tag)
>  	    add_stmt_operand (&v_ann->type_mem_tag, s_ann, flags);
>+ 	  /* Aliasing information is missing; mark statement as volatile so we
>+ 	     won't optimize it out too actively.  */
>+ 	  else if (s_ann && !aliases_computed_p)
>+ 	    s_ann->has_volatile_ops = true;
>  	}
>      }
>  
>*************** add_stmt_operand (tree *var_p, stmt_ann_
>*** 1798,1803 ****
>--- 1802,1809 ----
>  
>        if (aliases == NULL)
>  	{
>+ 	  if (s_ann && !aliases_computed_p && TREE_ADDRESSABLE (var))
>+ 	    s_ann->has_volatile_ops = true;
>  	  /* The variable is not aliased or it is an alias tag.  */
>  	  if (flags & opf_is_def)
>  	    {
>  
>
You are marking volatile every non-register operand (stores to global 
variables, arrays, etc).  You should only need to mark pointer 
dereferences as volatile (i.e., the change you did to 
get_indirect_ref_operands).

However, that may not be enough for DCE:

foo()
{
  int a, *p;
  p = baz (&a);
  a = 3;      <-- This is *not* dead, p may be pointing to a.
  return *p;
}

So, I think you will also need the change in add_stmt_operand.  Every 
store/load to non-gimple registers will be marked volatile.  Well, 
without aliasing information, there's not much else you can do.

Make sure that the has_volatile_ops flag is later reset to false.  In 
theory, it is always computed from scratch every time a statement is 
re-scanned.



More information about the Gcc-patches mailing list