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]

Kill CONST_DOUBLE_CHAIN


The only thing we use the CONST_DOUBLE_CHAIN for anymore is making all
CONST_DOUBLEs unique in the current function.  However, nothing seems
to care, and it complicates things unnecessarily.  CONST_DOUBLEs are
rare enough that I'm not particularly worried about wasting memory
with them (we may save just as much from getting rid of the chain
pointer).

This has bootstrapped on i686-linux with no regressions.  I am doing
an additional bootstrap with RTL checking turned on.  Meant to do that
last night, actually, but messed up my driver script so it didn't
happen.

I also made init_emit_once use REAL_VALUE_FROM_INT instead of
REAL_VALUE_ATOF (the fewer cycles we burn in setup, the sooner we
start compiling stuff) and made REAL_VALUE_TYPE be a macro again
(several headers check whether it's #defined in order to decide
whether they can use it in prototypes; this should squelch some
warnings).

zw

	* varasm.c (struct varasm_status): Remove x_const_double_chain field.
	(const_double_chain): Don't define.
	Remove stale comment.
	(immed_double_const): Don't search the const_double_chain, or
	put the new RTX on it.
	(immed_real_const_1): Likewise.  No need to check
	REAL_VALUE_ISNAN anymore; the emulator will not generate
	floating point traps.  Don't attempt to use immed_double_const.
	(clear_const_double_mem): Delete function.
	(init_varasm_status): Don't clear p->x_const_double_chain.
	(mark_varasm_status): Don't mark p->x_const_double_chain.

	* real.h (REAL_VALUE_TYPE): Make it a macro again.
	(CONST_DOUBLE_FORMAT): Remove the '0' slot at the beginning.
	* rtl.h: Don't define CONST_DOUBLE_CHAIN.  Slide
	CONST_DOUBLE_LOW and CONST_DOUBLE_HIGH down one slot.
	* output.h: Don't prototype clear_const_double_mem.

	* emit-rtl.c (gen_rtx_CONST_DOUBLE): The integer fields now
	start at slot 0.
	(init_emit_once): Use REAL_VALUE_FROM_INT.
	Don't set CONST_DOUBLE_CHAIN.
	* ggc-common.c (ggc_mark_rtx_children):
	Don't mark CONST_DOUBLE_CHAIN.
	* toplev.c (rest_of_compilation): Don't call
	clear_const_double_mem.

===================================================================
Index: emit-rtl.c
--- emit-rtl.c	22 Apr 2002 23:22:32 -0000	1.262
+++ emit-rtl.c	24 Apr 2002 18:06:22 -0000
@@ -375,11 +375,10 @@ gen_rtx_CONST_DOUBLE (mode, arg0, arg1)
   int i;
 
   PUT_MODE (r, mode);
-  X0EXP (r, 0) = NULL_RTX;
-  XWINT (r, 1) = arg0;
-  XWINT (r, 2) = arg1;
+  XWINT (r, 0) = arg0;
+  XWINT (r, 1) = arg1;
 
-  for (i = GET_RTX_LENGTH (CONST_DOUBLE) - 1; i > 2; --i)
+  for (i = GET_RTX_LENGTH (CONST_DOUBLE) - 1; i > 1; --i)
     XWINT (r, i) = 0;
 
   return r;
@@ -4915,10 +4914,10 @@ init_emit_once (line_numbers)
   else
     const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
 
-  dconst0 = REAL_VALUE_ATOF ("0", double_mode);
-  dconst1 = REAL_VALUE_ATOF ("1", double_mode);
-  dconst2 = REAL_VALUE_ATOF ("2", double_mode);
-  dconstm1 = REAL_VALUE_ATOF ("-1", double_mode);
+  REAL_VALUE_FROM_INT (dconst0,   0, 0, double_mode);
+  REAL_VALUE_FROM_INT (dconst1,   1, 0, double_mode);
+  REAL_VALUE_FROM_INT (dconst2,   2, 0, double_mode);
+  REAL_VALUE_FROM_INT (dconstm1, -1, 0, double_mode);
 
   for (i = 0; i <= 2; i++)
     {
@@ -4933,7 +4932,6 @@ init_emit_once (line_numbers)
 	  /* Can't use CONST_DOUBLE_FROM_REAL_VALUE here; that uses the
 	     tables we're setting up right now.  */
 	  memcpy (&CONST_DOUBLE_LOW (tem), r, sizeof (REAL_VALUE_TYPE));
-	  CONST_DOUBLE_CHAIN (tem) = NULL_RTX;
 	  PUT_MODE (tem, mode);
 
 	  const_tiny_rtx[i][(int) mode] = tem;
===================================================================
Index: ggc-common.c
--- ggc-common.c	27 Mar 2002 07:30:37 -0000	1.48
+++ ggc-common.c	24 Apr 2002 18:06:22 -0000
@@ -309,9 +309,6 @@ ggc_mark_rtx_children (r)
 	case ADDRESSOF:
 	  ggc_mark_tree (ADDRESSOF_DECL (r));
 	  break;
-	case CONST_DOUBLE:
-	  ggc_mark_rtx (CONST_DOUBLE_CHAIN (r));
-	  break;
 	case NOTE:
 	  switch (NOTE_LINE_NUMBER (r))
 	    {
===================================================================
Index: output.h
--- output.h	23 Apr 2002 07:20:51 -0000	1.98
+++ output.h	24 Apr 2002 18:06:23 -0000
@@ -354,11 +354,6 @@ extern void assemble_real		PARAMS ((REAL
 #endif
 #endif
 
-/* At the end of a function, forget the memory-constants
-   previously made for CONST_DOUBLEs.  Mark them as not on real_constant_chain.
-   Also clear out real_constant_chain and clear out all the chain-pointers.  */
-extern void clear_const_double_mem	PARAMS ((void));
-
 /* Start deferring output of subconstants.  */
 extern void defer_addressed_constants	PARAMS ((void));
 
===================================================================
Index: real.h
--- real.h	19 Apr 2002 00:14:48 -0000	1.40
+++ real.h	24 Apr 2002 18:06:23 -0000
@@ -89,7 +89,10 @@ Software Foundation, 59 Temple Place - S
    + (REAL_VALUE_TYPE_SIZE%HOST_BITS_PER_WIDE_INT ? 1 : 0)) /* round up */
 typedef struct {
   HOST_WIDE_INT r[REAL_WIDTH];
-} REAL_VALUE_TYPE;
+} realvaluetype;
+/* Various headers condition prototypes on #ifdef REAL_VALUE_TYPE, so it needs
+   to be a macro.  */
+#define REAL_VALUE_TYPE realvaluetype
 
 /* Calculate the format for CONST_DOUBLE.  We need as many slots as
    are necessary to overlay a REAL_VALUE_TYPE on them.  This could be
@@ -99,19 +102,19 @@ typedef struct {
    slots in a CONST_DOUBLE, so we provide them even if one would suffice.  */
 
 #if REAL_WIDTH == 1
-# define CONST_DOUBLE_FORMAT	 "0ww"
+# define CONST_DOUBLE_FORMAT	 "ww"
 #else
 # if REAL_WIDTH == 2
-#  define CONST_DOUBLE_FORMAT	 "0ww"
+#  define CONST_DOUBLE_FORMAT	 "ww"
 # else
 #  if REAL_WIDTH == 3
-#   define CONST_DOUBLE_FORMAT	 "0www"
+#   define CONST_DOUBLE_FORMAT	 "www"
 #  else
 #   if REAL_WIDTH == 4
-#    define CONST_DOUBLE_FORMAT	 "0wwww"
+#    define CONST_DOUBLE_FORMAT	 "wwww"
 #   else
 #    if REAL_WIDTH == 5
-#     define CONST_DOUBLE_FORMAT "0wwwww"
+#     define CONST_DOUBLE_FORMAT "wwwww"
 #    else
       #error "REAL_WIDTH > 5 not supported"
 #    endif
===================================================================
Index: rtl.h
--- rtl.h	22 Apr 2002 23:22:31 -0000	1.339
+++ rtl.h	24 Apr 2002 18:06:23 -0000
@@ -819,11 +819,8 @@ extern const char * const note_insn_name
    For a float, the number of ints varies,
     and CONST_DOUBLE_LOW is the one that should come first *in memory*.
     So use &CONST_DOUBLE_LOW(r) as the address of an array of ints.  */
-#define CONST_DOUBLE_LOW(r) XCWINT (r, 1, CONST_DOUBLE)
-#define CONST_DOUBLE_HIGH(r) XCWINT (r, 2, CONST_DOUBLE)
-
-/* Link for chain of all CONST_DOUBLEs in use in current function.  */
-#define CONST_DOUBLE_CHAIN(r) XCEXP (r, 0, CONST_DOUBLE)
+#define CONST_DOUBLE_LOW(r) XCWINT (r, 0, CONST_DOUBLE)
+#define CONST_DOUBLE_HIGH(r) XCWINT (r, 1, CONST_DOUBLE)
 
 /* For a CONST_VECTOR, return element #n.  */
 #define CONST_VECTOR_ELT(RTX, N) XCVECEXP (RTX, 0, N, CONST_VECTOR)
===================================================================
Index: toplev.c
--- toplev.c	19 Apr 2002 16:21:54 -0000	1.613
+++ toplev.c	24 Apr 2002 18:06:24 -0000
@@ -3445,10 +3445,6 @@ rest_of_compilation (decl)
      longer valid.  */
   init_insn_lengths ();
 
-  /* Clear out the real_constant_chain before some of the rtx's
-     it runs through become garbage.  */
-  clear_const_double_mem ();
-
   /* Show no temporary slots allocated.  */
   init_temp_slots ();
 
===================================================================
Index: varasm.c
--- varasm.c	29 Mar 2002 21:46:04 -0000	1.264
+++ varasm.c	24 Apr 2002 18:06:25 -0000
@@ -95,10 +95,6 @@ struct varasm_status
   /* Current offset in constant pool (does not include any machine-specific
      header).  */
   HOST_WIDE_INT x_pool_offset;
-
-  /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
-     They are chained through the CONST_DOUBLE_CHAIN.  */
-  rtx x_const_double_chain;
 };
 
 #define const_rtx_hash_table (cfun->varasm->x_const_rtx_hash_table)
@@ -106,7 +102,6 @@ struct varasm_status
 #define first_pool (cfun->varasm->x_first_pool)
 #define last_pool (cfun->varasm->x_last_pool)
 #define pool_offset (cfun->varasm->x_pool_offset)
-#define const_double_chain (cfun->varasm->x_const_double_chain)
 
 /* Number for making the label on the next
    constant that is stored in memory.  */
@@ -2102,9 +2097,6 @@ assemble_real (d, mode, align)
     }
 }
 
-/* Here we combine duplicate floating constants to make
-   CONST_DOUBLE rtx's, and force those out to memory when necessary.  */
-
 /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
    For an integer, I0 is the low-order word and I1 is the high-order word.
    For a real number, I0 is the word with the low address
@@ -2115,8 +2107,6 @@ immed_double_const (i0, i1, mode)
      HOST_WIDE_INT i0, i1;
      enum machine_mode mode;
 {
-  rtx r;
-
   if (GET_MODE_CLASS (mode) == MODE_INT
       || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
     {
@@ -2177,28 +2167,10 @@ immed_double_const (i0, i1, mode)
       mode = VOIDmode;
     }
 
-  /* Search the chain for an existing CONST_DOUBLE with the right value.
-     If one is found, return it.  */
-  if (cfun != 0)
-    for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
-      if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
-	  && GET_MODE (r) == mode)
-	return r;
-
-  /* No; make a new one and add it to the chain.  */
-  r = gen_rtx_CONST_DOUBLE (mode, i0, i1);
-
-  /* Don't touch const_double_chain if not inside any function.  */
-  if (current_function_decl != 0)
-    {
-      CONST_DOUBLE_CHAIN (r) = const_double_chain;
-      const_double_chain = r;
-    }
-
-  return r;
+  return gen_rtx_CONST_DOUBLE (mode, i0, i1);
 }
 
-/* Return a CONST_DOUBLE for a specified `double' value
+/* Return a CONST_DOUBLE for a value specified by a REAL_VALUE_TYPE
    and machine mode.  */
 
 rtx
@@ -2208,54 +2180,20 @@ immed_real_const_1 (d, mode)
 {
   rtx r;
 
-  /* Detect special cases.  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.  */
-  if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_IDENTICAL (dconst0, d))
+  /* Detect special cases.  Must use REAL_VALUES_IDENTICAL for
+     dconst0 so that it doesn't get used for negative zero.  */
+  if (REAL_VALUES_IDENTICAL (dconst0, d))
     return CONST0_RTX (mode);
-  else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
+  else if (REAL_VALUES_EQUAL (dconst1, d))
     return CONST1_RTX (mode);
-  else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst2, d))
+  else if (REAL_VALUES_EQUAL (dconst2, d))
     return CONST2_RTX (mode);
 
-  if (sizeof (REAL_VALUE_TYPE) == sizeof (HOST_WIDE_INT))
-    return immed_double_const (d.r[0], 0, mode);
-  if (sizeof (REAL_VALUE_TYPE) == 2 * sizeof (HOST_WIDE_INT))
-    return immed_double_const (d.r[0], d.r[1], mode);
-
-  /* The rest of this function handles the case where
-     a float value requires more than 2 ints of space.
-     It will be deleted as dead code on machines that don't need it.  */
-
-  /* Search the chain for an existing CONST_DOUBLE with the right value.
-     If one is found, return it.  */
-  if (cfun != 0)
-    for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
-      if (! memcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &d, sizeof d)
-	  && GET_MODE (r) == mode)
-	return r;
-
-  /* No; make a new one and add it to the chain.
-
-     We may be called by an optimizer which may be discarding any memory
-     allocated during its processing (such as combine and loop).  However,
-     we will be leaving this constant on the chain, so we cannot tolerate
-     freed memory.  */
+  /* Otherwise, allocate and return a fresh CONST_DOUBLE.  */
   r = rtx_alloc (CONST_DOUBLE);
   PUT_MODE (r, mode);
   memcpy ((char *) &CONST_DOUBLE_LOW (r), (char *) &d, sizeof d);
 
-  /* If we aren't inside a function, don't put r on the
-     const_double_chain.  */
-  if (current_function_decl != 0)
-    {
-      CONST_DOUBLE_CHAIN (r) = const_double_chain;
-      const_double_chain = r;
-    }
-  else
-    CONST_DOUBLE_CHAIN (r) = NULL_RTX;
-
   return r;
 }
 
@@ -2269,22 +2207,6 @@ immed_real_const (exp)
   return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
 }
 
-/* At the end of a function, forget the memory-constants
-   previously made for CONST_DOUBLEs.  Mark them as not on real_constant_chain.
-   Also clear out real_constant_chain and clear out all the chain-pointers.  */
-
-void
-clear_const_double_mem ()
-{
-  rtx r, next;
-
-  for (r = const_double_chain; r; r = next)
-    {
-      next = CONST_DOUBLE_CHAIN (r);
-      CONST_DOUBLE_CHAIN (r) = 0;
-    }
-  const_double_chain = 0;
-}
 
 /* Given an expression EXP with a constant value,
    reduce it to the sum of an assembler symbol and an integer.
@@ -3466,7 +3388,6 @@ init_varasm_status (f)
 
   p->x_first_pool = p->x_last_pool = 0;
   p->x_pool_offset = 0;
-  p->x_const_double_chain = 0;
 }
 
 /* Mark PC for GC.  */
@@ -3494,7 +3415,6 @@ mark_varasm_status (p)
     return;
 
   mark_pool_constant (p->x_first_pool);
-  ggc_mark_rtx (p->x_const_double_chain);
 }
 
 /* Clear out all parts of the state in F that can safely be discarded






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