CONST0_RTX vs nested functions

Richard Henderson rth@redhat.com
Sat Jul 28 19:55:00 GMT 2001


This should fix the fortran failures Toon reported the other day.

I can't figure out why we prevented these special cases from 
matching while compiling the nested function.  It appears to be
good enough to clear their const_double_mem when we clear the
const_double_chain.  If these rtxes are in use in an outer 
function, then we'll assign new memories to them in reload.

Tested on alphaev6 linux.


r~


        * varasm.c (immed_real_const_1): Don't elide special cases for
        nested functions.
        (clear_const_double_mem): Clear const_tiny_rtx too.

Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.184
diff -c -p -d -r1.184 varasm.c
*** varasm.c	2001/07/26 06:56:13	1.184
--- varasm.c	2001/07/29 02:45:08
*************** immed_real_const_1 (d, mode)
*** 1917,1935 ****
  
    u.d = d;
  
!   /* Detect special cases.  But be careful we don't use a CONST_DOUBLE
!      that's from a parent function since it may be in its constant pool.  */
!   if (REAL_VALUES_IDENTICAL (dconst0, d)
!       && (cfun == 0 || decl_function_context (current_function_decl) == 0))
      return CONST0_RTX (mode);
  
    /* Check for NaN first, because some ports (specifically the i386) do not
       emit correct ieee-fp code by default, and thus will generate a core
       dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
       does a floating point comparison.  */
!   else if ((! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
! 	   && (cfun == 0
! 	       || decl_function_context (current_function_decl) == 0))
      return CONST1_RTX (mode);
  
    if (sizeof u == sizeof (HOST_WIDE_INT))
--- 1917,1931 ----
  
    u.d = d;
  
!   /* Detect special cases.  */
!   if (REAL_VALUES_IDENTICAL (dconst0, d))
      return CONST0_RTX (mode);
  
    /* Check for NaN first, because some ports (specifically the i386) do not
       emit correct ieee-fp code by default, and thus will generate a core
       dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
       does a floating point comparison.  */
!   else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
      return CONST1_RTX (mode);
  
    if (sizeof u == sizeof (HOST_WIDE_INT))
*************** void
*** 1996,2001 ****
--- 1992,1999 ----
  clear_const_double_mem ()
  {
    register rtx r, next;
+   enum machine_mode mode;
+   int i;
  
    for (r = const_double_chain; r; r = next)
      {
*************** clear_const_double_mem ()
*** 2004,2009 ****
--- 2002,2016 ----
        CONST_DOUBLE_MEM (r) = cc0_rtx;
      }
    const_double_chain = 0;
+ 
+   for (i = 0; i <= 2; i++)
+     for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
+          mode = GET_MODE_WIDER_MODE (mode))
+       {
+ 	r = const_tiny_rtx[i][(int) mode];
+ 	CONST_DOUBLE_CHAIN (r) = 0;
+ 	CONST_DOUBLE_MEM (r) = cc0_rtx;
+       }
  }
  
  /* Given an expression EXP with a constant value,



More information about the Gcc-patches mailing list