OSDN Git Service

* doc/invoke.texi: Document max-jump-thread-duplication-stmts PARAM.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Nov 2005 20:09:25 +0000 (20:09 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Nov 2005 20:09:25 +0000 (20:09 +0000)
* tree-ssa-dom.c: Include params.h.
(thread_across_edge): If there are too many statements in the
target block, then do not thread through it.
* Makefile.in (tree-ssa-dom.o): Depend on $(PARAMS_H).
* params.def (PARAM_MAX_JUMP_THREAD_DUPLICATION_STMTS): New PARAM.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106503 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/doc/invoke.texi
gcc/params.def
gcc/tree-ssa-dom.c

index b7c1bb9..9bf6a7c 100644 (file)
@@ -1,3 +1,13 @@
+2005-10-04  Jeff Law  <law@redhat.com>
+
+       PR/21883
+       * doc/invoke.texi: Document max-jump-thread-duplication-stmts PARAM.
+       * tree-ssa-dom.c: Include params.h.
+       (thread_across_edge): If there are too many statements in the
+       target block, then do not thread through it.
+       * Makefile.in (tree-ssa-dom.o): Depend on $(PARAMS_H).
+       * params.def (PARAM_MAX_JUMP_THREAD_DUPLICATION_STMTS): New PARAM.
+
 2005-11-03  Diego Novillo  <dnovillo@redhat.com>
 
        PR 24627
index db66fbc..8bba4e0 100644 (file)
@@ -1791,7 +1791,7 @@ tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h $(DIAGNOSTIC_H) \
    function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
    $(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h $(FLAGS_H) langhooks.h \
-   tree-ssa-propagate.h $(CFGLOOP_H)
+   tree-ssa-propagate.h $(CFGLOOP_H) $(PARAMS_H)
 tree-ssa-uncprop.o : tree-ssa-uncprop.c $(TREE_FLOW_H) $(CONFIG_H) \
    $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \
    $(DIAGNOSTIC_H) function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
index eda329a..5662786 100644 (file)
@@ -6085,6 +6085,9 @@ ratio is 3.
 The minimum size of buffers (i.e. arrays) that will receive stack smashing
 protection when @option{-fstack-protection} is used.
 
+@item max-jump-thread-duplication-stmts
+Maximum number of statements allowed in a block that needs to be
+duplicated when threading jumps.
 @end table
 @end table
 
index f808682..f0740a9 100644 (file)
@@ -506,6 +506,24 @@ DEFPARAM (PARAM_SSP_BUFFER_SIZE,
          "The lower bound for a buffer to be considered for stack smashing protection",
          8, 1, 0)
 
+/* When we thread through a block we have to make copies of the
+   statements within the block.  Clearly for large blocks the code
+   duplication is bad.
+
+   PARAM_MAX_JUMP_THREAD_DUPLICATION_STMTS specifies the maximum number
+   of statements and PHI nodes allowed in a block which is going to
+   be duplicated for thread jumping purposes.
+
+   Some simple analysis showed that more than 99% of the jump
+   threading opportunities are for blocks with less than 15
+   statements.  So we can get the benefits of jump threading
+   without excessive code bloat for pathological cases with the
+   throttle set at 15 statements.  */
+DEFPARAM (PARAM_MAX_JUMP_THREAD_DUPLICATION_STMTS,
+         "max-jump-thread-duplication-stmts",
+          "Maximum number of statements allowed in a block that needs to be duplicated when threading jumps",
+         15, 0, 0)
+   
 /*
 Local variables:
 mode:c
index b37df77..cb5eeb0 100644 (file)
@@ -42,6 +42,7 @@ Boston, MA 02110-1301, USA.  */
 #include "tree-pass.h"
 #include "tree-ssa-propagate.h"
 #include "langhooks.h"
+#include "params.h"
 
 /* This file implements optimizations on the dominator tree.  */
 
@@ -608,6 +609,9 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
   block_stmt_iterator bsi;
   tree stmt = NULL;
   tree phi;
+  int stmt_count = 0;
+  int max_stmt_count;
+
 
   /* If E->dest does not end with a conditional, then there is
      nothing to do.  */
@@ -637,6 +641,11 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
       tree src = PHI_ARG_DEF_FROM_EDGE (phi, e);
       tree dst = PHI_RESULT (phi);
 
+      /* Do not include virtual PHIs in our statement count as
+        they never generate code.  */
+      if (is_gimple_reg (dst))
+       stmt_count++;
+
       /* If the desired argument is not the same as this PHI's result 
         and it is set by a PHI in E->dest, then we can not thread
         through E->dest.  */
@@ -664,6 +673,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
      Failure to simplify into the form above merely means that the
      statement provides no equivalences to help simplify later
      statements.  This does not prevent threading through E->dest.  */
+  max_stmt_count = PARAM_VALUE (PARAM_MAX_JUMP_THREAD_DUPLICATION_STMTS);
   for (bsi = bsi_start (e->dest); ! bsi_end_p (bsi); bsi_next (&bsi))
     {
       tree cached_lhs = NULL;
@@ -674,6 +684,12 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
       if (IS_EMPTY_STMT (stmt) || TREE_CODE (stmt) == LABEL_EXPR)
        continue;
 
+      /* If duplicating this block is going to cause too much code
+        expansion, then do not thread through this block.  */
+      stmt_count++;
+      if (stmt_count > max_stmt_count)
+       return;
+
       /* Safely handle threading across loop backedges.  This is
         over conservative, but still allows us to capture the
         majority of the cases where we can thread across a loop