From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 301DB3858C74; Thu, 11 Aug 2022 14:07:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 301DB3858C74 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2021] Tame path_range_query::compute_imports X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 16b013c9d9b4d950f89821476e791bf18c1295df X-Git-Newrev: e4fbcfc0b130f872b8dd9d5089fb71ee5ed9459a Message-Id: <20220811140728.301DB3858C74@sourceware.org> Date: Thu, 11 Aug 2022 14:07:28 +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, 11 Aug 2022 14:07:28 -0000 https://gcc.gnu.org/g:e4fbcfc0b130f872b8dd9d5089fb71ee5ed9459a commit r13-2021-ge4fbcfc0b130f872b8dd9d5089fb71ee5ed9459a Author: Richard Biener Date: Thu Aug 11 13:28:44 2022 +0200 Tame path_range_query::compute_imports This avoids going BBs outside of the path when adding def chains to the set of imports. It also syncs the code with range_def_chain::get_def_chain to not miss out on some imports this function would identify. * gimple-range-path.cc (path_range_query::compute_imports): Restrict walking SSA defs to blocks inside the path. Track the same operands as range_def_chain::get_def_chain does. Diff: --- gcc/gimple-range-path.cc | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 5ae374df3a2..5ff2c733b4e 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -575,18 +575,11 @@ path_range_query::compute_imports (bitmap imports, const vec &path) { tree name = worklist.pop (); gimple *def_stmt = SSA_NAME_DEF_STMT (name); + if (SSA_NAME_IS_DEFAULT_DEF (name) + || !path.contains (gimple_bb (def_stmt))) + continue; - if (is_gimple_assign (def_stmt)) - { - add_to_imports (gimple_assign_rhs1 (def_stmt), imports); - tree rhs = gimple_assign_rhs2 (def_stmt); - if (rhs && add_to_imports (rhs, imports)) - worklist.safe_push (rhs); - rhs = gimple_assign_rhs3 (def_stmt); - if (rhs && add_to_imports (rhs, imports)) - worklist.safe_push (rhs); - } - else if (gphi *phi = dyn_cast (def_stmt)) + if (gphi *phi = dyn_cast (def_stmt)) { for (size_t i = 0; i < gimple_phi_num_args (phi); ++i) { @@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec &path) worklist.safe_push (arg); } } + else if (gassign *ass = dyn_cast (def_stmt)) + { + tree ssa[3]; + if (range_op_handler (ass)) + { + ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass)); + ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass)); + ssa[2] = NULL_TREE; + } + else if (gimple_assign_rhs_code (ass) == COND_EXPR) + { + ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass)); + ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass)); + ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass)); + } + else + continue; + for (unsigned j = 0; j < 3; ++j) + { + tree rhs = ssa[j]; + if (rhs && add_to_imports (rhs, imports)) + worklist.safe_push (rhs); + } + } } // Exported booleans along the path, may help conditionals. if (m_resolve)