This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't forwprop into clobbers in some cases (PR tree-optimization/56854)


On Mon, 8 Apr 2013, Jakub Jelinek wrote:

> Hi!
> 
> lhs ={v} {CLOBBER};
> stmts right now allow only VAR_DECL or MEM_REF lhs, but the forwprop code
> below on the attached testcase attempts to propagate an ARRAY_REF (of
> MEM_REF) into it.  Fixed by not propagating in that case, allowing arbitrary
> memory lhs is IMHO unnecessary and such lhs's wouldn't be very useful for
> DSE anyway.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-04-08  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/56854
> 	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't
> 	forward into clobber stmts if it would change MEM_REF lhs into
> 	non-MEM_REF.
> 
> 	* g++.dg/torture/pr56854.C: New test.
> 
> --- gcc/tree-ssa-forwprop.c.jj	2013-02-25 23:51:21.000000000 +0100
> +++ gcc/tree-ssa-forwprop.c	2013-04-08 16:12:37.000000000 +0200
> @@ -826,7 +826,11 @@ forward_propagate_addr_expr_1 (tree name
>  	       && integer_zerop (TREE_OPERAND (lhs, 1))
>  	       && useless_type_conversion_p
>  	            (TREE_TYPE (TREE_OPERAND (def_rhs, 0)),
> -		     TREE_TYPE (gimple_assign_rhs1 (use_stmt))))
> +		     TREE_TYPE (gimple_assign_rhs1 (use_stmt)))
> +	       /* Don't forward anything into clobber stmts if it would result
> +		  in the lhs no longer being a MEM_REF.  */
> +	       && (!gimple_clobber_p (use_stmt)
> +		   || TREE_CODE (TREE_OPERAND (def_rhs, 0)) == MEM_REF))
>  	{
>  	  tree *def_rhs_basep = &TREE_OPERAND (def_rhs, 0);
>  	  tree new_offset, new_base, saved, new_lhs;
> --- gcc/testsuite/g++.dg/torture/pr56854.C.jj	2013-04-08 18:03:37.978009666 +0200
> +++ gcc/testsuite/g++.dg/torture/pr56854.C	2013-04-08 18:03:09.000000000 +0200
> @@ -0,0 +1,24 @@
> +// PR tree-optimization/56854
> +// { dg-do compile }
> +
> +inline void *
> +operator new (__SIZE_TYPE__, void *p) throw ()
> +{
> +  return p;
> +}
> +
> +struct A
> +{
> +  int a;
> +  A () : a (0) {}
> +  ~A () {}
> +  A &operator= (const A &v) { this->~A (); new (this) A (v); return *this; }
> +};
> +A b[4], c[4];
> +
> +void
> +foo ()
> +{
> +  for (int i = 0; i < 4; ++i)
> +    c[i] = b[i];
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]