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]

[PATCH] PR tree-optimization/29877: handling of register vars during TER


This patch fixes PR29877, which concerns erroneous extensions of
the lifetimes of register variables.  This was being caused by the
TER pass incorrectly removing assignments with a register variable
on the RHS.

There was some discussion internally as to what to do about the
somewhat fragile testcase involved in the patch; that below was
eventually settled on.

This patch causes no regressions on x86_64-unknown-linux-gnu with all
default languages enabled.  OK to apply to mainline?

Mark

--


2006-12-24 Mark Shinwell <shinwell@codesourcery.com>


	PR tree-optimization/29877
	gcc/
	* tree-ssa-ter.c (is_replaceable_p): Deem assignments with
	a register variable on the RHS to not be replaceable.

	gcc/testsuite/
	* gcc.dg/pr16194.c: Skip test entirely if we don't know the
	name of a hard register for the target concerned.  Adjust dg-error
	directives to cope with new behaviour of TER.
Index: gcc/testsuite/gcc.dg/pr16194.c
===================================================================
--- gcc/testsuite/gcc.dg/pr16194.c	(revision 119735)
+++ gcc/testsuite/gcc.dg/pr16194.c	(working copy)
@@ -2,6 +2,7 @@
 /* { dg-options "-O" } */
 /* { dg-bogus "internal compiler error" "ICE" { target *-*-* } 0 } */
 
+#undef SKIP
 #define ASMDECL __asm (REG);
 #define CLOBBER_LIST : REG
 #define INP_CLOBBER_LIST : CLOBBER_LIST
@@ -18,17 +19,15 @@
 # define REG "6"
 #elif defined (__x86_64__)
 # define REG "rax"
+#elif defined (__m68k__)
+# define REG "%d0"
 #else
-  /* Make this test harmless for any target not recognized above.  */
-# undef ASMDECL
-# define ASMDECL
-# define REG "conflict"
-# undef CLOBBER_LIST
-# define CLOBBER_LIST
-# undef INP_CLOBBER_LIST
-# define INP_CLOBBER_LIST
+/* Make this test harmless for any target not recognized above.  */
+# define SKIP 1
 #endif
 
+#ifndef SKIP
+
 struct A
 {
   int a;
@@ -47,7 +46,7 @@ struct C
 void bug (void)
 {
   register char* dst ASMDECL;
-  __asm__ ("":"=g"(*dst): : REG); /* { dg-error "conflict" } */
+  __asm__ ("":"=g"(*dst): : REG);
 }
 
 /* The tree optimizers currently prevent us from finding an overlap -
@@ -65,3 +64,13 @@ foo (void)
   register struct C *dst ASMDECL;
   __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST);
 }
+
+#else
+
+int main ()
+{
+  return 0;
+}
+
+#endif
+
Index: gcc/tree-ssa-ter.c
===================================================================
--- gcc/tree-ssa-ter.c	(revision 119735)
+++ gcc/tree-ssa-ter.c	(working copy)
@@ -393,6 +393,12 @@ is_replaceable_p (tree stmt)
       && FLOAT_TYPE_P (TREE_TYPE (GENERIC_TREE_OPERAND (stmt, 1))))
     return false;
 
+  /* An assignment with a register variable on the RHS is not
+     replaceable.  */
+  if (TREE_CODE (GENERIC_TREE_OPERAND (stmt, 1)) == VAR_DECL
+      && DECL_HARD_REGISTER (GENERIC_TREE_OPERAND (stmt, 1)))
+    return false;
+
   /* Calls to functions with side-effects cannot be replaced.  */
   if ((call_expr = get_call_expr_in (stmt)) != NULL_TREE)
     {

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