Compile-time improvement for 26854 -- 4.1 branch version

Jeffrey A Law law@redhat.com
Wed Apr 19 22:35:00 GMT 2006


This patch takes DOM off the radar as far as compile-time is
concerned for this PR.  num_imm_uses actually walks the list of
immediate uses and increments a counter -- so it's a horrible
way to determine if we have 0 or 1 uses (for which we have special
functions).

In 26854, DOM was spending the vast majority if its time counting
immediate uses, believe it or not.  This patch takes DOM's time from
~250 seconds to ~5 on my x86 box.  However, to make real progress on
this PR someone is going to have to dive into the memory issues in
other passes (it takes ~9hrs to compile on my x86 box due to extreme
swapping).

I found and fixed similar code in DSE, but it's not hit enough to
trigger any compile-time issues.  

This patch is for the 4.1 branch; a similar, but slightly different
patch will be necessary for mainline.

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


-------------- next part --------------
        PR tree-optimization/26854
	* tree-ssa-dse.c (dse_optimize_stmt): Use has_single_use rather
	than num_imm_uses.
	* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Similarly.

Index: tree-ssa-dse.c
===================================================================
*** tree-ssa-dse.c	(revision 113077)
--- tree-ssa-dse.c	(working copy)
*************** dse_optimize_stmt (struct dom_walk_data 
*** 269,275 ****
  
  	  /* If this virtual def does not have precisely one use, then
  	     we will not be able to eliminate STMT.  */
! 	  if (num_imm_uses (defvar) != 1)
  	    {
  	      fail = true;
  	      break;
--- 269,275 ----
  
  	  /* If this virtual def does not have precisely one use, then
  	     we will not be able to eliminate STMT.  */
! 	  if (! has_single_use (defvar))
  	    {
  	      fail = true;
  	      break;
Index: tree-ssa-dom.c
===================================================================
*** tree-ssa-dom.c	(revision 113077)
--- tree-ssa-dom.c	(working copy)
*************** simplify_rhs_and_lookup_avail_expr (tree
*** 1794,1800 ****
       assignment.  Add minus to this, as we handle it specially below.  */
    if ((associative_tree_code (rhs_code) || rhs_code == MINUS_EXPR)
        && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
!       && num_imm_uses (TREE_OPERAND (rhs, 0)) == 1
        && is_gimple_min_invariant (TREE_OPERAND (rhs, 1)))
      {
        tree rhs_def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0));
--- 1794,1800 ----
       assignment.  Add minus to this, as we handle it specially below.  */
    if ((associative_tree_code (rhs_code) || rhs_code == MINUS_EXPR)
        && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
!       && has_single_use (TREE_OPERAND (rhs, 0))
        && is_gimple_min_invariant (TREE_OPERAND (rhs, 1)))
      {
        tree rhs_def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0));


More information about the Gcc-patches mailing list