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]

[PATCH][alias-improvements] "Re-enable" SDSE


I managed to break (read: make it a no-op) simple DSE by always recording
a load for every store.  Oops.  It turns out this skews inlining for
tramp3d quite a lot, so this patch improves tramp3d performance by 20%,
not quite to the trunk level though.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the 
branch.

Richard.

2009-01-11  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-operands.h (unlink_stmt_vdef): Declare.
	* tree-ssa-dse.c (dse_optimize_stmt): Use it.
	(execute_simple_dse): Likewise.  Make sure to update virtual
	SSA form if we changed a call.
	* tree-ssa-operands.c (add_stmt_operand): For defs do not
	update the bitmap of loaded syms.
	(unlink_stmt_vdef): New function.

Index: gcc/tree-ssa-operands.h
===================================================================
*** gcc/tree-ssa-operands.h.orig	2009-01-11 14:22:00.000000000 +0100
--- gcc/tree-ssa-operands.h	2009-01-11 14:23:26.000000000 +0100
*************** extern void push_stmt_changes (gimple *)
*** 216,221 ****
--- 216,223 ----
  extern void pop_stmt_changes (gimple *);
  extern void discard_stmt_changes (gimple *);
  
+ extern void unlink_stmt_vdef (gimple);
+ 
  enum ssa_op_iter_type {
    ssa_op_iter_none = 0,
    ssa_op_iter_tree,
Index: gcc/tree-ssa-dse.c
===================================================================
*** gcc/tree-ssa-dse.c.orig	2009-01-11 14:22:00.000000000 +0100
--- gcc/tree-ssa-dse.c	2009-01-11 14:23:26.000000000 +0100
*************** dse_optimize_stmt (struct dom_walk_data 
*** 312,332 ****
              }
  
  	  /* Then we need to fix the operand of the consuming stmt.  */
! 	  if (gimple_vdef (stmt))
! 	    {
! 	      use_operand_p use_p;
! 	      imm_use_iterator iter;
! 	      gimple use_stmt;
! 
! 	      FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_vdef (stmt))
! 		{
! 		  FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
! 		    SET_USE (use_p, gimple_vuse (stmt));
! 		}
! 
! 	      if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vdef (stmt)))
! 		SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vuse (stmt)) = 1;
! 	    }
  
  	  /* Remove the dead store.  */
  	  gsi_remove (&gsi, true);
--- 312,318 ----
              }
  
  	  /* Then we need to fix the operand of the consuming stmt.  */
! 	  unlink_stmt_vdef (stmt);
  
  	  /* Remove the dead store.  */
  	  gsi_remove (&gsi, true);
*************** execute_simple_dse (void)
*** 504,511 ****
  	    bitmap_iterator bi;
  	    bool dead = true;
  
- 
- 
  	    /* See if STMT only stores to write-only variables and
  	       verify that there are no volatile operands.  tree-ssa-operands
  	       sets has_volatile_ops flag for all statements involving
--- 490,495 ----
*************** execute_simple_dse (void)
*** 555,560 ****
--- 539,545 ----
  		    push_stmt_changes (gsi_stmt_ptr (&gsi));
                      gimple_call_set_lhs (stmt, NULL);
  		    pop_stmt_changes (gsi_stmt_ptr (&gsi));
+ 		    todo |= TODO_update_ssa_only_virtuals;
  		  }
  		else
  		  {
*************** execute_simple_dse (void)
*** 565,570 ****
--- 550,556 ----
  			fprintf (dump_file, "'\n");
  		      }
  		    removed = true;
+ 		    unlink_stmt_vdef (stmt);
  		    gsi_remove (&gsi, true);
  		    todo |= TODO_cleanup_cfg;
  		  }
Index: gcc/tree-ssa-operands.c
===================================================================
*** gcc/tree-ssa-operands.c.orig	2009-01-11 14:22:01.000000000 +0100
--- gcc/tree-ssa-operands.c	2009-01-11 14:23:26.000000000 +0100
*************** add_stmt_operand (tree *var_p, gimple st
*** 1194,1200 ****
  	{
  	  if (flags & opf_def)
  	    bitmap_set_bit (build_stores, DECL_UID (var));
! 	  bitmap_set_bit (build_loads, DECL_UID (var));
  	}
        add_virtual_operand (stmt, flags);
      }
--- 1194,1201 ----
  	{
  	  if (flags & opf_def)
  	    bitmap_set_bit (build_stores, DECL_UID (var));
! 	  else
! 	    bitmap_set_bit (build_loads, DECL_UID (var));
  	}
        add_virtual_operand (stmt, flags);
      }
*************** discard_stmt_changes (gimple *stmt_p)
*** 2209,2211 ****
--- 2210,2237 ----
    buf->stmt_p = NULL;
    free (buf);
  }
+ 
+ /* Unlink STMTs virtual definition from the IL by propagating its use.  */
+ 
+ void
+ unlink_stmt_vdef (gimple stmt)
+ {
+   use_operand_p use_p;
+   imm_use_iterator iter;
+   gimple use_stmt;
+   tree vdef = gimple_vdef (stmt);
+ 
+   if (!vdef
+       || TREE_CODE (vdef) != SSA_NAME)
+     return;
+ 
+   FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_vdef (stmt))
+     {
+       FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ 	SET_USE (use_p, gimple_vuse (stmt));
+     }
+ 
+   if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vdef (stmt)))
+     SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vuse (stmt)) = 1;
+ }
+ 


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