summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-04 20:09:25 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-04 20:09:25 +0000
commitcf024d2253f999eeeaf8c7185f83320f03cef3ef (patch)
treead9cd6b26ccb8f5631c14579e9c4b7fc9941c67e
parent3e38f533e66073c47d86762df861c327061ddcf9 (diff)
downloadgcc-cf024d2253f999eeeaf8c7185f83320f03cef3ef.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106503 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/doc/invoke.texi3
-rw-r--r--gcc/params.def18
-rw-r--r--gcc/tree-ssa-dom.c16
5 files changed, 48 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b7c1bb9a665..9bf6a7ca3e4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index db66fbc95e1..8bba4e097b4 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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 \
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index eda329a7684..5662786911a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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
diff --git a/gcc/params.def b/gcc/params.def
index f808682a06f..f0740a9d00f 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -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
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index b37df7797f8..cb5eeb03a2f 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -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