From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 4B799385803F; Thu, 4 Nov 2021 14:40:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B799385803F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4903] path solver: Only compute relations for imports. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: 333efaea633971912f2208d37b7b62992759d400 X-Git-Newrev: 5ea1ce43b6070aaa94882e8b15f3340344aaa6b2 Message-Id: <20211104144044.4B799385803F@sourceware.org> Date: Thu, 4 Nov 2021 14:40:44 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2021 14:40:44 -0000 https://gcc.gnu.org/g:5ea1ce43b6070aaa94882e8b15f3340344aaa6b2 commit r12-4903-g5ea1ce43b6070aaa94882e8b15f3340344aaa6b2 Author: Aldy Hernandez Date: Wed Nov 3 08:23:25 2021 +0100 path solver: Only compute relations for imports. We are currently calculating implicit PHI relations for all PHI arguments. This creates unecessary work, as we only care about SSA names in the import bitmap. Similarly for inter-path relationals. We can avoid things not in the bitmap. Tested on x86-64 and ppc64le Linux with the usual regstrap. I also verified that the before and after number of threads was the same in a suite of .ii files from a bootstrap. gcc/ChangeLog: PR tree-optimization/102943 * gimple-range-path.cc (path_range_query::compute_phi_relations): Only compute relations for SSA names in the import list. (path_range_query::compute_outgoing_relations): Same. * gimple-range-path.h (path_range_query::import_p): New. Diff: --- gcc/gimple-range-path.cc | 7 ++++++- gcc/gimple-range-path.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index d8c2a9b6a86..42309886c94 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -678,8 +678,12 @@ path_range_query::compute_phi_relations (basic_block bb, basic_block prev) gsi_next (&iter)) { gphi *phi = iter.phi (); + tree result = gimple_phi_result (phi); unsigned nargs = gimple_phi_num_args (phi); + if (!import_p (result)) + continue; + for (size_t i = 0; i < nargs; ++i) if (e_in == gimple_phi_arg_edge (phi, i)) { @@ -701,7 +705,8 @@ path_range_query::compute_outgoing_relations (basic_block bb, basic_block next) if (stmt && gimple_code (stmt) == GIMPLE_COND - && irange::supports_type_p (TREE_TYPE (gimple_cond_lhs (stmt)))) + && (import_p (gimple_cond_lhs (stmt)) + || import_p (gimple_cond_rhs (stmt)))) { int_range<2> r; gcond *cond = as_a (stmt); diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index 541613956e1..f21d07f71c4 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -62,6 +62,7 @@ private: void maybe_register_phi_relation (gphi *, tree arg); void add_copies_to_imports (); bool add_to_imports (tree name, bitmap imports); + inline bool import_p (tree name); // Path navigation. void set_path (const vec &); @@ -97,4 +98,13 @@ private: bool m_undefined_path; }; +// Return TRUE if NAME is in the import bitmap. + +bool +path_range_query::import_p (tree name) +{ + return (TREE_CODE (name) == SSA_NAME + && bitmap_bit_p (m_imports, SSA_NAME_VERSION (name))); +} + #endif // GCC_TREE_SSA_THREADSOLVER_H