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] Fix tree-ssa-coalesce ICE on ASM_EXPR (PR tree-optimization/31866)


Hi!

create_outofssa_var_map ICEs on the attached testcase, because
DECL_REGISTER VAR_DECL input isn't SSA_NAME (that's correct).
create_outofssa_var_map needs SSA_NAME_VERSION of both the input
and output to coalesce them, therefore trying to do anything to
coalesce a VAR_DECL with SSA_NAME wouldn't fit well into the
current coalescing framework.

Ok for trunk?

BTW, the constraint analysis seems to be too simplistic to me,
although info gcc requests that if a number is together with some
other letters in one variant, it comes last (so "0rm" is invalid),
e.g. "0,1,2" or "0,rm" are valid constraints and I'm not sure if it
is a good idea to coalesce in that case.  My guess would be we want
to coalesce only if the constraint contains just a number (say "5"),
or if each variant contains the same number (say "1,1" or "5,5,5").

2007-06-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/31866
	* tree-ssa-coalesce.c (create_outofssa_var_map): Do nothing
	if ASM_EXPR's input is not a SSA_NAME.

	* gcc.dg/pr31866.c: New test.

--- gcc/tree-ssa-coalesce.c.jj	2007-06-13 17:38:55.000000000 +0200
+++ gcc/tree-ssa-coalesce.c	2007-06-20 13:18:39.000000000 +0200
@@ -1,5 +1,5 @@
 /* Coalesce SSA_NAMES together for the out-of-ssa pass.
-   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    Contributed by Andrew MacLeod <amacleod@redhat.com>
 
 This file is part of GCC.
@@ -1037,7 +1037,7 @@ create_outofssa_var_map (coalesce_list_p
 		    char *end;
 		    unsigned long match;
 
-		    if (TREE_CODE (input) != SSA_NAME && !DECL_P (input))
+		    if (TREE_CODE (input) != SSA_NAME)
 		      continue;
 
 		    match = strtoul (constraint, &end, 10);
--- gcc/testsuite/gcc.dg/pr31866.c.jj	2007-06-20 13:24:40.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr31866.c	2007-06-20 13:24:23.000000000 +0200
@@ -0,0 +1,28 @@
+/* PR tree-optimization/31866 */
+/* { dg-do compile { target alpha-*-* cris-*-* i?86-*-* mmix-*-* powerpc*-*-* rs6000-*-* x86_64-*-* } } */
+/* { dg-options "-O2" } */
+
+#if defined (__alpha__)
+# define REG "$1"
+#elif defined (__CRIS__)
+# define REG "r10"
+#elif defined (__i386__)
+# define REG "%eax"
+#elif defined (__MMIX__)
+# define REG "$8"
+#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
+	|| defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
+# define REG "6"
+#elif defined (__x86_64__)
+# define REG "rax"
+#endif
+
+long int
+foo (void)
+{
+  unsigned long int s;
+  long int a = (long int) 0;
+  register long int r asm (REG) = a;
+  asm ("" : "=r" (s) : "0" (r));
+  return s;
+}

	Jakub


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