From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id 473B03858D35; Wed, 15 Feb 2023 10:14:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 473B03858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676456086; bh=G3qlHoobRU/xIR3FKZZyNS0kf0uf7kOtxBAQGs6rHws=; h=From:To:Subject:Date:From; b=a+HEj/9p/UtlgyD3jT2SMdjJpGRvmJvWuQO0R7LfWO2XvlY10WDbnGHWgvQWjBrJT dL/ZwSVP9Szg67C2FgZuobGc0vSmUr/wQF8ua3FzQ7cLiF+sDX66zObUvjJKhVwN/j XwYx/Lp612tcKdXG4xzc/z5Lr07weW6akqwUdfk8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] using hash_set to check elements of scc X-Act-Checkin: gcc X-Git-Author: Filip Kastl X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: 2da5c4b15527c5bf7788ee53fae7d58187719f44 X-Git-Newrev: 34dde057327c06c9aa22ee21f241c19cf1e8e821 Message-Id: <20230215101446.473B03858D35@sourceware.org> Date: Wed, 15 Feb 2023 10:14:46 +0000 (GMT) List-Id: https://gcc.gnu.org/g:34dde057327c06c9aa22ee21f241c19cf1e8e821 commit 34dde057327c06c9aa22ee21f241c19cf1e8e821 Author: Filip Kastl Date: Tue Sep 6 16:02:07 2022 +0200 using hash_set to check elements of scc Diff: --- gcc/sccp.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index 2df3547ed7b..32072c5d6d2 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -1,4 +1,4 @@ -/* TODO Popis passu +/* TODO Pass description Strongly connected copy propagation pass Copyright (C) 2022 Free Software Foundation, Inc. Contributed by Filip Kastl @@ -19,8 +19,6 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -// TODO Clean up includes - #include "config.h" #include "system.h" #include "coretypes.h" @@ -34,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hash-set.h" +// DEBUG includes #include #include "gimple-pretty-print.h" #include "print-tree.h" @@ -359,6 +358,13 @@ remove_redundant_phis (auto_vec &phis) auto_vec inner; hash_set outer_ops; + /* Prepare hash set of PHIs in scc to query later. */ + hash_set scc_set; + for (gphi *phi : scc) + { + scc_set.add (phi); + } + for (gphi *phi : scc) { bool is_inner = true; @@ -366,20 +372,15 @@ remove_redundant_phis (auto_vec &phis) unsigned i; for (i = 0; i < gimple_phi_num_args (phi); i++) { - // Check if operand is a phi from current scc bool op_in_scc = false; tree op = gimple_phi_arg_def (phi, i); if (TREE_CODE (op) == SSA_NAME) { gimple *op_stmt = SSA_NAME_DEF_STMT (op); - - // TODO Efficiency - for (gphi *foo : scc) - { - if (op_stmt == foo) - op_in_scc = true; - } + if (gimple_code (op_stmt) == GIMPLE_PHI && + scc_set.contains (as_a (op_stmt))) + op_in_scc = true; } if (!op_in_scc) @@ -395,7 +396,6 @@ remove_redundant_phis (auto_vec &phis) } } - // TODO if == 0 -> unreachable? if (outer_ops.elements () == 1) { /* Get the only operand in outer_ops. */ @@ -420,6 +420,10 @@ remove_redundant_phis (auto_vec &phis) worklist.safe_push (inner_scc); } } + else + { + gcc_unreachable (); // DEBUG + } scc.release (); }