aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-threadupdate.c
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2021-09-11 17:33:25 +0200
committerAldy Hernandez <aldyh@redhat.com>2021-09-13 16:34:48 +0200
commitc7a669af0aeb639eb78f1614cbecb72a98d81ce8 (patch)
treea696301076a76ac2f3a927db342d94b700b0ff33 /gcc/tree-ssa-threadupdate.c
parentc8b2b89358481d36755dbc99e585a251780453b0 (diff)
downloadgcc-c7a669af0aeb639eb78f1614cbecb72a98d81ce8.zip
gcc-c7a669af0aeb639eb78f1614cbecb72a98d81ce8.tar.gz
gcc-c7a669af0aeb639eb78f1614cbecb72a98d81ce8.tar.bz2
Remove references to FSM threads.
Now that the jump thread back registry has been split into the generic copier and the custom (old) copier, it becomes trivial to remove the FSM bits from the jump threaders. First, there's no need for an EDGE_FSM_THREAD type. The only reason we were looking at the threading type was to determine what type of copier to use, and now that the copier has been split, there's no need to even look. However, there is one check in register_jump_thread where we verify that only the generic copier can thread through back-edges. I've removed that check in favor of a flag passed to the constructor. I've also removed all the FSM references from the code and tests. Interestingly, some tests weren't even testing the right thing. They were testing for "FSM" which would catch jump thread paths as well as the backward threader *failing* on registering a path. *big eye roll* The only remaining code that was actually checking for EDGE_FSM_THREAD was adjust_paths_after_duplication, and the checks could be written without looking at the edge type at all. For the record, the code there is horrible: it's convoluted, hard to read, and doesn't have any tests. I'd smack myself if I could go back in time. All that remains are the FSM references in the --param's themselves. I think we should s/fsm/threader/, since I envision a day when we can share the cost basis code between the threaders. However, I don't know what the proper procedure is for renaming existing compiler options. By the way, param_fsm_maximum_phi_arguments is no longer relevant after the rewrite. We can nuke that one right away. Tested on x86-64 Linux. gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader_profitability::profitable_path_p): Remove FSM references. (back_threader_registry::register_path): Same. * tree-ssa-threadedge.c (jump_threader::simplify_control_stmt_condition): Same. * tree-ssa-threadupdate.c (jt_path_registry::jt_path_registry): Add backedge_threads argument. (fwd_jt_path_registry::fwd_jt_path_registry): Pass backedge_threads argument. (back_jt_path_registry::back_jt_path_registry): Same. (dump_jump_thread_path): Adjust for FSM removal. (back_jt_path_registry::rewire_first_differing_edge): Same. (back_jt_path_registry::adjust_paths_after_duplication): Same. (back_jt_path_registry::update_cfg): Same. (jt_path_registry::register_jump_thread): Same. * tree-ssa-threadupdate.h (enum jump_thread_edge_type): Remove EDGE_FSM_THREAD. (class back_jt_path_registry): Add backedge_threads to constructor. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr21417.c: Adjust for FSM removal. * gcc.dg/tree-ssa/pr66752-3.c: Same. * gcc.dg/tree-ssa/pr68198.c: Same. * gcc.dg/tree-ssa/pr69196-1.c: Same. * gcc.dg/tree-ssa/pr70232.c: Same. * gcc.dg/tree-ssa/pr77445.c: Same. * gcc.dg/tree-ssa/ranger-threader-4.c: Same. * gcc.dg/tree-ssa/ssa-dom-thread-18.c: Same. * gcc.dg/tree-ssa/ssa-dom-thread-6.c: Same. * gcc.dg/tree-ssa/ssa-thread-12.c: Same. * gcc.dg/tree-ssa/ssa-thread-13.c: Same.
Diffstat (limited to 'gcc/tree-ssa-threadupdate.c')
-rw-r--r--gcc/tree-ssa-threadupdate.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 9353810..c5a7423 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -167,10 +167,11 @@ jump_thread_path_allocator::allocate_thread_path ()
return new (r) vec<jump_thread_edge *> ();
}
-jt_path_registry::jt_path_registry ()
+jt_path_registry::jt_path_registry (bool backedge_threads)
{
m_paths.create (5);
m_num_threaded_edges = 0;
+ m_backedge_threads = backedge_threads;
}
jt_path_registry::~jt_path_registry ()
@@ -179,6 +180,7 @@ jt_path_registry::~jt_path_registry ()
}
fwd_jt_path_registry::fwd_jt_path_registry ()
+ : jt_path_registry (/*backedge_threads=*/false)
{
m_removed_edges = new hash_table<struct removed_edges> (17);
m_redirection_data = NULL;
@@ -189,6 +191,11 @@ fwd_jt_path_registry::~fwd_jt_path_registry ()
delete m_removed_edges;
}
+back_jt_path_registry::back_jt_path_registry ()
+ : jt_path_registry (/*backedge_threads=*/true)
+{
+}
+
jump_thread_edge *
jt_path_registry::allocate_thread_edge (edge e, jump_thread_edge_type t)
{
@@ -210,9 +217,8 @@ dump_jump_thread_path (FILE *dump_file,
bool registering)
{
fprintf (dump_file,
- " %s%s jump thread: (%d, %d) incoming edge; ",
+ " %s jump thread: (%d, %d) incoming edge; ",
(registering ? "Registering" : "Cancelling"),
- (path[0]->type == EDGE_FSM_THREAD ? " FSM": ""),
path[0]->e->src->index, path[0]->e->dest->index);
for (unsigned int i = 1; i < path.length (); i++)
@@ -224,20 +230,24 @@ dump_jump_thread_path (FILE *dump_file,
if (path[i]->e == NULL)
continue;
- if (path[i]->type == EDGE_COPY_SRC_JOINER_BLOCK)
- fprintf (dump_file, " (%d, %d) joiner; ",
- path[i]->e->src->index, path[i]->e->dest->index);
- if (path[i]->type == EDGE_COPY_SRC_BLOCK)
- fprintf (dump_file, " (%d, %d) normal;",
- path[i]->e->src->index, path[i]->e->dest->index);
- if (path[i]->type == EDGE_NO_COPY_SRC_BLOCK)
- fprintf (dump_file, " (%d, %d) nocopy;",
- path[i]->e->src->index, path[i]->e->dest->index);
- if (path[0]->type == EDGE_FSM_THREAD)
- fprintf (dump_file, " (%d, %d) ",
- path[i]->e->src->index, path[i]->e->dest->index);
+ fprintf (dump_file, " (%d, %d) ",
+ path[i]->e->src->index, path[i]->e->dest->index);
+ switch (path[i]->type)
+ {
+ case EDGE_COPY_SRC_JOINER_BLOCK:
+ fprintf (dump_file, "joiner");
+ break;
+ case EDGE_COPY_SRC_BLOCK:
+ fprintf (dump_file, "normal");
+ break;
+ case EDGE_NO_COPY_SRC_BLOCK:
+ fprintf (dump_file, "nocopy");
+ break;
+ default:
+ gcc_unreachable ();
+ }
}
- fputc ('\n', dump_file);
+ fprintf (dump_file, "; \n");
}
DEBUG_FUNCTION void
@@ -2256,8 +2266,8 @@ back_jt_path_registry::rewire_first_differing_edge (unsigned path_num,
return true;
}
-/* After an FSM path has been jump threaded, adjust the remaining FSM
- paths that are subsets of this path, so these paths can be safely
+/* After a path has been jump threaded, adjust the remaining paths
+ that are subsets of this path, so these paths can be safely
threaded within the context of the new threaded path.
For example, suppose we have just threaded:
@@ -2293,10 +2303,9 @@ back_jt_path_registry::adjust_paths_after_duplication (unsigned curr_path_num)
continue;
}
/* Make sure the candidate to adjust starts with the same path
- as the recently threaded path and is an FSM thread. */
+ as the recently threaded path. */
vec<jump_thread_edge *> *cand_path = m_paths[cand_path_num];
- if ((*cand_path)[0]->type != EDGE_FSM_THREAD
- || (*cand_path)[0]->e != (*curr_path)[0]->e)
+ if ((*cand_path)[0]->e != (*curr_path)[0]->e)
{
++cand_path_num;
continue;
@@ -2350,16 +2359,11 @@ back_jt_path_registry::adjust_paths_after_duplication (unsigned curr_path_num)
m_paths.unordered_remove (cand_path_num);
continue;
}
- if ((*cand_path)[j]->type != EDGE_FSM_THREAD)
- {
- /* If all the EDGE_FSM_THREADs are common, all that's
- left is the final EDGE_NO_COPY_SRC_BLOCK. */
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "Dropping illformed candidate.\n");
- }
- else
- /* Otherwise, just remove the redundant sub-path. */
+ /* Otherwise, just remove the redundant sub-path. */
+ if (cand_path->length () - j > 1)
cand_path->block_remove (0, j);
+ else if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Dropping illformed candidate.\n");
}
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -2616,8 +2620,6 @@ back_jt_path_registry::update_cfg (bool /*peel_loop_headers*/)
vec<jump_thread_edge *> *path = m_paths[0];
edge entry = (*path)[0]->e;
- gcc_checking_assert ((*path)[0]->type == EDGE_FSM_THREAD);
-
/* Do not jump-thread twice from the same starting edge.
Previously we only checked that we weren't threading twice
@@ -2631,7 +2633,7 @@ back_jt_path_registry::update_cfg (bool /*peel_loop_headers*/)
various reasons. So check it first. */
|| !valid_jump_thread_path (path))
{
- /* Remove invalid FSM jump-thread paths. */
+ /* Remove invalid jump-thread paths. */
cancel_thread (path, "Avoiding threading twice from same edge");
m_paths.unordered_remove (0);
continue;
@@ -2782,10 +2784,7 @@ jt_path_registry::register_jump_thread (vec<jump_thread_edge *> *path)
return false;
}
- /* Only the FSM threader is allowed to thread across
- backedges in the CFG. */
- if (flag_checking
- && (*path)[0]->type != EDGE_FSM_THREAD)
+ if (flag_checking && !m_backedge_threads)
gcc_assert (((*path)[i]->e->flags & EDGE_DFS_BACK) == 0);
}