aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-threadedge.cc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-08-17 13:18:01 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-08-18 16:38:00 +0200
commit011d0a033ab370ea38b06b813ac62be8dde0801b (patch)
treeb0abbeb3bea4d27cd333a9e07264c5f8511024a1 /gcc/tree-ssa-threadedge.cc
parentac68f904fe31baf80fa53218f1d8ee033bd8c79b (diff)
downloadgcc-011d0a033ab370ea38b06b813ac62be8dde0801b.zip
gcc-011d0a033ab370ea38b06b813ac62be8dde0801b.tar.gz
gcc-011d0a033ab370ea38b06b813ac62be8dde0801b.tar.bz2
Make path_range_query standalone and add reset_path.
These are a bunch of cleanups inspired by Richi's suggestion of making path_range_query standalone, instead of having to call compute_ranges() for each path. I've made the ranger need explicit, and moved the responsibility for its creation to the caller. I've also investigated and documented why the forward threader needs its own compute exit dependencies variant. I can't wait for it to go away :-/. I've also added constructors that take a path and dependencies, and made compute_ranges() private. Unfortunately, reinstantiating path_range_query in the forward threader caused a 14% performance regression in DOM, because the old threader calls it over and over on the same path to simplify statements (some of which not even in the IL, but that's old news). In the meantime, I've left the ability to reset a path, but this time appropriately called reset_path(). Tested, benchmarked, and thread counted on x86-64 Linux. gcc/ChangeLog: * gimple-range-path.cc (path_range_query::path_range_query): Add various constructors to take a path. (path_range_query::~path_range_query): Remove m_alloced_ranger. (path_range_query::range_on_path_entry): Adjust for m_ranger being a reference. (path_range_query::set_path): Rename to... (path_range_query::reset_path): ...this and call compute_ranges. (path_range_query::ssa_range_in_phi): Adjust for m_ranger reference. (path_range_query::range_defined_in_block): Same. (path_range_query::compute_ranges_in_block): Same. (path_range_query::adjust_for_non_null_uses): Same. (path_range_query::compute_exit_dependencies): Use m_path instead of argument. (path_range_query::compute_ranges): Remove path argument. (path_range_query::range_of_stmt): Adjust for m_ranger reference. (path_range_query::compute_outgoing_relations): Same. * gimple-range-path.h (class path_range_query): Add various constructors. Make compute_ranges and compute_exit_dependencies private. Rename set_path to reset_path. Make m_ranger a reference. Remove m_alloced_ranger. * tree-ssa-dom.cc (pass_dominator::execute): Adjust constructor to path_range_query. * tree-ssa-loop-ch.cc (entry_loop_condition_is_static): Take a ranger and instantiate a new path_range_query every time. (ch_base::copy_headers): Pass ranger instead of path_range_query. * tree-ssa-threadbackward.cc (class back_threader): Remove m_solver. (back_threader::~back_threader): Remove m_solver. (back_threader::find_taken_edge_switch): Adjust for m_ranger reference. (back_threader::find_taken_edge_cond): Same. (back_threader::dump): Remove m_solver. (back_threader::back_threader): Move verify_marked_backedges here from the path_range_query constructor. * tree-ssa-threadedge.cc (hybrid_jt_simplifier::simplify): Move some code from compute_ranges_from_state here. (hybrid_jt_simplifier::compute_ranges_from_state): Rename... (hybrid_jt_simplifier::compute_exit_dependencies): ...to this. * tree-ssa-threadedge.h (class hybrid_jt_simplifier): Rename compute_ranges_from_state to compute_exit_dependencies. Remove m_path.
Diffstat (limited to 'gcc/tree-ssa-threadedge.cc')
-rw-r--r--gcc/tree-ssa-threadedge.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/gcc/tree-ssa-threadedge.cc b/gcc/tree-ssa-threadedge.cc
index e64e4f2..905a98c 100644
--- a/gcc/tree-ssa-threadedge.cc
+++ b/gcc/tree-ssa-threadedge.cc
@@ -1399,7 +1399,6 @@ jt_state::register_equivs_stmt (gimple *stmt, basic_block bb,
// Hybrid threader implementation.
-
hybrid_jt_simplifier::hybrid_jt_simplifier (gimple_ranger *r,
path_range_query *q)
{
@@ -1411,7 +1410,12 @@ tree
hybrid_jt_simplifier::simplify (gimple *stmt, gimple *, basic_block,
jt_state *state)
{
- compute_ranges_from_state (stmt, state);
+ auto_bitmap dependencies;
+ auto_vec<basic_block> path;
+
+ state->get_path (path);
+ compute_exit_dependencies (dependencies, path, stmt);
+ m_query->reset_path (path, dependencies);
if (gimple_code (stmt) == GIMPLE_COND
|| gimple_code (stmt) == GIMPLE_ASSIGN)
@@ -1432,22 +1436,25 @@ hybrid_jt_simplifier::simplify (gimple *stmt, gimple *, basic_block,
return NULL;
}
-// Use STATE to generate the list of imports needed for the solver,
-// and calculate the ranges along the path.
+// Calculate the set of exit dependencies for a path and statement to
+// be simplified. This is different than the
+// compute_exit_dependencies in the path solver because the forward
+// threader asks questions about statements not necessarily in the
+// path. Using the default compute_exit_dependencies in the path
+// solver gets noticeably less threads.
void
-hybrid_jt_simplifier::compute_ranges_from_state (gimple *stmt, jt_state *state)
+hybrid_jt_simplifier::compute_exit_dependencies (bitmap dependencies,
+ const vec<basic_block> &path,
+ gimple *stmt)
{
- auto_bitmap imports;
gori_compute &gori = m_ranger->gori ();
- state->get_path (m_path);
-
// Start with the imports to the final conditional.
- bitmap_copy (imports, gori.imports (m_path[0]));
+ bitmap_copy (dependencies, gori.imports (path[0]));
// Add any other interesting operands we may have missed.
- if (gimple_bb (stmt) != m_path[0])
+ if (gimple_bb (stmt) != path[0])
{
for (unsigned i = 0; i < gimple_num_ops (stmt); ++i)
{
@@ -1455,8 +1462,7 @@ hybrid_jt_simplifier::compute_ranges_from_state (gimple *stmt, jt_state *state)
if (op
&& TREE_CODE (op) == SSA_NAME
&& Value_Range::supports_type_p (TREE_TYPE (op)))
- bitmap_set_bit (imports, SSA_NAME_VERSION (op));
+ bitmap_set_bit (dependencies, SSA_NAME_VERSION (op));
}
}
- m_query->compute_ranges (m_path, imports);
}