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]

insn-attrtab on diet version 2


HI
This version of patch don't compute the cost using which_alternative, that
caused code size increase on Alpha - now the inlining is avoided only when the
expression still expands to two or more function calls, so now it should bring
only the improvements.

The code size of insn-attrtab on i386 is now about 550Kb, insn-attrtab for
alpha is unchanged.

Mon Aug 16 12:23:48 CEST 2004  Jan Hubicka  <jh@suse.cz>
	* genattrtab.c (attr_rtx_cost): New function.
	(simplify_test_exp): Limit inlining using attr_rtx_cost.

*** /c/egcs/gcc/genattrtab.c	Tue Aug 29 14:02:33 2000
--- genattrtab.c	Mon Aug 16 09:41:23 2004
*************** static rtx attr_eq		PARAMS ((const char 
*** 461,466 ****
--- 461,467 ----
  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)
  
*************** simplify_or_tree (exp, pterm, insn_code,
*** 3178,3183 ****
--- 3179,3231 ----
  
    return exp;
  }
+ /* Compute approximate cost of the expression.  Used to decide whether
+    expression is cheap enought for inline.  */
+ static int
+ attr_rtx_cost (x)
+      rtx x;
+ {
+   int cost = 0;
+   enum rtx_code code;
+   if (!x)
+     return 0;
+   code = GET_CODE (x);
+   switch (code)
+     {
+     case MATCH_OPERAND:
+       if (XSTR (x, 1)[0])
+ 	return 10;
+       else
+ 	return 0;
+     case EQ_ATTR:
+       /* Alternatives don't result into function call.  */
+       if (!strcmp (XSTR (x, 0), "alternative"))
+ 	return 0;
+       else
+ 	return 5;
+     default:
+       {
+ 	int i, j;
+ 	const char *fmt = GET_RTX_FORMAT (code);
+ 	for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+ 	  {
+ 	    switch (fmt[i])
+ 	      {
+ 	      case 'V':
+ 	      case 'E':
+ 		for (j = 0; j < XVECLEN (x, i); j++)
+ 		  cost += attr_rtx_cost (XVECEXP (x, i, j));
+ 		break;
+ 	      case 'e':
+ 		cost += attr_rtx_cost (XEXP (x, i));
+ 		break;
+ 	      }
+ 	  }
+       }
+       break;
+     }
+   return cost;
+ }
  
  /* Given an expression, see if it can be simplified for a particular insn
     code based on the values of other attributes being tested.  This can
*************** simplify_test_exp (exp, insn_code, insn_
*** 3467,3473 ****
  	for (av = attr->first_value; av; av = av->next)
  	  for (ie = av->first_insn; ie; ie = ie->next)
  	    if (ie->insn_code == insn_code)
! 	      return evaluate_eq_attr (exp, av->value, insn_code, insn_index);
        break;
        
      default:
--- 3515,3526 ----
  	for (av = attr->first_value; av; av = av->next)
  	  for (ie = av->first_insn; ie; ie = ie->next)
  	    if (ie->insn_code == insn_code)
! 	      {
! 		rtx 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;
        
      default:

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