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]

Minor memory usage reduction in DOM


DOM was keeping a per-block varray of statements which needed to be
rescanned for new operands when it could just as easily keep a single
varray of statements to rescan for operands on a global basis.

By making this change we generate ~5k fewer varrays for Gerald's
favorite testcase and reduce the amount of memory we allocate
by a couple hundred K.  Nothing spectacular.

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

	* tree-ssa-dom.c (stmts_to_rescan): Move from a block-local
	to a global varray.  
	(tree_ssa_dominator_optimize): Allocate stmts_to_rescan.
	(dom_opt_initialize_block_local_data): No longer test state
	of stmts_to_rescan.
	(dom_opt_finalize_block): Update due to change in scope of
	stmts_to_rescan.
	(optimize_stmt): Similarly.
	
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.37
diff -c -p -r2.37 tree-ssa-dom.c
*** tree-ssa-dom.c	9 Sep 2004 07:54:12 -0000	2.37
--- tree-ssa-dom.c	14 Sep 2004 15:10:00 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 53,58 ****
--- 53,67 ----
     in this table.  */
  static htab_t avail_exprs;
  
+ /* Stack of statements we need to rescan during finalization for newly
+    exposed variables.
+ 
+    Statement rescanning must occur after the current block's available
+    expressions are removed from AVAIL_EXPRS.  Else we may change the
+    hash code for an expression and be unable to find/remove it from
+    AVAIL_EXPRS.  */
+ varray_type stmts_to_rescan;
+ 
  /* Structure for entries in the expression hash table.
  
     This requires more memory for the hash table entries, but allows us
*************** struct dom_walk_block_data
*** 185,194 ****
       restored during finalization.  */
    varray_type nonzero_vars;
  
-   /* Array of statements we need to rescan during finalization for
newly
-      exposed variables.  */
-   varray_type stmts_to_rescan;
- 
    /* Array of variables which have their values constrained by
operations
       in this basic block.  We use this during finalization to know
       which variables need their VRP data updated.  */
--- 194,199 ----
*************** tree_ssa_dominator_optimize (void)
*** 313,318 ****
--- 318,324 ----
    nonzero_vars = BITMAP_XMALLOC ();
    VARRAY_GENERIC_PTR_INIT (vrp_data, num_ssa_names, "vrp_data");
    need_eh_cleanup = BITMAP_XMALLOC ();
+   VARRAY_TREE_INIT (stmts_to_rescan, 20, "Statements to rescan");
  
    /* Setup callbacks for the generic dominator tree walker.  */
    walk_data.walk_stmts_backward = false;
*************** dom_opt_initialize_block_local_data (str
*** 730,737 ****
  		  || VARRAY_ACTIVE_SIZE (bd->const_and_copies) == 0);
        gcc_assert (!bd->nonzero_vars
  		  || VARRAY_ACTIVE_SIZE (bd->nonzero_vars) == 0);
-       gcc_assert (!bd->stmts_to_rescan
- 		  || VARRAY_ACTIVE_SIZE (bd->stmts_to_rescan) == 0);
        gcc_assert (!bd->vrp_variables
  		  || VARRAY_ACTIVE_SIZE (bd->vrp_variables) == 0);
        gcc_assert (!bd->block_defs
--- 736,741 ----
*************** dom_opt_finalize_block (struct dom_walk_
*** 1046,1057 ****
        VARRAY_POP (bd->vrp_variables);
      }
  
!   /* Re-scan operands in all statements that may have had new symbols
!      exposed.  */
!   while (bd->stmts_to_rescan && VARRAY_ACTIVE_SIZE
(bd->stmts_to_rescan) > 0)
      {
!       tree stmt = VARRAY_TOP_TREE (bd->stmts_to_rescan);
!       VARRAY_POP (bd->stmts_to_rescan);
        mark_new_vars_to_rename (stmt, vars_to_rename);
      }
  }
--- 1050,1066 ----
        VARRAY_POP (bd->vrp_variables);
      }
  
!   /* If we queued any statements to rescan in this block, then
!      go ahead and rescan them now.  */
!   while (VARRAY_ACTIVE_SIZE (stmts_to_rescan) > 0)
      {
!       tree stmt = VARRAY_TOP_TREE (stmts_to_rescan);
!       basic_block stmt_bb = bb_for_stmt (stmt);
! 
!       if (stmt_bb != bb)
! 	break;
! 
!       VARRAY_POP (stmts_to_rescan);
        mark_new_vars_to_rename (stmt, vars_to_rename);
      }
  }
*************** optimize_stmt (struct dom_walk_data *wal
*** 2850,2860 ****
      }
  
    if (may_have_exposed_new_symbols)
!     {
!       if (! bd->stmts_to_rescan)
! 	VARRAY_TREE_INIT (bd->stmts_to_rescan, 20, "stmts_to_rescan");
!       VARRAY_PUSH_TREE (bd->stmts_to_rescan, bsi_stmt (si));
!     }
  }
  
  /* Replace the RHS of STMT with NEW_RHS.  If RHS can be found in the
--- 2859,2865 ----
      }
  
    if (may_have_exposed_new_symbols)
!     VARRAY_PUSH_TREE (stmts_to_rescan, bsi_stmt (si));
  }
  
  /* Replace the RHS of STMT with NEW_RHS.  If RHS can be found in the



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