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]

Avoiding useless work



Another step towards avoiding useless work when we thread jumps.  Basically
it's silly to even bother marking bypassed virtual sets for the out-of-ssa
translators.  Just mark them for the in-to-ssa translator.

Bootstrapped and regression tested on i686-pc-linux-gnu.

	* tree-ssa-dom.c (redirect_edges_and_update_ssa_graph): Don't even
	bother marking bypassed virtuals for out-of-ssa.  Instead merge
	bypassed virtuals into vars_to_rename just before into-ssa pass.


Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.3
diff -c -p -r2.3 tree-ssa-dom.c
*** tree-ssa-dom.c	14 May 2004 17:51:03 -0000	2.3
--- tree-ssa-dom.c	15 May 2004 06:18:55 -0000
*************** set_value_for (tree var, tree value, var
*** 312,323 ****
  static void
  redirect_edges_and_update_ssa_graph (varray_type redirection_edges)
  {
!   basic_block tgt;
    unsigned int i;
    size_t old_num_referenced_vars = num_referenced_vars;
  
    /* First note any variables which we are going to have to take
!      out of SSA form.  */
    for (i = 0; i < VARRAY_ACTIVE_SIZE (redirection_edges); i += 2)
      {
        block_stmt_iterator bsi;
--- 312,325 ----
  static void
  redirect_edges_and_update_ssa_graph (varray_type redirection_edges)
  {
!   basic_block tgt, bb;
!   tree phi;
    unsigned int i;
    size_t old_num_referenced_vars = num_referenced_vars;
+   bitmap virtuals_to_rename = BITMAP_XMALLOC ();
  
    /* First note any variables which we are going to have to take
!      out of SSA form as well as any virtuals which need updating.  */
    for (i = 0; i < VARRAY_ACTIVE_SIZE (redirection_edges); i += 2)
      {
        block_stmt_iterator bsi;
*************** redirect_edges_and_update_ssa_graph (var
*** 333,339 ****
        for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree result = SSA_NAME_VAR (PHI_RESULT (phi));
! 	  bitmap_set_bit (vars_to_rename, var_ann (result)->uid);
          }
  
        /* Any variables set by statements at the start of the block we
--- 335,345 ----
        for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree result = SSA_NAME_VAR (PHI_RESULT (phi));
! 
! 	  if (is_gimple_reg (PHI_RESULT (phi)))
! 	    bitmap_set_bit (vars_to_rename, var_ann (result)->uid);
! 	  else
! 	    bitmap_set_bit (virtuals_to_rename, var_ann (result)->uid);
          }
  
        /* Any variables set by statements at the start of the block we
*************** redirect_edges_and_update_ssa_graph (var
*** 362,368 ****
  	  for (j = 0; j < NUM_VDEFS (vdefs); j++)
  	    {
  	      tree op = VDEF_RESULT (vdefs, j);
! 	      bitmap_set_bit (vars_to_rename, var_ann (op)->uid);
  	    }
  	}
  
--- 368,374 ----
  	  for (j = 0; j < NUM_VDEFS (vdefs); j++)
  	    {
  	      tree op = VDEF_RESULT (vdefs, j);
! 	      bitmap_set_bit (virtuals_to_rename, var_ann (op)->uid);
  	    }
  	}
  
*************** redirect_edges_and_update_ssa_graph (var
*** 371,390 ****
        for (phi = phi_nodes (tgt); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree result = SSA_NAME_VAR (PHI_RESULT (phi));
- 	  int j;
- 
- 	  bitmap_set_bit (vars_to_rename, var_ann (result)->uid);
- 
- 	  for (j = 0; j < PHI_NUM_ARGS (phi); j++)
- 	    {
- 	      tree arg = PHI_ARG_DEF (phi, j);
  
! 	      if (TREE_CODE (arg) != SSA_NAME)
! 		continue;
! 
! 	      arg = SSA_NAME_VAR (arg);
! 	      bitmap_set_bit (vars_to_rename, var_ann (arg)->uid);
! 	    }
          }
      }
  
--- 377,387 ----
        for (phi = phi_nodes (tgt); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree result = SSA_NAME_VAR (PHI_RESULT (phi));
  
! 	  if (is_gimple_reg (PHI_RESULT (phi)))
! 	    bitmap_set_bit (vars_to_rename, var_ann (result)->uid);
! 	  else
! 	    bitmap_set_bit (virtuals_to_rename, var_ann (result)->uid);
          }
      }
  
*************** redirect_edges_and_update_ssa_graph (var
*** 497,502 ****
--- 494,521 ----
        bitmap_set_bit (vars_to_rename, i);
        var_ann (referenced_var (i))->out_of_ssa_tag = 0;
      }
+ 
+   bitmap_a_or_b (vars_to_rename, vars_to_rename, virtuals_to_rename);
+ 
+   /* We must remove any PHIs for virtual variables that we are going to
+      re-rename.  Hopefully we'll be able to simply update these incrementally
+      soon.  */
+   FOR_EACH_BB (bb)
+     {
+       tree next;
+ 
+       for (phi = phi_nodes (bb); phi; phi = next)
+ 	{
+ 	  tree result = PHI_RESULT (phi);
+ 
+ 	  next = TREE_CHAIN (phi);
+ 
+ 	  if (bitmap_bit_p (virtuals_to_rename,
+ 			    var_ann (SSA_NAME_VAR (result))->uid))
+ 	    remove_phi_node (phi, NULL, bb);
+ 	}
+     }
+   BITMAP_XFREE (virtuals_to_rename);
  }
  
  /* Jump threading, redundancy elimination and const/copy propagation. 



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