public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Filip Kastl <pheeck@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/pheeck/heads/sccp)] using hash_set to check elements of scc
Date: Wed, 15 Feb 2023 10:14:46 +0000 (GMT)	[thread overview]
Message-ID: <20230215101446.473B03858D35@sourceware.org> (raw)

https://gcc.gnu.org/g:34dde057327c06c9aa22ee21f241c19cf1e8e821

commit 34dde057327c06c9aa22ee21f241c19cf1e8e821
Author: Filip Kastl <filip.kastl@gmail.com>
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 <filip.kastl@gmail.com>
@@ -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
 <http://www.gnu.org/licenses/>.  */
 
-// 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 <iostream>
 #include "gimple-pretty-print.h"
 #include "print-tree.h"
@@ -359,6 +358,13 @@ remove_redundant_phis (auto_vec<gphi *> &phis)
       auto_vec<gphi *> inner;
       hash_set<tree> outer_ops;
 
+      /* Prepare hash set of PHIs in scc to query later.  */
+      hash_set<gphi *> 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<gphi *> &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<gphi *> (op_stmt)))
+		    op_in_scc = true;
 		}
 
 	      if (!op_in_scc)
@@ -395,7 +396,6 @@ remove_redundant_phis (auto_vec<gphi *> &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<gphi *> &phis)
 	      worklist.safe_push (inner_scc);
 	    }
 	}
+      else
+	{
+	  gcc_unreachable (); // DEBUG
+	}
 
       scc.release ();
     }

             reply	other threads:[~2023-02-15 10:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 10:14 Filip Kastl [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-09-06 14:02 Filip Kastl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230215101446.473B03858D35@sourceware.org \
    --to=pheeck@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).