public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] fixed bug when scc references same var multiple times
@ 2022-09-05  9:27 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2022-09-05  9:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e92422ecae491dc4655d206e96a6b0536e1eaccf

commit e92422ecae491dc4655d206e96a6b0536e1eaccf
Author: Filip Kastl <filip.kastl@gmail.com>
Date:   Mon Sep 5 11:27:39 2022 +0200

    fixed bug when scc references same var multiple times

Diff:
---
 gcc/sccp.cc | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index 4dcedc293fd..1ac4474c019 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <iostream>
 #include "gimple-pretty-print.h"
 #include "vec.h"
+#include "hash-set.h"
 #include "libiberty.h"
 
 #include "print-tree.h"
@@ -373,7 +374,7 @@ static void
 process_scc (vec<gphi *> scc)
 {
   vec<gphi *> inner = vNULL;
-  vec<tree> outer_ops = vNULL;
+  hash_set<tree> outer_ops;
 
   for (gphi *phi : scc)
     {
@@ -400,7 +401,7 @@ process_scc (vec<gphi *> scc)
 
 	  if (!op_in_scc)
 	    {
-	      outer_ops.safe_push (op);
+	      outer_ops.add (op);
 	      is_inner = false;
 	    }
 	}
@@ -412,9 +413,19 @@ process_scc (vec<gphi *> scc)
     }
 
   // TODO if == 0 -> unreachable?
-  if (outer_ops.length () == 1)
-    replace_scc_by_value (scc, outer_ops.pop());
-  else if (outer_ops.length () > 1)
+  if (outer_ops.elements () == 1)
+    {
+      /* Get the only operand in outer_ops.  */
+      tree outer_op;
+      for (tree foo : outer_ops)
+	{
+	  outer_op = foo;
+	  break;
+	}
+
+      replace_scc_by_value (scc, outer_op);
+    }
+  else if (outer_ops.elements () > 1)
     {
       remove_redundant_phis (inner);
     }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/pheeck/heads/sccp)] fixed bug when scc references same var multiple times
@ 2023-02-15 10:14 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2023-02-15 10:14 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f2e8ddf3d4eff923162d990b05493f9b5b5f5305

commit f2e8ddf3d4eff923162d990b05493f9b5b5f5305
Author: Filip Kastl <filip.kastl@gmail.com>
Date:   Mon Sep 5 11:27:39 2022 +0200

    fixed bug when scc references same var multiple times

Diff:
---
 gcc/sccp.cc | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index 4dcedc293fd..1ac4474c019 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <iostream>
 #include "gimple-pretty-print.h"
 #include "vec.h"
+#include "hash-set.h"
 #include "libiberty.h"
 
 #include "print-tree.h"
@@ -373,7 +374,7 @@ static void
 process_scc (vec<gphi *> scc)
 {
   vec<gphi *> inner = vNULL;
-  vec<tree> outer_ops = vNULL;
+  hash_set<tree> outer_ops;
 
   for (gphi *phi : scc)
     {
@@ -400,7 +401,7 @@ process_scc (vec<gphi *> scc)
 
 	  if (!op_in_scc)
 	    {
-	      outer_ops.safe_push (op);
+	      outer_ops.add (op);
 	      is_inner = false;
 	    }
 	}
@@ -412,9 +413,19 @@ process_scc (vec<gphi *> scc)
     }
 
   // TODO if == 0 -> unreachable?
-  if (outer_ops.length () == 1)
-    replace_scc_by_value (scc, outer_ops.pop());
-  else if (outer_ops.length () > 1)
+  if (outer_ops.elements () == 1)
+    {
+      /* Get the only operand in outer_ops.  */
+      tree outer_op;
+      for (tree foo : outer_ops)
+	{
+	  outer_op = foo;
+	  break;
+	}
+
+      replace_scc_by_value (scc, outer_op);
+    }
+  else if (outer_ops.elements () > 1)
     {
       remove_redundant_phis (inner);
     }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-15 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05  9:27 [gcc(refs/users/pheeck/heads/sccp)] fixed bug when scc references same var multiple times Filip Kastl
2023-02-15 10:14 Filip Kastl

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).