diff options
author | Jeff Law <law@redhat.com> | 2015-10-29 10:20:06 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2015-10-29 10:20:06 -0600 |
commit | 21f0717ab16fe725e887536f5f90b7487b6431cd (patch) | |
tree | cbe77223cf0c65aa5396de518c330072d3fd1143 /gcc/tree-ssa-threadedge.c | |
parent | 3ddb720ebfccb2c64d731cd841ce3388e87abf55 (diff) | |
download | gcc-21f0717ab16fe725e887536f5f90b7487b6431cd.zip gcc-21f0717ab16fe725e887536f5f90b7487b6431cd.tar.gz gcc-21f0717ab16fe725e887536f5f90b7487b6431cd.tar.bz2 |
[PATCH][PR tree-optimization/67892] Use FSM threader to handle backedges
PR tree-optimization/67892
* tree-ssa-threadedge.c (simplify_controL_stmt_condition): Fix typo
in comment.
(thread_through_normal_block): If we have seen a backedge, then
do nothing. No longer call find_jump_threads_backwards here.
(thread_across_edge): Use find_jump_threads_backwards to find
jump threads if the old style threader was not successful.
* tree-ssa-threadbackward.c (get_gimple_control_stmt): Use
gsi_last_nondebug_bb. Return NULL if the block does not end
with a control statement.
(find_jump_threads_backwards): Setup code moved here from
tree-ssa-threadedge.c::thread_through_normal_block. Accept
single edge argument instead of name & block.
* tree-ssa-threadbackward.h (find_jump_threads_backwards): Update
prototype.
PR tree-optimization/67892
* gcc.dg/tree-ssa/pr21417: Update expected output.
* gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Likewise.
From-SVN: r229538
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 386aea7..ddd5061 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -566,7 +566,7 @@ simplify_control_stmt_condition (edge e, It is possible to get loops in the SSA_NAME_VALUE chains (consider threading the backedge of a loop where we have - a loop invariant SSA_NAME used in the condition. */ + a loop invariant SSA_NAME used in the condition). */ if (cached_lhs) { for (int i = 0; i < 2; i++) @@ -904,12 +904,10 @@ thread_through_normal_block (edge e, bitmap visited, bool *backedge_seen_p) { - /* If we have traversed a backedge, then we do not want to look - at certain expressions in the table that can not be relied upon. - Luckily the only code that looked at those expressions is the - SIMPLIFY callback, which we replace if we can no longer use it. */ + /* If we have seen a backedge, then we rely solely on the FSM threader + to find jump threads. */ if (*backedge_seen_p) - simplify = dummy_simplify; + return 0; /* We want to record any equivalences created by traversing E. */ if (!handle_dominating_asserts) @@ -1019,26 +1017,6 @@ thread_through_normal_block (edge e, backedge_seen_p); return 1; } - - if (!flag_expensive_optimizations - || optimize_function_for_size_p (cfun) - || !(TREE_CODE (cond) == SSA_NAME - || (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison - && TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME - && TREE_CODE (TREE_OPERAND (cond, 1)) == INTEGER_CST)) - || e->dest->loop_father != e->src->loop_father - || loop_depth (e->dest->loop_father) == 0) - return 0; - - /* Extract the SSA_NAME we want to trace backwards if COND is not - already a bare SSA_NAME. */ - if (TREE_CODE (cond) != SSA_NAME) - cond = TREE_OPERAND (cond, 0); - - /* When COND cannot be simplified, try to find paths from a control - statement back through the PHI nodes which would affect that control - statement. */ - find_jump_threads_backwards (cond, e->dest); } return 0; } @@ -1118,6 +1096,8 @@ thread_across_edge (gcond *dummy_cond, path->release (); delete path; + find_jump_threads_backwards (e); + /* A negative status indicates the target block was deemed too big to duplicate. Just quit now rather than trying to use the block as a joiner in a jump threading path. @@ -1217,6 +1197,7 @@ thread_across_edge (gcond *dummy_cond, } else { + find_jump_threads_backwards (path->last ()->e); delete_jump_thread_path (path); } |