reload1.c (calculate_needs_all_insns): If deleting an instruction, remove its insn_ch...
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Oct 2000 13:48:00 +0000 (15:48 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Oct 2000 13:48:00 +0000 (15:48 +0200)
* reload1.c (calculate_needs_all_insns): If deleting an instruction,
remove its insn_chain structure as well.

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

From-SVN: r36824

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

index 98387aa09724c3a33751b5d5b1fbc512bfa802b7..6cced2b0c973fc2c9c9b91443b6b45f74d90be99 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       * reload1.c (calculate_needs_all_insns): If deleting an instruction,
+       remove its insn_chain structure as well.
+
 2000-10-09  J. David Anglin  <dave@hiauly1.hia.nrc.ca>
 
        * dbxout.c (dbxout_source_line): Remove extra tab.
index c556265f3126a2dfb1fae12dd88a1469c103486f..803fd010fafbc5e22cbbb7d7921bfb788cd4c9b4 100644 (file)
@@ -1330,15 +1330,17 @@ calculate_needs_all_insns (global)
      int global;
 {
   struct insn_chain **pprev_reload = &insns_need_reload;
-  struct insn_chain *chain;
+  struct insn_chain *chain, *next = 0;
 
   something_needs_elimination = 0;
 
   reload_insn_firstobj = (char *) obstack_alloc (&reload_obstack, 0);
-  for (chain = reload_insn_chain; chain != 0; chain = chain->next)
+  for (chain = reload_insn_chain; chain != 0; chain = next)
     {
       rtx insn = chain->insn;
 
+      next = chain->next;
+
       /* Clear out the shortcuts.  */
       chain->n_reloads = 0;
       chain->need_elim = 0;
@@ -1394,6 +1396,15 @@ calculate_needs_all_insns (global)
                  PUT_CODE (insn, NOTE);
                  NOTE_SOURCE_FILE (insn) = 0;
                  NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
+                 /* Delete it from the reload chain */
+                 if (chain->prev)
+                   chain->prev->next = next;
+                 else
+                   reload_insn_chain = next;
+                 if (next)
+                   next->prev = chain->prev;
+                 chain->next = unused_insn_chains;
+                 unused_insn_chains = chain;
                  continue;
                }
            }
index e1d64f358a3831e01b749d8a1f33ea66617c5132..5d13b7b5149409bc59fa116eea7bb8074414bef3 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20001009-1.c: New test.
+
 Mon Oct  9 23:32:06 MET DST 2000  Jan Hubicka  <jh@suse.cz>
 
        * gcc.c-torture/compile/20001009-1.c: Move from here ....
diff --git a/gcc/testsuite/gcc.dg/20001009-1.c b/gcc/testsuite/gcc.dg/20001009-1.c
new file mode 100644 (file)
index 0000000..91b58a6
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpic" } */
+
+extern void foo (void *a, double x, double y);
+void
+bar (void *a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k[6])
+{
+  double l, m, n, o, p;
+  double q, r, s, t, u;
+  double x, y, v, w;
+  double z = 0.5 * j;
+  double aa;
+  l = b - 3 * d;
+  m = 4 * f;
+  n = f - h;
+  q = c + 3 * g - i;
+  r = 2 * (e - 2 * g + i);
+  s = g - i;
+  if (l != 0.0)
+    {
+      aa = 0.0;
+      o = (- m + aa);
+      p = (- m - aa);
+      if (o > 0.0)
+        {
+          x = ((b-h)*o + 3*(d+h)*o + 3*(f-h)*o);
+          y = ((c-i)*o + 3*(e+i)*o + 3*(g-i)*o);
+          foo (a, z, w);
+          foo (a, -z, w);
+        }
+      if (p > 0.0)
+        {
+          x = ((b+3*f-h)*p + 3*(d-2*f+h)*p + 3*p);
+          y = ((c+3*g-i)*p + 3*(e-2*g+i)*p + 3*p);
+          v = x * k[0] + y * k[2];
+          w = x * k[1] + y * k[3];
+          foo (a, z, w);
+          foo (a, - z, w);
+        }
+    }
+  if (q != 0.0)
+    {
+      aa = 0.0;
+      t = (- r + aa) / (2 * q);
+      u = (- r - aa) / (2 * q);
+    }
+}