This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Generalize thread_through_normal_block
- From: Jeff Law <law at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 14 Nov 2013 11:05:51 -0700
- Subject: [PATCH] Generalize thread_through_normal_block
- Authentication-results: sourceware.org; auth=none
As part of the generalized FSA optimization work we need the ability to
start a jump threading path with a joiner, then later in the path have a
normal jump threading block (ie, has side effects and thus requires
duplication).
thread_through_normal_block needs one tweak to make that possible.
Namely it should only push the EDGE_START_JUMP_THREAD marker if the jump
threading path is currently empty.
Right now we don't call thread_through_normal_block after we've
processed a joiner block, but we will soon :-) So at least today, this
patch has no impact on the code we generate.
Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
Installed on the trunk.
* tree-ssa-threadedge.c (thread_through_normal_block): Only push
the EDGE_START_JUMP_THREAD marker if the jump threading path is
empty.
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index c9b2c69..cabfc82 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -940,12 +940,18 @@ thread_through_normal_block (edge e,
|| bitmap_bit_p (visited, dest->index))
return false;
- jump_thread_edge *x
- = new jump_thread_edge (e, EDGE_START_JUMP_THREAD);
- path->safe_push (x);
- *backedge_seen_p |= ((e->flags & EDGE_DFS_BACK) != 0);
+ /* Only push the EDGE_START_JUMP_THREAD marker if this is
+ first edge on the path. */
+ if (path->length () == 0)
+ {
+ jump_thread_edge *x
+ = new jump_thread_edge (e, EDGE_START_JUMP_THREAD);
+ path->safe_push (x);
+ *backedge_seen_p |= ((e->flags & EDGE_DFS_BACK) != 0);
+ }
- x = new jump_thread_edge (taken_edge, EDGE_COPY_SRC_BLOCK);
+ jump_thread_edge *x
+ = new jump_thread_edge (taken_edge, EDGE_COPY_SRC_BLOCK);
path->safe_push (x);
*backedge_seen_p |= ((taken_edge->flags & EDGE_DFS_BACK) != 0);
@@ -953,7 +959,7 @@ thread_through_normal_block (edge e,
secondary effects of threading without having to re-run DOM or
VRP. */
if (!*backedge_seen_p
- || ! cond_arg_set_in_bb (taken_edge, e->dest))
+ || ! cond_arg_set_in_bb (taken_edge, e->dest))
{
/* We don't want to thread back to a block we have already
visited. This may be overly conservative. */