diff mbox

Do not "transform" clobbers in SRA

Message ID alpine.LNX.2.00.1201271453250.4999@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Jan. 27, 2012, 1:54 p.m. UTC
Quite obvious (just generates dead code) and quite annoys reading
SRA dumps.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-01-27  Richard Guenther  <rguenther@suse.de>

	* tree-sra.c (sra_modify_assign): Do not transform clobbers.

Comments

Richard Biener Jan. 27, 2012, 2:36 p.m. UTC | #1
On Fri, 27 Jan 2012, Richard Guenther wrote:

> 
> Quite obvious (just generates dead code) and quite annoys reading
> SRA dumps.
> 
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

This regresses gcc.dg/tree-ssa/ipa-split-5.c, ipa-split is confused
about clobbers on paths where the variable is unused.  The following
alternative patch makes SRA remove fully scalarized variables (but
it still won't remove such dead clobbers if there are no other
uses at the time of SRA).

Richard.

2012-01-27  Richard Guenther  <rguenther@suse.de>

	* tree-sra.c (sra_modify_assign): Do not transform clobbers.

Index: gcc/tree-sra.c
===================================================================
*** gcc/tree-sra.c	(revision 183616)
--- gcc/tree-sra.c	(working copy)
*************** sra_modify_constructor_assign (gimple *s
*** 2817,2822 ****
--- 2817,2836 ----
    if (!acc)
      return SRA_AM_NONE;
  
+   if (gimple_clobber_p (*stmt))
+     {
+       /* Remove clobbers of fully scalarized variables, otherwise
+ 	 do nothing.  */
+       if (acc->grp_covered)
+ 	{
+ 	  unlink_stmt_vdef (*stmt);
+ 	  gsi_remove (gsi, true);
+ 	  return SRA_AM_REMOVED;
+ 	}
+       else
+ 	return SRA_AM_NONE;
+     }
+ 
    loc = gimple_location (*stmt);
    if (VEC_length (constructor_elt,
  		  CONSTRUCTOR_ELTS (gimple_assign_rhs1 (*stmt))) > 0)
diff mbox

Patch

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c	(revision 183616)
+++ gcc/tree-sra.c	(working copy)
@@ -2915,11 +2915,12 @@  sra_modify_assign (gimple *stmt, gimple_
   location_t loc;
   gimple_stmt_iterator orig_gsi = *gsi;
 
-  if (!gimple_assign_single_p (*stmt))
+  if (!gimple_assign_single_p (*stmt)
+      || gimple_clobber_p (*stmt))
     return SRA_AM_NONE;
+
   lhs = gimple_assign_lhs (*stmt);
   rhs = gimple_assign_rhs1 (*stmt);
-
   if (TREE_CODE (rhs) == CONSTRUCTOR)
     return sra_modify_constructor_assign (stmt, gsi);