Some cselib bug fixes
authorBernd Schmidt <bernds@cygnus.co.uk>
Thu, 16 Mar 2000 17:13:49 +0000 (17:13 +0000)
committerBernd Schmidt <crux@gcc.gnu.org>
Thu, 16 Mar 2000 17:13:49 +0000 (17:13 +0000)
From-SVN: r32589

gcc/ChangeLog
gcc/simplify-rtx.c

index 37dc67e4c4d3c2631485bf824d671296214a8c37..1650a80a0f1740c93fd6a5e8b65c79aaa34e83d4 100644 (file)
@@ -1,3 +1,11 @@
+2000-03-16  Bernd Schmidt  <bernds@cygnus.co.uk>
+
+       * simplify-rtx.c (hash_rtx, case MEM/REG): Take into account that
+       HASH may already be nonzero.  Add code/mode into hash value
+       immediately after repeat label.
+       (cselib_lookup): Don't leave the hash table in an inconsistent
+       state before a hash lookup operation.
+
 Thu Mar 16 17:03:10 MET 2000  Jan Hubicka  <jh@suse.cz>
 
        * i386.md (all HI and QI mode non-move patterns):  Conditionize
index f9ed9318080dbe328cf4abcaa629d983187ad910..08abf69975758e139ec8f4f36faebe43a446dca9 100644 (file)
@@ -2435,14 +2435,15 @@ hash_rtx (x, mode, create)
 {
   cselib_val *e;
   int i, j;
+  enum rtx_code code;
+  const char *fmt;
   unsigned int hash = 0;
-  enum rtx_code code = GET_CODE (x);
-  const char *fmt = GET_RTX_FORMAT (code);
 
   /* repeat is used to turn tail-recursion into iteration.  */
  repeat:
-
   code = GET_CODE (x);
+  hash += (unsigned) code + (unsigned) GET_MODE (x);
+
   switch (code)
     {
     case MEM:
@@ -2450,7 +2451,8 @@ hash_rtx (x, mode, create)
       e = cselib_lookup (x, GET_MODE (x), create);
       if (! e)
        return 0;
-      return e->value;
+      hash += e->value;
+      return hash;
 
     case CONST_INT:
       {
@@ -2506,7 +2508,6 @@ hash_rtx (x, mode, create)
     }
 
   i = GET_RTX_LENGTH (code) - 1;
-  hash += (unsigned) code + (unsigned) GET_MODE (x);
   fmt = GET_RTX_FORMAT (code);
   for (; i >= 0; i--)
     {
@@ -2765,8 +2766,11 @@ cselib_lookup (x, mode, create)
     return e;
 
   e = new_cselib_val (hashval, mode);
-  e->locs = new_elt_loc_list (e->locs, cselib_subst_to_values (x));
+  /* We have to fill the slot before calling cselib_subst_to_values:
+     the hash table is inconsistent until we do so, and
+     cselib_subst_to_values will need to do lookups.  */
   *slot = (void *) e;
+  e->locs = new_elt_loc_list (e->locs, cselib_subst_to_values (x));
   return e;
 }