This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix decl_overlaps_hard_reg_set_p (4.1 regression, PR middle-end/26334)


On Fri, Feb 17, 2006 at 02:27:00PM -0800, Mark Mitchell wrote:
> Jakub Jelinek wrote:
> 
> > 2006-02-17  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR middle-end/26334
> > 	* stmt.c (decl_overlaps_hard_reg_set_p): Only look at
> > 	DECL_RTL of DECL_REGISTER if DECL_ASSEMBLER_NAME_SET_P.
> 
> I think it would be better to check DECL_HARD_REGISTER.
> DECL_ASSEMBLER_NAME is computed lazily, so it's best not to reply on
> DECL_ASSEMBLER_NAME_SET_P as having any semantic meaning.

DECL_HARD_REGISTER works, so I have committed the patch to gcc-4_1-branch.

> After the change to use DECL_HARD_REGISTER, the checks for REG_P (...)
> and REGNO (...) < FIRST_PSEUDO_REGISTER  should be reundant; on the
> mainline, please move them into an assert.  Leave it as is for 4.1, for

But replacing REG_P (...) and REGNO (...) < FIRST_PSEUDO_REGISTER with
gcc_assert does not work, as shown on the gcc.dg/20060218-1.c testcase
(where with the gcc_assert we get invalid register name error
followed by ICE).
So, can I commit the same patch that's on the gcc-4_1-branch to the trunk
as well?  I haven't committed the gcc.dg/20060218-1.c testcase to the
branch, as I didn't include it in the patch I bootstrapped/regtested
on gcc-4_1-branch, only in the trunk bootstrap/regression testing.

2006-02-18  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/26334
	* stmt.c (decl_overlaps_hard_reg_set_p): Use DECL_HARD_REGISTER
	instead of DECL_REGISTER.

	* gcc.c-torture/compile/20060217-1.c: New test.
	* gcc.dg/20060218-1.c: New test.

--- gcc/stmt.c.jj	2006-02-16 08:23:00.000000000 +0100
+++ gcc/stmt.c	2006-02-18 09:36:27.000000000 +0100
@@ -567,9 +567,9 @@ decl_overlaps_hard_reg_set_p (tree *decl
   tree decl = *declp;
   const HARD_REG_SET *regs = data;
 
-  if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
+  if (TREE_CODE (decl) == VAR_DECL)
     {
-      if (DECL_REGISTER (decl)
+      if (DECL_HARD_REGISTER (decl)
 	  && REG_P (DECL_RTL (decl))
 	  && REGNO (DECL_RTL (decl)) < FIRST_PSEUDO_REGISTER)
 	{
@@ -585,7 +585,7 @@ decl_overlaps_hard_reg_set_p (tree *decl
 	}
       walk_subtrees = 0;
     }
-  else if (TYPE_P (decl))
+  else if (TYPE_P (decl) || TREE_CODE (decl) == PARM_DECL)
     walk_subtrees = 0;
   return NULL_TREE;
 }
--- gcc/testsuite/gcc.c-torture/compile/20060217-1.c.jj	2006-02-18 09:11:30.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20060217-1.c	2006-02-18 09:11:30.000000000 +0100
@@ -0,0 +1,25 @@
+/* PR middle-end/26334 */
+
+struct U
+{
+  unsigned int u[256];
+};
+
+struct S
+{
+  int u, v, w, x;
+  int s[255];
+};
+
+int
+foo (struct U *x, struct S *y)
+{
+  register int i;
+  for (i = 0; i < 255; i++)
+    {
+      unsigned int v;
+      __asm__ ("" : "=r" (v) : "0" (x->u[i + 1]) : "cc");
+      y->s[i] = v;
+    }
+  return 0;
+}
--- gcc/testsuite/gcc.dg/20060218-1.c.jj	2006-02-18 09:27:38.000000000 +0100
+++ gcc/testsuite/gcc.dg/20060218-1.c	2006-02-18 09:28:12.000000000 +0100
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  register int cc __asm ("cc"); /* { dg-error "invalid register name" } */
+  __asm ("" : : "r" (cc) : "cc");
+}


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]