re PR rtl-optimization/18599 (Quadratic behavior in copyprop_hardreg_forward)
authorKazu Hirata <kazu@cs.umass.edu>
Mon, 22 Nov 2004 15:18:50 +0000 (15:18 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 22 Nov 2004 15:18:50 +0000 (15:18 +0000)
PR rtl-optimization/18599
* regrename.c (copyprop_hardreg_forward): Speed up by putting
BB_VISITED flags on basic blocks as we process them.

From-SVN: r91016

gcc/ChangeLog
gcc/regrename.c

index 0d6d39918d598e76967c420a330540f4190fcd50..86ea00b29ce5cc37fd91a54796958f4b108b7385 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-22  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR rtl-optimization/18599
+       * regrename.c (copyprop_hardreg_forward): Speed up by putting
+       BB_VISITED flags on basic blocks as we process them.
+
 2004-11-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        * config/rs6000/altivec.md (VI_char): New mode attribute.
index 3153e5c353f7ade7321b686efd02b850f5198b69..35f17a4d1d2af41739d3b15d415ba64c9ce3b708 100644 (file)
@@ -1745,24 +1745,31 @@ copyprop_hardreg_forward (void)
 {
   struct value_data *all_vd;
   bool need_refresh;
-  basic_block bb, bbp = 0;
+  basic_block bb;
 
   need_refresh = false;
 
   all_vd = xmalloc (sizeof (struct value_data) * last_basic_block);
 
+  /* Clear all BB_VISITED flags.  We use BB_VISITED flags to indicate
+     whether we have processed a given basic block or not.  Note that
+     we never put BB_VISITED flag on ENTRY_BLOCK_PTR throughout this
+     function because we want to call init_value_data for all
+     successors of ENTRY_BLOCK_PTR.  */
+  FOR_ALL_BB (bb)
+    bb->flags &= ~BB_VISITED;
+
   FOR_EACH_BB (bb)
     {
+      bb->flags |= BB_VISITED;
+
       /* If a block has a single predecessor, that we've already
         processed, begin with the value data that was live at
         the end of the predecessor block.  */
       /* ??? Ought to use more intelligent queuing of blocks.  */
-      if (EDGE_COUNT (bb->preds) == 1)
-       for (bbp = bb; bbp && bbp != EDGE_PRED (bb, 0)->src; bbp = bbp->prev_bb);
       if (EDGE_COUNT (bb->preds) == 1
-         && ! (EDGE_PRED (bb, 0)->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
-         && EDGE_PRED (bb, 0)->src != ENTRY_BLOCK_PTR
-         && bbp)
+         && ((EDGE_PRED (bb, 0)->src->flags & BB_VISITED) != 0)
+         && ! (EDGE_PRED (bb, 0)->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)))
        all_vd[bb->index] = all_vd[EDGE_PRED (bb, 0)->src->index];
       else
        init_value_data (all_vd + bb->index);
@@ -1771,6 +1778,12 @@ copyprop_hardreg_forward (void)
        need_refresh = true;
     }
 
+  /* Clear BB_VISITED flag on each basic block.  We do not need to
+     clear the one on ENTRY_BLOCK_PTR because it's already cleared
+     above.  */
+  FOR_EACH_BB (bb)
+    bb->flags &= ~BB_VISITED;
+
   if (need_refresh)
     {
       if (dump_file)