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]

genattrtab memory usage reduction


Howdy,

In genattrtab, there is no need to copy rtxs.  Doing so only
consumes extra memory, causing my system to run out when
bootstrapping (64 megabytes on i586-pc-linux-gnu).

With the following patch, GCC bootstraps on my system.  I can't
check for any regressions as I don't have a working baseline.  OK
to commit?

Matt

2001-05-20  Matt Kraai  <kraai@alumni.carnegiemellon.edu>

	* genattrtab.c (attr_copy_rtx): Remove it.
	(simplify_test_exp): Remove temp_obstack references.
	(simplify_test_exp): Remove call to attr_copy_rtx.
	(expand_units): Likewise.
	(optimize_attrs): Likewise.

Index: gcc/genattrtab.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genattrtab.c,v
retrieving revision 1.90
diff -c -3 -p -r1.90 genattrtab.c
*** genattrtab.c	2001/04/13 21:10:14	1.90
--- genattrtab.c	2001/05/21 04:05:55
*************** static void extend_range	PARAMS ((struct
*** 459,465 ****
  static rtx attr_eq		PARAMS ((const char *, const char *));
  static const char *attr_numeral	PARAMS ((int));
  static int attr_equal_p		PARAMS ((rtx, rtx));
- static rtx attr_copy_rtx	PARAMS ((rtx));
  static int attr_rtx_cost 	PARAMS ((rtx));
  
  #define oballoc(size) obstack_alloc (hash_obstack, size)
--- 459,464 ----
*************** attr_equal_p (x, y)
*** 829,920 ****
  		     && rtx_equal_p (x, y)));
  }
  
- /* Copy an attribute value expression,
-    descending to all depths, but not copying any
-    permanent hashed subexpressions.  */
- 
- static rtx
- attr_copy_rtx (orig)
-      register rtx orig;
- {
-   register rtx copy;
-   register int i, j;
-   register RTX_CODE code;
-   register const char *format_ptr;
- 
-   /* No need to copy a permanent object.  */
-   if (RTX_INTEGRATED_P (orig))
-     return orig;
- 
-   code = GET_CODE (orig);
- 
-   switch (code)
-     {
-     case REG:
-     case QUEUED:
-     case CONST_INT:
-     case CONST_DOUBLE:
-     case SYMBOL_REF:
-     case CODE_LABEL:
-     case PC:
-     case CC0:
-       return orig;
- 
-     default:
-       break;
-     }
- 
-   copy = rtx_alloc (code);
-   PUT_MODE (copy, GET_MODE (orig));
-   copy->in_struct = orig->in_struct;
-   copy->volatil = orig->volatil;
-   copy->unchanging = orig->unchanging;
-   copy->integrated = orig->integrated;
- 
-   format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
- 
-   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
-     {
-       switch (*format_ptr++)
- 	{
- 	case 'e':
- 	  XEXP (copy, i) = XEXP (orig, i);
- 	  if (XEXP (orig, i) != NULL)
- 	    XEXP (copy, i) = attr_copy_rtx (XEXP (orig, i));
- 	  break;
- 
- 	case 'E':
- 	case 'V':
- 	  XVEC (copy, i) = XVEC (orig, i);
- 	  if (XVEC (orig, i) != NULL)
- 	    {
- 	      XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
- 	      for (j = 0; j < XVECLEN (copy, i); j++)
- 		XVECEXP (copy, i, j) = attr_copy_rtx (XVECEXP (orig, i, j));
- 	    }
- 	  break;
- 
- 	case 'n':
- 	case 'i':
- 	  XINT (copy, i) = XINT (orig, i);
- 	  break;
- 
- 	case 'w':
- 	  XWINT (copy, i) = XWINT (orig, i);
- 	  break;
- 
- 	case 's':
- 	case 'S':
- 	  XSTR (copy, i) = XSTR (orig, i);
- 	  break;
- 
- 	default:
- 	  abort ();
- 	}
-     }
-   return copy;
- }
- 
  /* Given a test expression for an attribute, ensure it is validly formed.
     IS_CONST indicates whether the expression is constant for each compiler
     run (a constant expression may not test any particular insn).
--- 828,833 ----
*************** expand_units ()
*** 1961,1967 ****
  	{
  	  XEXP (newexp, 0) = unit->condexp;
  	  XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
! 	  unitsmask = operate_exp (ORX_OP, unitsmask, attr_copy_rtx (newexp));
  	}
      }
  
--- 1874,1880 ----
  	{
  	  XEXP (newexp, 0) = unit->condexp;
  	  XEXP (newexp, 1) = make_numeric_value (1 << unit->num);
! 	  unitsmask = operate_exp (ORX_OP, unitsmask, newexp);
  	}
      }
  
*************** simplify_test_exp (exp, insn_code, insn_
*** 3464,3476 ****
  	    if (ie->insn_code == insn_code)
  	      {
  		rtx x;
- 		struct obstack *old = rtl_obstack;
- 		rtl_obstack = temp_obstack;
  		x = evaluate_eq_attr (exp, av->value, insn_code, insn_index);
  		x = SIMPLIFY_TEST_EXP (x, insn_code, insn_index);
- 		rtl_obstack = old;
  		if (attr_rtx_cost(x) < 20)
! 		  return attr_copy_rtx (x);
  	      }
        break;
  
--- 3377,3386 ----
  	    if (ie->insn_code == insn_code)
  	      {
  		rtx x;
  		x = evaluate_eq_attr (exp, av->value, insn_code, insn_index);
  		x = SIMPLIFY_TEST_EXP (x, insn_code, insn_index);
  		if (attr_rtx_cost(x) < 20)
! 		  return x;
  	      }
        break;
  
*************** optimize_attrs ()
*** 3585,3591 ****
  	      rtl_obstack = old;
  	      if (newexp != av->value)
  		{
- 		  newexp = attr_copy_rtx (newexp);
  		  remove_insn_ent (av, ie);
  		  av = get_attr_value (newexp, attr, ie->insn_code);
  		  iv->av = av;
--- 3495,3500 ----


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