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]

genattrtab speedup 1/4


Hi,

I seem to be the master of bad timing, posting this long standing thing 
again during stage 3 :-|  But IMHO it could still be accepted as the scope 
is relatively limited (and there are some real bugs fixed too).

This and the following three patches (together with a small fix in the C++ 
frontend) make the building and compilation of insn-attrtab.c much faster, 
with the side-effect that insn-attrtab.o will be quite a bit smaller.

The slowness of running genattrtab (on i386,ia64,x86_64 and ppc at least) 
and even more the compilation of the resulting insn-attrtab.c with the 
stage1 compiler (even more so, when checking is enabled) is a major 
serialization point in a parallel bootstrap.  IIRC I heard someone for 
whom compiling insn-attrtab.c (on ppc?) took 30 minutes.

I post four separate patches to hopefully make the review easier.  I did
several performance assessments on several architectures with the patches
applied successively.  The results will come with the fourth patch.  
Bootstrapping and regression testing I did only with all patches combined.

This first patch is merely a cleanup, which is fairly obvious.  
'current_alternative_string' is not set anywhere, hence all code depending 
on it is dead.  Second there is a small type in simplify_test_exp in the 
AND case, where it tests 'left' twice for falseness and misses testing 
'right'.  Fixing this obvious type btw. makes the resulting insn-attrtab.c 
even larger and slower on x86-64 :-)

Okay?


Ciao,
Michael.
-- 
	* genattrtab.c (current_alternative_string): Remove.
	(SIMPLIFY_ALTERNATIVE): Ditto.
	(attr_alt_bit_p): Ditto.
	(alternative_name): Make const char *.
	(evaluate_eq_attr): Remove use of above things.
	(simplify_test_exp): Ditto.
	(simplify_test_exp <EQ_ATTR>): Guard for insn_code < 0 .
	(simplify_test_exp <AND>): Correct typo (test 'right' not 'left').
	
--- genattrtab.cvs.c	2005-07-13 13:52:30.000000000 +0200
+++ genattrtab.clean.c	2005-07-29 19:48:05.000000000 +0200
@@ -228,19 +228,13 @@ static int *insn_n_alternatives;
 
 static int *insn_alternatives;
 
-/* If nonzero, assume that the `alternative' attr has this value.
-   This is the hashed, unique string for the numeral
-   whose value is chosen alternative.  */
-
-static const char *current_alternative_string;
-
 /* Used to simplify expressions.  */
 
 static rtx true_rtx, false_rtx;
 
 /* Used to reduce calls to `strcmp' */
 
-static char *alternative_name;
+static const char *alternative_name;
 static const char *length_str;
 static const char *delay_type_str;
 static const char *delay_1_0_str;
@@ -262,15 +256,6 @@ int optimize = 0;
   (ATTR_IND_SIMPLIFIED_P (EXP) || ATTR_CURR_SIMPLIFIED_P (EXP) ? (EXP)	\
    : simplify_test_exp (EXP, INSN_CODE, INSN_INDEX))
 
-/* Simplify (eq_attr ("alternative") ...)
-   when we are working with a particular alternative.  */
-#define SIMPLIFY_ALTERNATIVE(EXP)				\
-  if (current_alternative_string				\
-      && GET_CODE ((EXP)) == EQ_ATTR				\
-      && XSTR ((EXP), 0) == alternative_name)			\
-    (EXP) = (XSTR ((EXP), 1) == current_alternative_string	\
-	    ? true_rtx : false_rtx);
-
 #define DEF_ATTR_STRING(S) (attr_string ((S), strlen (S)))
 
 /* These are referenced by rtlanal.c and hence need to be defined somewhere.
@@ -352,7 +337,6 @@ static bool attr_alt_subset_of_compl_p (
 static rtx attr_alt_intersection (rtx, rtx);
 static rtx attr_alt_union (rtx, rtx);
 static rtx attr_alt_complement (rtx);
-static bool attr_alt_bit_p (rtx, int);
 static rtx mk_attr_alt (int);
 
 #define oballoc(size) obstack_alloc (hash_obstack, size)
@@ -1106,7 +1090,7 @@ check_attr_value (rtx exp, struct attr_d
 }
 
 /* Given an SET_ATTR_ALTERNATIVE expression, convert to the canonical SET.
-   It becomes a COND with each test being (eq_attr "alternative "n") */
+   It becomes a COND with each test being (eq_attr "alternative" "n") */
 
 static rtx
 convert_set_attr_alternative (rtx exp, struct insn_def *id)
@@ -2035,16 +2019,11 @@ evaluate_eq_attr (rtx exp, rtx value, in
       orexp = false_rtx;
       andexp = true_rtx;
 
-      if (current_alternative_string)
-	clear_struct_flag (value);
-
       for (i = 0; i < XVECLEN (value, 0); i += 2)
 	{
 	  rtx this = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
 						insn_code, insn_index);
 
-	  SIMPLIFY_ALTERNATIVE (this);
-
 	  right = insert_right_side (AND, andexp, this,
 				     insn_code, insn_index);
 	  right = insert_right_side (AND, right,
@@ -2082,7 +2061,6 @@ evaluate_eq_attr (rtx exp, rtx value, in
 
   if (address_used)
     {
-      /* This had `&& current_alternative_string', which seems to be wrong.  */
       if (! ATTR_IND_SIMPLIFIED_P (exp))
 	return copy_rtx_unchanging (exp);
       return exp;
@@ -2490,14 +2468,6 @@ attr_alt_complement (rtx s)
   return result;
 }
 
-/* Tests whether a bit B belongs to the set represented by S.  */
-
-static bool
-attr_alt_bit_p (rtx s, int b)
-{
-  return XINT (s, 1) ^ ((XINT (s, 0) >> b) & 1);
-}
-
 /* Return EQ_ATTR_ALT expression representing set containing elements set
    in E.  */
 
@@ -2540,12 +2510,10 @@ simplify_test_exp (rtx exp, int insn_cod
     {
     case AND:
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (left == false_rtx)
 	return false_rtx;
       right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (right);
-      if (left == false_rtx)
+      if (right == false_rtx)
 	return false_rtx;
 
       if (GET_CODE (left) == EQ_ATTR_ALT
@@ -2646,11 +2614,9 @@ simplify_test_exp (rtx exp, int insn_cod
 
     case IOR:
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (left == true_rtx)
 	return true_rtx;
       right = SIMPLIFY_TEST_EXP (XEXP (exp, 1), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (right);
       if (right == true_rtx)
 	return true_rtx;
 
@@ -2744,12 +2710,10 @@ simplify_test_exp (rtx exp, int insn_cod
 	{
 	  left = SIMPLIFY_TEST_EXP (XEXP (XEXP (exp, 0), 0),
 				    insn_code, insn_index);
-	  SIMPLIFY_ALTERNATIVE (left);
 	  return left;
 	}
 
       left = SIMPLIFY_TEST_EXP (XEXP (exp, 0), insn_code, insn_index);
-      SIMPLIFY_ALTERNATIVE (left);
       if (GET_CODE (left) == NOT)
 	return XEXP (left, 0);
 
@@ -2788,18 +2752,11 @@ simplify_test_exp (rtx exp, int insn_cod
       break;
 
     case EQ_ATTR_ALT:
-      if (current_alternative_string)
-	return attr_alt_bit_p (exp, atoi (current_alternative_string)) ? true_rtx : false_rtx;
-
       if (!XINT (exp, 0))
 	return XINT (exp, 1) ? true_rtx : false_rtx;
       break;
 
     case EQ_ATTR:
-      if (current_alternative_string && XSTR (exp, 0) == alternative_name)
-	return (XSTR (exp, 1) == current_alternative_string
-		? true_rtx : false_rtx);
-
       if (XSTR (exp, 0) == alternative_name)
 	{
 	  newexp = mk_attr_alt (1 << atoi (XSTR (exp, 1)));
@@ -2809,7 +2766,7 @@ simplify_test_exp (rtx exp, int insn_cod
       /* Look at the value for this insn code in the specified attribute.
 	 We normally can replace this comparison with the condition that
 	 would give this insn the values being tested for.  */
-      if (XSTR (exp, 0) != alternative_name
+      if (insn_code >= 0
 	  && (attr = find_attr (&XSTR (exp, 0), 0)) != NULL)
 	for (av = attr->first_value; av; av = av->next)
 	  for (ie = av->first_insn; ie; ie = ie->next)
@@ -2830,7 +2787,7 @@ simplify_test_exp (rtx exp, int insn_cod
   /* We have already simplified this expression.  Simplifying it again
      won't buy anything unless we weren't given a valid insn code
      to process (i.e., we are canonicalizing something.).  */
-  if (insn_code != -2 /* Seems wrong: && current_alternative_string.  */
+  if (insn_code != -2
       && ! ATTR_IND_SIMPLIFIED_P (newexp))
     return copy_rtx_unchanging (newexp);
 


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