aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-threadupdate.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2015-09-30 14:28:14 -0600
committerJeff Law <law@gcc.gnu.org>2015-09-30 14:28:14 -0600
commitd64f8dd280e6d2d70aec5b133e913b1af51832d9 (patch)
tree8a5d0ddc85f0e869a286b391f3deb283fd6db817 /gcc/tree-ssa-threadupdate.c
parent9702ee6a6f2086fffd543cdb785d0caac05e7fcc (diff)
downloadgcc-d64f8dd280e6d2d70aec5b133e913b1af51832d9.zip
gcc-d64f8dd280e6d2d70aec5b133e913b1af51832d9.tar.gz
gcc-d64f8dd280e6d2d70aec5b133e913b1af51832d9.tar.bz2
[PATCH] Improve DOM's optimization of control statements
* tree-ssa-dom.c (optimize_stmt): Collapse control flow statements with constant conditions. * tree-ssa-threadupdate.c (remove_jump_threads_starting_at): New. (remove_ctrl_stmt_and_useless_edges): No longer static. * tree-ssa-threadupdate.h (remove_jump_threads_starting_at): Prototype. (remove_ctrl_stmt_and_useless_edges): Likewise. * gcc.dg/tree-ssa/ssa-dom-branch-1.c: New test. From-SVN: r228306
Diffstat (limited to 'gcc/tree-ssa-threadupdate.c')
-rw-r--r--gcc/tree-ssa-threadupdate.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 6f21529..4a147bb 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -260,7 +260,7 @@ struct thread_stats_d thread_stats;
Also remove all outgoing edges except the edge which reaches DEST_BB.
If DEST_BB is NULL, then remove all outgoing edges. */
-static void
+void
remove_ctrl_stmt_and_useless_edges (basic_block bb, basic_block dest_bb)
{
gimple_stmt_iterator gsi;
@@ -2539,6 +2539,37 @@ valid_jump_thread_path (vec<jump_thread_edge *> *path)
return true;
}
+/* Remove any queued jump threads that start at BB. */
+
+void
+remove_jump_threads_starting_at (basic_block bb)
+{
+ if (!paths.exists ())
+ return;
+
+ for (unsigned i = 0; i < paths.length ();)
+ {
+ vec<jump_thread_edge *> *path = paths[i];
+
+ /* Sadly, FSM jump threads have a slightly different
+ representation than the rest of the jump threads. */
+ if ((*path)[0]->type == EDGE_FSM_THREAD
+ && (*path)[0]->e->src == bb)
+ {
+ delete_jump_thread_path (path);
+ paths.unordered_remove (i);
+ }
+ else if ((*path)[0]->type != EDGE_FSM_THREAD
+ && (*path)[0]->e->dest == bb)
+ {
+ delete_jump_thread_path (path);
+ paths.unordered_remove (i);
+ }
+ else
+ i++;
+ }
+}
+
/* Walk through all blocks and thread incoming edges to the appropriate
outgoing edge for each edge pair recorded in THREADED_EDGES.