From 0aacf12c55490c22e0f0efcc797fb1dbe36a7090 Mon Sep 17 00:00:00 2001
From: krebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 14 Jun 2006 14:19:54 +0000
Subject: [PATCH] 2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

	PR middle-end/27959
	* reload1.c (reload): Remove registers returned by update_eliminables
	from used_spill_regs.

2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>

	PR middle-end/27959
	* gcc.dg/pr27959.c: New testcase.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114640 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                  |  6 +++
 gcc/reload1.c                  |  2 +
 gcc/testsuite/ChangeLog        |  5 ++
 gcc/testsuite/gcc.dg/pr27959.c | 93 ++++++++++++++++++++++++++++++++++
 4 files changed, 106 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr27959.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f1760ff59e28..defc39d69221 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>
+
+	PR middle-end/27959
+	* reload1.c (reload): Remove registers returned by update_eliminables
+	from used_spill_regs.
+
 2006-06-13  DJ Delorie  <dj@redhat.com>
 
 	* config/m32c/muldiv.md (mulpsi3): Expect arbitrary constants.
diff --git a/gcc/reload1.c b/gcc/reload1.c
index d791da6ff32e..f426e1dbe1dd 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -989,6 +989,8 @@ reload (rtx first, int global)
 	HARD_REG_SET to_spill;
 	CLEAR_HARD_REG_SET (to_spill);
 	update_eliminables (&to_spill);
+	AND_COMPL_HARD_REG_SET(used_spill_regs, to_spill);
+
 	for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
 	  if (TEST_HARD_REG_BIT (to_spill, i))
 	    {
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5a547a7db757..8b7995506048 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-14  Andreas Krebbel  <krebbel1@de.ibm.com>
+
+	PR middle-end/27959
+	* gcc.dg/pr27959.c: New testcase.
+
 2006-06-13  J"orn Rennecke <joern.rennecke@st.com>
 
 	PR target/28014:
diff --git a/gcc/testsuite/gcc.dg/pr27959.c b/gcc/testsuite/gcc.dg/pr27959.c
new file mode 100644
index 000000000000..7118aec73c6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr27959.c
@@ -0,0 +1,93 @@
+/* PR middle-end/27959 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */
+
+extern void abort (void);
+
+struct B
+{
+  unsigned int b1, b2, b3;
+  char b4;
+};
+
+struct C
+{
+  char c1;
+};
+
+struct D
+{
+  char *d1;
+  struct C **d2;
+  unsigned int d3;
+};
+
+void
+__attribute__((noinline))
+foo (void *x, struct B *y, unsigned int *z)
+{
+  if (x)
+    abort ();
+  if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4)
+    abort ();
+  if (*z != 2)
+    abort ();
+}
+
+int
+__attribute__((noinline))
+baz (unsigned int *x, unsigned int y)
+{
+  asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
+  return *x + y;
+}
+
+inline int bar (unsigned int *x, unsigned int y)
+{
+  if (y < *x)
+    return 0;
+  return baz (x, y);
+}
+
+unsigned int *
+__attribute__((noinline))
+test (struct D *x, unsigned int *y)
+{
+  struct B b;
+  unsigned int c;
+
+  bar (y, x->d3);
+  if ((*(x->d2))->c1)
+    c = ((unsigned char) x->d1[0]
+	 + ((unsigned char) x->d1[1] << 8)
+	 + ((unsigned char) x->d1[2] << 16)
+	 + ((short) x->d1[3] << 24));
+  else
+    {
+      int d;
+      ((char *) &d)[0] = x->d1[0];
+      ((char *) &d)[1] = x->d1[1];
+      ((char *) &d)[2] = x->d1[2];
+      ((char *) &d)[3] = x->d1[3];
+      c = d;
+    }
+  b.b4 = 0;
+  b.b1 = c / 10000L % 10000;
+  b.b2 = c / 100 % 100;
+  b.b3 = c % 100;
+  foo (0, &b, y);
+  return y;
+}
+
+int
+main (void)
+{
+  unsigned int x = 900070503;
+  unsigned int y = 2;
+  struct C c = { 0 }, *cptr = &c;
+  struct D d = { (char *) &x, &cptr, 0 };
+  if (test (&d, &y) != &y)
+    abort ();
+  return 0;
+}
-- 
GitLab