From 59e339e9fbc0539c62610bbcc7393996f21b65de Mon Sep 17 00:00:00 2001
From: mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 12 Jun 2001 04:42:46 +0000
Subject: [PATCH] 	* unroll.c (initial_reg_note_copy): Use
 PUT_REG_NOTE_KIND and 	REG_NOTE_KIND, not PUT_MODE and GET_MODE. 
 (final_reg_note_copy): Remove REG_WAS_0 notes that are no longer 	valid.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43241 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog |  7 +++++++
 gcc/unroll.c  | 41 ++++++++++++++++++++++++++++++++---------
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 272d38d97c2e..4d46908a35f2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2001-06-11  Mark Mitchell  <mark@codesourcery.com>
+
+	* unroll.c (initial_reg_note_copy): Use PUT_REG_NOTE_KIND and
+	REG_NOTE_KIND, not PUT_MODE and GET_MODE.
+	(final_reg_note_copy): Remove REG_WAS_0 notes that are no longer
+	valid.
+
 2001-06-11  Stan Shebs  <shebs@apple.com>
 
 	* darwin.h (ASM_FILE_END): Remove decl of language_string.
diff --git a/gcc/unroll.c b/gcc/unroll.c
index 71c96f689879..94c58cd925ce 100644
--- a/gcc/unroll.c
+++ b/gcc/unroll.c
@@ -201,7 +201,7 @@ static int *splittable_regs_updates;
 static void init_reg_map PARAMS ((struct inline_remap *, int));
 static rtx calculate_giv_inc PARAMS ((rtx, rtx, unsigned int));
 static rtx initial_reg_note_copy PARAMS ((rtx, struct inline_remap *));
-static void final_reg_note_copy PARAMS ((rtx, struct inline_remap *));
+static void final_reg_note_copy PARAMS ((rtx *, struct inline_remap *));
 static void copy_loop_body PARAMS ((struct loop *, rtx, rtx,
 				    struct inline_remap *, rtx, int,
 				    enum unroll_types, rtx, rtx, rtx, rtx));
@@ -1666,7 +1666,7 @@ initial_reg_note_copy (notes, map)
     return 0;
 
   copy = rtx_alloc (GET_CODE (notes));
-  PUT_MODE (copy, GET_MODE (notes));
+  PUT_REG_NOTE_KIND (copy, REG_NOTE_KIND (notes));
 
   if (GET_CODE (notes) == EXPR_LIST)
     XEXP (copy, 0) = copy_rtx_and_substitute (XEXP (notes, 0), map, 0);
@@ -1684,15 +1684,38 @@ initial_reg_note_copy (notes, map)
 /* Fixup insn references in copied REG_NOTES.  */
 
 static void
-final_reg_note_copy (notes, map)
-     rtx notes;
+final_reg_note_copy (notesp, map)
+     rtx *notesp;
      struct inline_remap *map;
 {
-  rtx note;
+  while (*notesp)
+    {
+      rtx note = *notesp;
+      
+      if (GET_CODE (note) == INSN_LIST)
+	{
+	  /* Sometimes, we have a REG_WAS_0 note that points to a
+	     deleted instruction.  In that case, we can just delete the
+	     note.  */
+	  if (REG_NOTE_KIND (note) == REG_WAS_0)
+	    {
+	      *notesp = XEXP (note, 1);
+	      continue;
+	    }
+	  else
+	    {
+	      rtx insn = map->insn_map[INSN_UID (XEXP (note, 0))];
+
+	      /* If we failed to remap the note, something is awry.  */
+	      if (!insn)
+		abort ();
+
+	      XEXP (note, 0) = insn;
+	    }
+	}
 
-  for (note = notes; note; note = XEXP (note, 1))
-    if (GET_CODE (note) == INSN_LIST)
-      XEXP (note, 0) = map->insn_map[INSN_UID (XEXP (note, 0))];
+      notesp = &XEXP (note, 1);
+    }
 }
 
 /* Copy each instruction in the loop, substituting from map as appropriate.
@@ -2219,7 +2242,7 @@ copy_loop_body (loop, copy_start, copy_end, map, exit_label, last_iteration,
       if ((GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
 	   || GET_CODE (insn) == CALL_INSN)
 	  && map->insn_map[INSN_UID (insn)])
-	final_reg_note_copy (REG_NOTES (map->insn_map[INSN_UID (insn)]), map);
+	final_reg_note_copy (&REG_NOTES (map->insn_map[INSN_UID (insn)]), map);
     }
   while (insn != copy_end);
 
-- 
GitLab