cse.c (max_insn_uid): New variable.
authorJim Wilson <wilson@cygnus.com>
Wed, 24 Dec 1997 22:54:37 +0000 (22:54 +0000)
committerJeff Law <law@gcc.gnu.org>
Wed, 24 Dec 1997 22:54:37 +0000 (15:54 -0700)
        * cse.c (max_insn_uid): New variable.
        (invalidate): Remove CYGNUS LOCAL patch.
        (cse_around_loop): Use max_insn_uid.
        (cse_main): Set max_insn_uid.

From-SVN: r17231

gcc/ChangeLog
gcc/cse.c

index 575f9a5..1926629 100644 (file)
@@ -4,6 +4,11 @@ Wed Dec 24 23:33:17 1997  Jeffrey A Law  (law@cygnus.com)
 
 Wed Dec 24 23:12:14 1997  Jim Wilson  <wilson@cygnus.com>
 
+       * cse.c (max_insn_uid): New variable.
+       (invalidate): Remove CYGNUS LOCAL patch.
+       (cse_around_loop): Use max_insn_uid.
+       (cse_main): Set max_insn_uid.
+
        * abi64.h (LONG_MAX_SPEC): Check MIPS_ABI_DEFAULT and TARGET_DEFAULT,
        and define __LONG_MAX__ appropriately.  Add support for -mabi=X,
        -mlong64, and -mgp{32,64} options.
index 247a3d8..ca1b648 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -193,6 +193,11 @@ Related expressions:
 
 static int max_reg;
 
+/* One plus largest instruction UID used in this function at time of
+   cse_main call.  */
+
+static int max_insn_uid;
+
 /* Length of vectors indexed by quantity number.
    We know in advance we will not need a quantity number this big.  */
 
@@ -7798,10 +7803,16 @@ cse_around_loop (loop_start)
 
      The only thing we do with SET_DEST is invalidate entries, so we
      can safely process each SET in order.  It is slightly less efficient
-     to do so, but we only want to handle the most common cases.  */
+     to do so, but we only want to handle the most common cases.
+
+     The gen_move_insn call in cse_set_around_loop may create new pseudos.
+     These pseudos won't have valid entries in any of the tables indexed
+     by register number, such as reg_qty.  We avoid out-of-range array
+     accesses by not processing any instructions created after cse started.  */
 
   for (insn = NEXT_INSN (loop_start);
        GET_CODE (insn) != CALL_INSN && GET_CODE (insn) != CODE_LABEL
+       && INSN_UID (insn) < max_insn_uid
        && ! (GET_CODE (insn) == NOTE
             && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END);
        insn = NEXT_INSN (insn))
@@ -8248,6 +8259,8 @@ cse_main (f, nregs, after_loop, file)
 
   max_reg = nregs;
 
+  max_insn_uid = get_max_uid ();
+
   all_minus_one = (int *) alloca (nregs * sizeof (int));
   consec_ints = (int *) alloca (nregs * sizeof (int));