summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-threadedge.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-11 02:23:48 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-11 02:23:48 +0000
commitbb66e2d1a9c19408a43f6648e93f329187716115 (patch)
tree2477817e3acba588af69e3d3c3b9166d7e6d8757 /gcc/tree-ssa-threadedge.c
parent2475874780d76c5ee3adcec03b18602b2c58381b (diff)
downloadgcc-bb66e2d1a9c19408a43f6648e93f329187716115.tar.gz
PR tree-optimization/58380
* tree-ssa-threadupdate.c (thread_block): Recognize another case of threading through a buried loop header. * tree-ssa-threadedge.c (thread_around_empty_blocks): Correct return value for single successor case. * g++.dg/torture/pr58380.C: New test. 2013-09-10 Jeff Law <law@redhat.com> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202489 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r--gcc/tree-ssa-threadedge.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 14bc4e37329..839f1859c1d 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -770,7 +770,19 @@ thread_around_empty_blocks (edge taken_edge,
gsi = gsi_start_nondebug_bb (bb);
/* If the block has no statements, but does have a single successor, then
- it's just a forwarding block and we can thread through it trivially. */
+ it's just a forwarding block and we can thread through it trivially.
+
+ However, note that just threading through empty blocks with single
+ successors is not inherently profitable. For the jump thread to
+ be profitable, we must avoid a runtime conditional.
+
+ By taking the return value from the recursive call, we get the
+ desired effect of returning TRUE when we found a profitable jump
+ threading opportunity and FALSE otherwise.
+
+ This is particularly important when this routine is called after
+ processing a joiner block. Returning TRUE too aggressively in
+ that case results in pointless duplication of the joiner block. */
if (gsi_end_p (gsi))
{
if (single_succ_p (bb))
@@ -781,15 +793,16 @@ thread_around_empty_blocks (edge taken_edge,
{
bitmap_set_bit (visited, taken_edge->dest->index);
path->safe_push (taken_edge);
- thread_around_empty_blocks (taken_edge,
- dummy_cond,
- handle_dominating_asserts,
- simplify,
- visited,
- path);
- return true;
+ return thread_around_empty_blocks (taken_edge,
+ dummy_cond,
+ handle_dominating_asserts,
+ simplify,
+ visited,
+ path);
}
}
+
+ /* We have a block with no statements, but multiple successors? */
return false;
}