summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-07 10:50:16 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-07 10:50:16 +0000
commite82720956688455f69e90dad8dc861e8b00c3a51 (patch)
treeb29e66caf101d11bc66ce183e3614bd567fca32d
parentf5d2c4620d5a19a6b57e8ac9d2d4fdb0d3521322 (diff)
downloadgcc-e82720956688455f69e90dad8dc861e8b00c3a51.tar.gz
* tree-ssa-threadbackward.c: Include tree-inline.h
(profitable_jump_thread_path): Use estimate_num_insns to estimate size of copied block; for cold paths reduce duplication. (find_jump_threads_backwards): Remove redundant tests. (pass_thread_jumps::gate): Enable for -Os. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239219 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c4
-rw-r--r--gcc/tree-ssa-threadbackward.c36
4 files changed, 37 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8cd9f2aecfd..9f1caad8c02 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-08-07 Jan Hubicka <hubicka@ucw.cz>
+
+ * tree-ssa-threadbackward.c: Include tree-inline.h
+ (profitable_jump_thread_path): Use estimate_num_insns to estimate
+ size of copied block; for cold paths reduce duplication.
+ (find_jump_threads_backwards): Remove redundant tests.
+ (pass_thread_jumps::gate): Enable for -Os.
+
2016-08-07 Jakub Jelinek <jakub@redhat.com>
PR c/72816
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index edd4b1cab9f..fece69cab09 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-08-07 Jan Hubicka <hubicka@ucw.cz>
+
+ * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update testcase.
+
2016-08-07 Jakub Jelinek <jakub@redhat.com>
PR c/72816
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
index 7cd14510724..1a4089fcdfd 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-thread2-stats -fdump-tree-thread3-stats -fdump-tree-dom3-stats -fdump-tree-vrp2-stats" } */
+/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-thread2-stats -fdump-tree-thread3-stats -fdump-tree-dom3-stats -fdump-tree-vrp2-stats -fno-guess-branch-probability" } */
/* { dg-final { scan-tree-dump "Jumps threaded: 16" "thread1" } } */
-/* { dg-final { scan-tree-dump "Jumps threaded: 11" "thread2" } } */
+/* { dg-final { scan-tree-dump "Jumps threaded: 6" "thread2" } } */
/* { dg-final { scan-tree-dump "Jumps threaded: 3" "thread3" } } */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" } } */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "vrp2" } } */
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index 9dd37adf51c..234ce50d10c 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pass.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
+#include "tree-inline.h"
static int max_threaded_paths;
@@ -223,7 +224,7 @@ profitable_jump_thread_path (vec<basic_block, va_gc> *&path,
&& !(gimple_code (stmt) == GIMPLE_ASSIGN
&& gimple_assign_rhs_code (stmt) == ASSERT_EXPR)
&& !is_gimple_debug (stmt))
- ++n_insns;
+ n_insns += estimate_num_insns (stmt, &eni_size_weights);
}
/* We do not look at the block with the threaded branch
@@ -251,13 +252,15 @@ profitable_jump_thread_path (vec<basic_block, va_gc> *&path,
threaded_through_latch = true;
}
+ gimple *stmt = get_gimple_control_stmt ((*path)[0]);
+ gcc_assert (stmt);
+
/* We are going to remove the control statement at the end of the
last block in the threading path. So don't count it against our
statement count. */
- n_insns--;
- gimple *stmt = get_gimple_control_stmt ((*path)[0]);
- gcc_assert (stmt);
+ n_insns-= estimate_num_insns (stmt, &eni_size_weights);
+
/* We have found a constant value for ARG. For GIMPLE_SWITCH
and GIMPLE_GOTO, we use it as-is. However, for a GIMPLE_COND
we need to substitute, fold and simplify so we can determine
@@ -303,12 +306,24 @@ profitable_jump_thread_path (vec<basic_block, va_gc> *&path,
return NULL;
}
- if (n_insns >= PARAM_VALUE (PARAM_MAX_FSM_THREAD_PATH_INSNS))
+ if (optimize_edge_for_speed_p (taken_edge))
+ {
+ if (n_insns >= PARAM_VALUE (PARAM_MAX_FSM_THREAD_PATH_INSNS))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "FSM jump-thread path not considered: "
+ "the number of instructions on the path "
+ "exceeds PARAM_MAX_FSM_THREAD_PATH_INSNS.\n");
+ path->pop ();
+ return NULL;
+ }
+ }
+ else if (n_insns > 1)
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "FSM jump-thread path not considered: "
- "the number of instructions on the path "
- "exceeds PARAM_MAX_FSM_THREAD_PATH_INSNS.\n");
+ "duplication of %i insns is needed and optimizing for size.\n",
+ n_insns);
path->pop ();
return NULL;
}
@@ -612,10 +627,6 @@ fsm_find_control_statement_thread_paths (tree name,
void
find_jump_threads_backwards (basic_block bb)
{
- if (!flag_expensive_optimizations
- || optimize_function_for_size_p (cfun))
- return;
-
gimple *stmt = get_gimple_control_stmt (bb);
if (!stmt)
return;
@@ -680,8 +691,7 @@ public:
bool
pass_thread_jumps::gate (function *fun ATTRIBUTE_UNUSED)
{
- return (flag_expensive_optimizations
- && ! optimize_function_for_size_p (cfun));
+ return flag_expensive_optimizations;
}