From 48e97240a5255ffd72dca8d2c23937029aff882b Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 16 Aug 2022 10:52:37 +0200 Subject: [PATCH] Rename imports nomenclature in path_range_query to exit_dependencies. The purpose of this change is to disambiguate the imports name with its use in GORI. gcc/ChangeLog: * gimple-range-path.cc (path_range_query::import_p): Rename to... (path_range_query::exit_dependency_p): ...this. (path_range_query::dump): Rename imports to exit dependencies. (path_range_query::compute_ranges_in_phis): Same. (path_range_query::compute_ranges_in_block): Same. (path_range_query::adjust_for_non_null_uses): Same. (path_range_query::compute_ranges): Same. (path_range_query::compute_phi_relations): Same. (path_range_query::add_to_imports): Rename to... (path_range_query::add_to_exit_dependencies): ...this. (path_range_query::compute_imports): Rename to... (path_range_query::compute_exit_dependencies): ...this. * gimple-range-path.h (class path_range_query): Rename imports to exit dependencies. --- gcc/gimple-range-path.cc | 79 +++++++++++++++++++--------------------- gcc/gimple-range-path.h | 19 +++++++--- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 78146f5683e..c99d77dd340 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -62,13 +62,13 @@ path_range_query::~path_range_query () delete m_cache; } -// Return TRUE if NAME is in the import bitmap. +// Return TRUE if NAME is an exit depenency for the path. bool -path_range_query::import_p (tree name) +path_range_query::exit_dependency_p (tree name) { return (TREE_CODE (name) == SSA_NAME - && bitmap_bit_p (m_imports, SSA_NAME_VERSION (name))); + && bitmap_bit_p (m_exit_dependencies, SSA_NAME_VERSION (name))); } // Mark cache entry for NAME as unused. @@ -118,8 +118,8 @@ path_range_query::dump (FILE *dump_file) dump_ranger (dump_file, m_path); - fprintf (dump_file, "Imports:\n"); - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + fprintf (dump_file, "Exit dependencies:\n"); + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); print_generic_expr (dump_file, name, TDF_SLIM); @@ -356,7 +356,7 @@ path_range_query::compute_ranges_in_phis (basic_block bb) gphi *phi = iter.phi (); tree name = gimple_phi_result (phi); - if (!import_p (name)) + if (!exit_dependency_p (name)) continue; Value_Range r (TREE_TYPE (name)); @@ -400,17 +400,17 @@ path_range_query::compute_ranges_in_block (basic_block bb) // Force recalculation of any names in the cache that are defined in // this block. This can happen on interdependent SSA/phis in loops. - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); if (ssa_defined_in_bb (name, bb)) clear_cache (name); } - // Solve imports defined in this block, starting with the PHIs... + // Solve dependencies defined in this block, starting with the PHIs... compute_ranges_in_phis (bb); - // ...and then the rest of the imports. - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + // ...and then the rest of the dependencies. + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); Value_Range r (TREE_TYPE (name)); @@ -423,7 +423,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) if (at_exit ()) return; - // Solve imports that are exported to the next block. + // Solve dependencies that are exported to the next block. basic_block next = next_bb (); edge e = find_edge (bb, next); @@ -444,7 +444,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) gori_compute &g = m_ranger->gori (); bitmap exports = g.exports (bb); - EXECUTE_IF_AND_IN_BITMAP (m_imports, exports, 0, i, bi) + EXECUTE_IF_AND_IN_BITMAP (m_exit_dependencies, exports, 0, i, bi) { tree name = ssa_name (i); Value_Range r (TREE_TYPE (name)); @@ -472,7 +472,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) compute_outgoing_relations (bb, next); } -// Adjust all pointer imports in BB with non-null information. +// Adjust all pointer exit dependencies in BB with non-null information. void path_range_query::adjust_for_non_null_uses (basic_block bb) @@ -481,7 +481,7 @@ path_range_query::adjust_for_non_null_uses (basic_block bb) bitmap_iterator bi; unsigned i; - EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); @@ -501,39 +501,33 @@ path_range_query::adjust_for_non_null_uses (basic_block bb) } } -// If NAME is a supported SSA_NAME, add it the bitmap in IMPORTS. +// If NAME is a supported SSA_NAME, add it to the bitmap in dependencies. bool -path_range_query::add_to_imports (tree name, bitmap imports) +path_range_query::add_to_exit_dependencies (tree name, bitmap dependencies) { if (TREE_CODE (name) == SSA_NAME && Value_Range::supports_type_p (TREE_TYPE (name))) - return bitmap_set_bit (imports, SSA_NAME_VERSION (name)); + return bitmap_set_bit (dependencies, SSA_NAME_VERSION (name)); return false; } -// Compute the imports to PATH. These are -// essentially the SSA names used to calculate the final conditional -// along the path. -// -// They are hints for the solver. Adding more elements doesn't slow -// us down, because we don't solve anything that doesn't appear in the -// path. On the other hand, not having enough imports will limit what -// we can solve. +// Compute the exit dependencies to PATH. These are essentially the +// SSA names used to calculate the final conditional along the path. void -path_range_query::compute_imports (bitmap imports, const vec &path) +path_range_query::compute_exit_dependencies (bitmap dependencies, + const vec &path) { // Start with the imports from the exit block... basic_block exit = path[0]; gori_compute &gori = m_ranger->gori (); - bitmap r_imports = gori.imports (exit); - bitmap_copy (imports, r_imports); + bitmap_copy (dependencies, gori.imports (exit)); - auto_vec worklist (bitmap_count_bits (imports)); + auto_vec worklist (bitmap_count_bits (dependencies)); bitmap_iterator bi; unsigned i; - EXECUTE_IF_SET_IN_BITMAP (imports, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (dependencies, 0, i, bi) { tree name = ssa_name (i); worklist.quick_push (name); @@ -557,7 +551,7 @@ path_range_query::compute_imports (bitmap imports, const vec &path) if (TREE_CODE (arg) == SSA_NAME && path.contains (e->src) - && bitmap_set_bit (imports, SSA_NAME_VERSION (arg))) + && bitmap_set_bit (dependencies, SSA_NAME_VERSION (arg))) worklist.safe_push (arg); } } @@ -581,7 +575,7 @@ path_range_query::compute_imports (bitmap imports, const vec &path) for (unsigned j = 0; j < 3; ++j) { tree rhs = ssa[j]; - if (rhs && add_to_imports (rhs, imports)) + if (rhs && add_to_exit_dependencies (rhs, dependencies)) worklist.safe_push (rhs); } } @@ -594,19 +588,20 @@ path_range_query::compute_imports (bitmap imports, const vec &path) tree name; FOR_EACH_GORI_EXPORT_NAME (gori, bb, name) if (TREE_CODE (TREE_TYPE (name)) == BOOLEAN_TYPE) - bitmap_set_bit (imports, SSA_NAME_VERSION (name)); + bitmap_set_bit (dependencies, SSA_NAME_VERSION (name)); } } -// Compute the ranges for IMPORTS along PATH. +// Compute the ranges for DEPENDENCIES along PATH. // -// IMPORTS are the set of SSA names, any of which could potentially -// change the value of the final conditional in PATH. Default to the -// imports of the last block in the path if none is given. +// DEPENDENCIES are path exit dependencies. They are the set of SSA +// names, any of which could potentially change the value of the final +// conditional in PATH. If none is given, the exit dependencies are +// calculated from the final conditional in the path. void path_range_query::compute_ranges (const vec &path, - const bitmap_head *imports) + const bitmap_head *dependencies) { if (DEBUG_SOLVER) fprintf (dump_file, "\n==============================================\n"); @@ -614,10 +609,10 @@ path_range_query::compute_ranges (const vec &path, set_path (path); m_undefined_path = false; - if (imports) - bitmap_copy (m_imports, imports); + if (dependencies) + bitmap_copy (m_exit_dependencies, dependencies); else - compute_imports (m_imports, m_path); + compute_exit_dependencies (m_exit_dependencies, m_path); if (m_resolve) get_path_oracle ()->reset_path (); @@ -809,7 +804,7 @@ path_range_query::compute_phi_relations (basic_block bb, basic_block prev) tree result = gimple_phi_result (phi); unsigned nargs = gimple_phi_num_args (phi); - if (!import_p (result)) + if (!exit_dependency_p (result)) continue; for (size_t i = 0; i < nargs; ++i) diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index e783e00b2f5..3cb794e34a9 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -35,9 +35,10 @@ public: path_range_query (bool resolve = true, class gimple_ranger *ranger = NULL); virtual ~path_range_query (); void compute_ranges (const vec &, - const bitmap_head *imports = NULL); + const bitmap_head *dependencies = NULL); void compute_ranges (edge e); - void compute_imports (bitmap imports, const vec &); + void compute_exit_dependencies (bitmap dependencies, + const vec &); bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override; bool unreachable_path_p (); @@ -64,8 +65,8 @@ private: void compute_outgoing_relations (basic_block bb, basic_block next); void compute_phi_relations (basic_block bb, basic_block prev); void maybe_register_phi_relation (gphi *, edge e); - bool add_to_imports (tree name, bitmap imports); - bool import_p (tree name); + bool add_to_exit_dependencies (tree name, bitmap dependencies); + bool exit_dependency_p (tree name); bool ssa_defined_in_bb (tree name, basic_block bb); bool relations_may_be_invalidated (edge); @@ -89,7 +90,15 @@ private: // Path being analyzed. auto_vec m_path; - auto_bitmap m_imports; + // This is a list of SSA names that may have relevant context + // information for solving the final conditional along the path. + // Ranges for these SSA names are pre-calculated and cached during a + // top-down traversal of the path, and are then used to answer + // questions at the path exit. + auto_bitmap m_exit_dependencies; + + // A ranger used to resolve ranges for SSA names whose values come + // from outside the path. gimple_ranger *m_ranger; // Current path position. -- 2.37.1