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)] compiler crashes on 20090917-1.c
Date: Wed, 15 Feb 2023 10:25:51 +0000 (GMT)	[thread overview]
Message-ID: <20230215102551.4827B385B516@sourceware.org> (raw)

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

commit f412011b1a0d65a8e8523a56d8681243865ca0ed
Author: Filip Kastl <filip.kastl@gmail.com>
Date:   Tue Nov 29 09:17:54 2022 +0100

    compiler crashes on 20090917-1.c

Diff:
---
 gcc/sccp.cc | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index 0f2f5cd61a3..c8c24fca2cf 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -69,7 +69,10 @@ static bool
 may_generate_useful_copy (gimple *stmt)
 {
   if (gimple_code (stmt) == GIMPLE_PHI)
-    return !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (stmt));
+    return true;
+  else
+    return false;
+    //return !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (stmt));
   //  return true; // TODO
 
   if (gimple_code (stmt) != GIMPLE_ASSIGN)
@@ -85,9 +88,11 @@ may_generate_useful_copy (gimple *stmt)
     return false;
 
   /* If the assignment is from a constant it generates a useful copy.  */
+  /* TODO
   if (gimple_assign_single_p (stmt)
       && is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))
     return true;
+  */
 
   /* Otherwise, the only statements that generate useful copies are
      assignments whose single SSA use doesn't flow through abnormal
@@ -217,9 +222,7 @@ tarjan_compute_sccs (auto_vec<gimple *> &copy_stmts)
       /* Iterate over neighbors of this vertex.  */
       ssa_op_iter iter;
       use_operand_p use_p;
-      std::cerr << gimple_code (stmt) << std::endl; // DEBUG
-      std::cerr << "Hi" << std::endl;
-      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
+      FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_ALL_USES)
 	{
 	  tree op_var = USE_FROM_PTR (use_p);
 
@@ -306,7 +309,7 @@ static void
 replace_scc_by_value (vec<gimple *> scc, tree replace_by)
 {
   // DEBUG
-  if (scc.length () >= 1)
+  if (scc.length () >= 5)
     {
       std::cerr << "Replacing SCC of length " << scc.length () << std::endl;
     }
@@ -363,8 +366,9 @@ sccp_propagate (auto_vec<gimple *> &copy_stmts)
 
 	  ssa_op_iter iter;
 	  use_operand_p use_p;
-	  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
+	  FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_ALL_USES)
 	    {
+	      //std::cerr << "Argument" << std::endl; // DEBUG
 	      tree op_var = USE_FROM_PTR (use_p);
 	      bool op_in_scc = false;
 
@@ -378,6 +382,7 @@ sccp_propagate (auto_vec<gimple *> &copy_stmts)
 	      if (!op_in_scc)
 		{
 		  outer_ops.add (op_var);
+		  last_outer_op = op_var;
 		  is_inner = false;
 		}
 	    }
@@ -388,6 +393,14 @@ sccp_propagate (auto_vec<gimple *> &copy_stmts)
 	    }
 	}
 
+      // DEBUG
+      /*
+      for (gimple *s : scc)
+	{
+	  debug_gimple_stmt (s);
+	}
+      */
+
       if (outer_ops.elements () == 1)
 	{
 	  /* The only operand in outer_ops.  */
@@ -430,14 +443,6 @@ get_all_may_generate_useful_copy (void)
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
 	  gimple *s = gsi_stmt (gsi);
-
-	  /*
-	  std::cerr << GIMPLE_PHI << std::endl; // DEBUG
-	  std::cerr << GIMPLE_ASSIGN << std::endl;
-	  debug_gimple_stmt (s);
-	  std::cerr << gimple_code (s) << std::endl << std::endl;
-	  */
-
 	  if (may_generate_useful_copy (s))
 	    result.safe_push (s);
 	}
@@ -446,14 +451,6 @@ get_all_may_generate_useful_copy (void)
       for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
 	{
 	  gimple *s = pi.phi ();
-
-	  /*
-	  std::cerr << GIMPLE_PHI << std::endl; // DEBUG
-	  std::cerr << GIMPLE_ASSIGN << std::endl;
-	  debug_gimple_stmt (s);
-	  std::cerr << gimple_code (s) << std::endl << std::endl;
-	  */
-
 	  if (may_generate_useful_copy (s))
 	    result.safe_push (s);
 	}

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230215102551.4827B385B516@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).