From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id E24623851179; Tue, 6 Sep 2022 14:02:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E24623851179 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662472935; bh=ddtkTzIqG2XKyr6FlcQjNNvssK4pWvGbCVOI6Vz4LuA=; h=From:To:Subject:Date:From; b=JoBEIM5vneTnZ1p3HERPgxWV/gAhGjdnjRGNN09m/UAzrF3gAEXyK6OOJ+gz6tdpm J8ajyQFQGwrZ/YCUEcLgejbhWaxW3g6PZykGjm5WXtroeRl+cghNbIYiBo2h9lvtlL FLSXsSBXSiwWGqhul3+imcG+ZtKc76KviSsaN0P4= 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: 472b5ddbf8c917c8d3c0f4a96311fd635264a1a3 X-Git-Newrev: f2dce1dbe6499863c1f0c7c56dec1aaf6073acef Message-Id: <20220906140215.E24623851179@sourceware.org> Date: Tue, 6 Sep 2022 14:02:15 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f2dce1dbe6499863c1f0c7c56dec1aaf6073acef commit f2dce1dbe6499863c1f0c7c56dec1aaf6073acef 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 (); }