OSDN Git Service

PR optimization/5747
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Feb 2002 08:56:22 +0000 (08:56 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Feb 2002 08:56:22 +0000 (08:56 +0000)
* loop.c (scan_loop): Update reg info if move_movables created new
pseudos.

* gcc.dg/20020222-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49989 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/loop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20020222-1.c [new file with mode: 0644]

index a4a547c..69c95cf 100644 (file)
@@ -1,3 +1,9 @@
+2002-02-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR optimization/5747
+       * loop.c (scan_loop): Update reg info if move_movables created new
+       pseudos.
+
 2002-02-23  David Edelsohn  <edelsohn@gnu.org>
 
        * gcc.c (init_gcc_spec): Revert last change.
index 68ef439..2bd1944 100644 (file)
@@ -1102,7 +1102,25 @@ scan_loop (loop, flags)
      optimizing for code size.  */
 
   if (! optimize_size)
-    move_movables (loop, movables, threshold, insn_count);
+    {
+      move_movables (loop, movables, threshold, insn_count);
+
+      /* Recalculate regs->array if move_movables has created new
+        registers.  */
+      if (max_reg_num () > regs->num)
+       {
+         loop_regs_scan (loop, 0);
+         for (update_start = loop_start;
+              PREV_INSN (update_start)
+              && GET_CODE (PREV_INSN (update_start)) != CODE_LABEL;
+              update_start = PREV_INSN (update_start))
+           ;
+         update_end = NEXT_INSN (loop_end);
+
+         reg_scan_update (update_start, update_end, loop_max_reg);
+         loop_max_reg = max_reg_num ();
+       }
+    }
 
   /* Now candidates that still are negative are those not moved.
      Change regs->array[I].set_in_loop to indicate that those are not actually
index e7149dd..15905e6 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20020222-1.c: New test.
+
 2002-02-22  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/opt/anonunion1.C: New test.
diff --git a/gcc/testsuite/gcc.dg/20020222-1.c b/gcc/testsuite/gcc.dg/20020222-1.c
new file mode 100644 (file)
index 0000000..61f1054
--- /dev/null
@@ -0,0 +1,34 @@
+/* PR optimization/5747
+   This testcase ICEd on sparc because move_movables created new pseudos,
+   but did not update reg info which load_mems needed.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -fPIC" { target sparc*-*-* } } */
+
+extern void foo (void);
+static char a[256];
+
+void
+bar (void)
+{
+  unsigned int i;
+  static int b = 0;
+  int c;
+
+  if (b == 0)
+    {
+      b = 1;
+      foo ();
+      c = 0;
+      for (i = 0; i < 10; i++)
+       a[i + '0'] = c++;
+      for (i = 'A'; i <= 'Z'; i++)
+       a[i] = c++;
+      a['$'] = c++;
+      a['%'] = c++;
+      a['.'] = c++;
+      a['_'] = c++;
+      for (i = 'a'; i <= 'z'; i++)
+       a[i] = c++;
+    }
+}