PATCH: [3.3 branch] IA64 bootstrap failure

H. J. Lu hjl@lucon.org
Tue Jul 8 21:56:00 GMT 2003


On Tue, Jul 08, 2003 at 02:11:42PM -0700, H. J. Lu wrote:
> On Tue, Jul 08, 2003 at 07:37:05AM -0700, H. J. Lu wrote:
> > On Tue, Jul 08, 2003 at 04:10:33PM +0200, Andreas Schwab wrote:
> > > Eric Botcazou <ebotcazou@libertysurf.fr> writes:
> > > 
> > > |> > @@ -2054,10 +2054,10 @@
> > > |> >      2a50:	0b 70 00 1e 18 10 	[MMI]       ld8 r14=[r15];;
> > > |> >      2a56:	70 00 38 0c 72 00 	            cmp.eq p7,p6=0,r14
> > > |> >      2a5c:	00 00 04 00       	            nop.i 0x0;;
> > > |> > -    2a60:	dc 00 20 40 98 11 	[MFB] (p06) st8 [r32]=r8
> > > |> > +    2a60:	fc 00 20 1e 98 11 	[MFB] (p07) st8 [r15]=r8
> > > |> >      2a66:	00 00 00 02 00 00 	            nop.f 0x0
> > > |> >      2a6c:	00 00 00 20       	            nop.b 0x0
> > > |> > -    2a70:	e0 00 20 1e 98 11 	[MII] (p07) st8 [r15]=r8
> > > |> > +    2a70:	c0 00 20 40 98 11 	[MII] (p06) st8 [r32]=r8
> > > |> >      2a76:	f0 c0 22 00 42 00 	            adds r15=88,r8
> > > |> >      2a7c:	04 40 00 84       	            mov r32=r8
> > > |> >      2a80:	0a 70 00 46 18 10 	[MMI]       ld8 r14=[r35];;
> > > |> 
> > > |> It bears some ressemblance with PR optimization/11320, where the machine 
> > > |> dependent reorg pass also swaps two insns.
> > > 
> > > Could be, but then I would have expected that the stage1 compiler
> > > generates the same code.  I'd rather think this is similar to the problem
> > > that lead to the replacement of PWD with PWD_COMMAND.
> > > 
> > 
> > Yes, it is true. Can you duplicate the result on the command line? If
> > not, can you duplicate it with Makefile?
> > 
> 
> I found:
> 
> /* If we don't have __builtin_constant_p, or it's not acceptable in
>    array initializers, fall back to assuming that all conditions
>    potentially vary at run time.  It works in 3.0.1 and later; 3.0
>    only when not optimizing.  */
> #if (GCC_VERSION >= 3001) || ((GCC_VERSION == 3000) && !__OPTIMIZE__)
> # define MAYBE_EVAL(expr) (__builtin_constant_p(expr) ? (int) (expr) : -1)
> #else
> # define MAYBE_EVAL(expr) -1
> #endif
> 
> in the generated insn-conditions.c. It means the stage1 compiler may
> be different from the stage2 compiler, depending on what compiler is
> used to bootstrap gcc. I think insn-conditions.c should be the same
> regardless the compiler used to boostrap.
> 
> 

I am testing this patch now.


H.J.
-------------- next part --------------
2003-07-08  H.J. Lu <hongjiu.lu@intel.com>

	* aclocal.m4 (gcc_AC_BUILTIN_CONSTANT_P): New.
	* configure.in: Use it.
	* configure: Regenerated.
	* config.in: Likewise.

	* genconditions.c (write_header): Use __builtin_constant_p if
	HAVE_BUILTIN_CONSTANT_P is defined.

--- gcc/aclocal.m4.const	2003-07-07 14:44:27.000000000 -0700
+++ gcc/aclocal.m4	2003-07-08 14:51:54.000000000 -0700
@@ -1454,3 +1454,23 @@ EOF
     AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
       [Define .init_array/.fini_array sections are available and working.])
   fi])
+
+dnl Check if __builtin_constant_p can be used in array initializers.
+AC_DEFUN(gcc_AC_BUILTIN_CONSTANT_P,
+[AC_CACHE_CHECK([for working __builtin_constant_p],
+  ac_cv_builtin_constant_p,
+[AC_TRY_COMPILE([
+extern int i;
+
+int x [2] =
+{
+  __builtin_constant_p (10) ? 10 : -1,
+  __builtin_constant_p (i) ? (int) i : -1
+};
+], ,
+ac_cv_builtin_constant_p=yes, ac_cv_builtin_constant_p=no)])
+if test $ac_cv_builtin_constant_p = yes; then
+  AC_DEFINE(HAVE_BUILTIN_CONSTANT_P, 1,
+  [Define if you have a working __builtin_constant_p.])
+fi
+])
--- gcc/configure.in.const	2003-07-08 14:38:39.000000000 -0700
+++ gcc/configure.in	2003-07-08 14:38:39.000000000 -0700
@@ -788,6 +788,9 @@ AC_ARG_ENABLE(initfini-array,
 # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
 CFLAGS="$saved_CFLAGS"
 
+# Check if __builtin_constant_p can be used to in array initializers.
+gcc_AC_BUILTIN_CONSTANT_P
+
 # mkdir takes a single argument on some systems. 
 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
 
--- gcc/genconditions.c.const	2002-07-29 11:02:47.000000000 -0700
+++ gcc/genconditions.c	2003-07-08 14:38:39.000000000 -0700
@@ -1,5 +1,5 @@
 /* Process machine description and calculate constant conditions.
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GNU CC.
 
@@ -120,16 +120,11 @@ extern rtx ins1;\n\
 extern rtx operands[];\n\
 extern int next_insn_tests_no_inequality PARAMS ((rtx));\n");
 
-  puts ("\
-/* If we don't have __builtin_constant_p, or it's not acceptable in\n\
-   array initializers, fall back to assuming that all conditions\n\
-   potentially vary at run time.  It works in 3.0.1 and later; 3.0\n\
-   only when not optimizing.  */\n\
-#if (GCC_VERSION >= 3001) || ((GCC_VERSION == 3000) && !__OPTIMIZE__)\n\
-# define MAYBE_EVAL(expr) (__builtin_constant_p(expr) ? (int) (expr) : -1)\n\
-#else\n\
-# define MAYBE_EVAL(expr) -1\n\
-#endif\n");
+#ifdef HAVE_BUILTIN_CONSTANT_P
+  puts ("# define MAYBE_EVAL(expr) (__builtin_constant_p(expr) ? (int) (expr) : -1)\n");
+#else
+  puts ("# define MAYBE_EVAL(expr) -1\n");
+#endif
 }
 
 /* Write out one entry in the conditions table, using the data pointed


More information about the Gcc-patches mailing list