From 77b2358d51bf227f14fa4dba349411cd2081adca Mon Sep 17 00:00:00 2001
From: grahams <grahams@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 15 Nov 2000 11:07:44 +0000
Subject: [PATCH]         * regrename.c (scan_rtx_rtx): Skip to the next chain
 on         encountering a terminated chain.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37473 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog   |   5 +++
 gcc/regrename.c | 109 +++++++++++++++++++++++++++---------------------
 2 files changed, 66 insertions(+), 48 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f0164266dde6..60efafb3265e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-15  Graham Stott  <grahams@redhat.com>
+
+	* regrename.c (scan_rtx_rtx): Skip to the next chain on
+	encountering a terminated chain.
+
 2000-11-14  Mark Mitchell  <mark@codesourcery.com>
 
 	* configure.in: Move check for V3 above check for C++ header-file
diff --git a/gcc/regrename.c b/gcc/regrename.c
index b3aa6c2f32a8..c444af8326e1 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -307,62 +307,75 @@ scan_rtx_reg (insn, loc, class, action, type)
   for (p = &open_chains; *p;)
     {
       struct du_chain *this = *p;
-      int regno = REGNO (*this->loc);
-      int nregs = HARD_REGNO_NREGS (regno, GET_MODE (*this->loc));
-      int exact_match = (regno == this_regno && nregs == this_nregs);
 
-      if (regno + nregs <= this_regno
-	  || this_regno + this_nregs <= regno)
-	p = &this->next_chain;
-      else if (action == mark_read)
-	{
-	  if (! exact_match)
-	    abort ();
-	  if (class == NO_REGS)
-	    abort ();
+      /* Check if the chain has been terminated if it has then skip to
+	 the next chain.
 
-	  this = (struct du_chain *)
-	    obstack_alloc (&rename_obstack, sizeof (struct du_chain));
-	  this->next_use = *p;
-	  this->next_chain = (*p)->next_chain;
-	  this->loc = loc;
-	  this->insn = insn;
-	  this->class = class;
-	  this->need_caller_save_reg = 0;
-	  *p = this;
-	  return;
-	}
-      else if (action != terminate_overlapping_read || ! exact_match)
-	{
-	  struct du_chain *next = this->next_chain;
-
-	  /* Whether the terminated chain can be used for renaming
-	     depends on the action and this being an exact match.
-	     In either case, we remove this element from open_chains.  */
+	 This can happen when we've already appended the location to
+	 the chain in Step 3, but are trying to hide in-out operands
+	 from terminate_write in Step 5.  */
 
-	  if ((action == terminate_dead || action == terminate_write)
-	      && exact_match)
+      if (*this->loc == cc0_rtx)
+	p = &this->next_chain;
+      else
+        {
+	  int regno = REGNO (*this->loc);
+	  int nregs = HARD_REGNO_NREGS (regno, GET_MODE (*this->loc));
+	  int exact_match = (regno == this_regno && nregs == this_nregs);
+
+	  if (regno + nregs <= this_regno
+	      || this_regno + this_nregs <= regno)
+	    p = &this->next_chain;
+	  else if (action == mark_read)
 	    {
-	      this->next_chain = closed_chains;
-	      closed_chains = this;
-	      if (rtl_dump_file)
-		fprintf (rtl_dump_file,
-			 "Closing chain %s at insn %d (%s)\n",
-			 reg_names[REGNO (*this->loc)], INSN_UID (insn),
-			 scan_actions_name[(int) action]);
+	      if (! exact_match)
+		abort ();
+	      if (class == NO_REGS)
+		abort ();
+
+	      this = (struct du_chain *)
+		obstack_alloc (&rename_obstack, sizeof (struct du_chain));
+	      this->next_use = *p;
+	      this->next_chain = (*p)->next_chain;
+	      this->loc = loc;
+	      this->insn = insn;
+	      this->class = class;
+	      this->need_caller_save_reg = 0;
+	      *p = this;
+	      return;
 	    }
-	  else
+	  else if (action != terminate_overlapping_read || ! exact_match)
 	    {
-	      if (rtl_dump_file)
-		fprintf (rtl_dump_file,
-			 "Discarding chain %s at insn %d (%s)\n",
-			 reg_names[REGNO (*this->loc)], INSN_UID (insn),
-			 scan_actions_name[(int) action]);
+	      struct du_chain *next = this->next_chain;
+
+	      /* Whether the terminated chain can be used for renaming
+	         depends on the action and this being an exact match.
+	         In either case, we remove this element from open_chains.  */
+
+	      if ((action == terminate_dead || action == terminate_write)
+		  && exact_match)
+		{
+		  this->next_chain = closed_chains;
+		  closed_chains = this;
+		  if (rtl_dump_file)
+		    fprintf (rtl_dump_file,
+			     "Closing chain %s at insn %d (%s)\n",
+			     reg_names[REGNO (*this->loc)], INSN_UID (insn),
+			     scan_actions_name[(int) action]);
+		}
+	      else
+		{
+		  if (rtl_dump_file)
+		    fprintf (rtl_dump_file,
+			     "Discarding chain %s at insn %d (%s)\n",
+			     reg_names[REGNO (*this->loc)], INSN_UID (insn),
+			     scan_actions_name[(int) action]);
+		}
+	      *p = next;
 	    }
-	  *p = next;
+	  else
+	    p = &this->next_chain;
 	}
-      else
-	p = &this->next_chain;
     }
 }
 
-- 
GitLab