1b4105c
2005-05-17  Jakub Jelinek  <jakub@redhat.com>
1b4105c
1b4105c
	* varasm.c (struct constant_descriptor_tree): Add hash field.
1b4105c
	(const_desc_hash): Just return hash field.
1b4105c
	(const_desc_eq): If hash values are different, return 0 immediately.
1b4105c
	(output_constant_def): Compute hash field of temporary key, use
1b4105c
	htab_find_slot_with_hash instead of htab_find_slot.  Set hash in
1b4105c
	newly built constant descriptor.
1b4105c
	(lookup_constant_def): Compute hash field of temporary key, use
1b4105c
	htab_find_with_hash instead of htab_find.
1b4105c
1b4105c
--- gcc/varasm.c	16 May 2005 21:37:01 -0000	1.510
1b4105c
+++ gcc/varasm.c	17 May 2005 06:34:48 -0000	1.511
1b4105c
@@ -2361,6 +2361,11 @@ struct constant_descriptor_tree GTY(())
1b4105c
 
1b4105c
   /* The value of the constant.  */
1b4105c
   tree value;
1b4105c
+
1b4105c
+  /* Hash of value.  Computing the hash from value each time
1b4105c
+     hashfn is called can't work properly, as that means recursive
1b4105c
+     use of the hash table during hash table expansion.  */
1b4105c
+  hashval_t hash;
1b4105c
 };
1b4105c
 
1b4105c
 static GTY((param_is (struct constant_descriptor_tree)))
1b4105c
@@ -2374,7 +2379,7 @@ static void maybe_output_constant_def_co
1b4105c
 static hashval_t
1b4105c
 const_desc_hash (const void *ptr)
1b4105c
 {
1b4105c
-  return const_hash_1 (((struct constant_descriptor_tree *)ptr)->value);
1b4105c
+  return ((struct constant_descriptor_tree *)ptr)->hash;
1b4105c
 }
1b4105c
 
1b4105c
 static hashval_t
1b4105c
@@ -2474,8 +2479,11 @@ const_hash_1 (const tree exp)
1b4105c
 static int
1b4105c
 const_desc_eq (const void *p1, const void *p2)
1b4105c
 {
1b4105c
-  return compare_constant (((struct constant_descriptor_tree *)p1)->value,
1b4105c
-			   ((struct constant_descriptor_tree *)p2)->value);
1b4105c
+  const struct constant_descriptor_tree *c1 = p1;
1b4105c
+  const struct constant_descriptor_tree *c2 = p2;
1b4105c
+  if (c1->hash != c2->hash)
1b4105c
+    return 0;
1b4105c
+  return compare_constant (c1->value, c2->value);
1b4105c
 }
1b4105c
 
1b4105c
 /* Compare t1 and t2, and return 1 only if they are known to result in
1b4105c
@@ -2745,12 +2753,14 @@ output_constant_def (tree exp, int defer
1b4105c
   /* Look up EXP in the table of constant descriptors.  If we didn't find
1b4105c
      it, create a new one.  */
1b4105c
   key.value = exp;
1b4105c
-  loc = htab_find_slot (const_desc_htab, &key, INSERT);
1b4105c
+  key.hash = const_hash_1 (exp);
1b4105c
+  loc = htab_find_slot_with_hash (const_desc_htab, &key, key.hash, INSERT);
1b4105c
 
1b4105c
   desc = *loc;
1b4105c
   if (desc == 0)
1b4105c
     {
1b4105c
       desc = build_constant_desc (exp);
1b4105c
+      desc->hash = key.hash;
1b4105c
       *loc = desc;
1b4105c
     }
1b4105c
 
1b4105c
@@ -2853,7 +2863,8 @@ lookup_constant_def (tree exp)
1b4105c
   struct constant_descriptor_tree key;
1b4105c
 
1b4105c
   key.value = exp;
1b4105c
-  desc = htab_find (const_desc_htab, &key);
1b4105c
+  key.hash = const_hash_1 (exp);
1b4105c
+  desc = htab_find_with_hash (const_desc_htab, &key, key.hash);
1b4105c
 
1b4105c
   return (desc ? desc->rtl : NULL_RTX);
1b4105c
 }