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]

cselib fix


This fixes the problem found by Jeff.  I'm currently bootstrapping with
this change; so far everything looks OK.  The problem was a rather subtle
one arising from using the new hash tables.  While I was there, I discovered
that the hash function was returning rather stupid values and fixed that,
too.


Bernd

	* 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.

Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.8
diff -c -p -r1.8 simplify-rtx.c
*** simplify-rtx.c	2000/03/14 18:36:18	1.8
--- simplify-rtx.c	2000/03/15 18:49:51
*************** hash_rtx (x, mode, create)
*** 2435,2448 ****
  {
    cselib_val *e;
    int i, j;
    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);
    switch (code)
      {
      case MEM:
--- 2435,2449 ----
  {
    cselib_val *e;
    int i, j;
+   enum rtx_code code;
+   const char *fmt;
    unsigned int hash = 0;
  
    /* 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:
*************** hash_rtx (x, mode, create)
*** 2450,2456 ****
        e = cselib_lookup (x, GET_MODE (x), create);
        if (! e)
  	return 0;
!       return e->value;
  
      case CONST_INT:
        {
--- 2451,2458 ----
        e = cselib_lookup (x, GET_MODE (x), create);
        if (! e)
  	return 0;
!       hash += e->value;
!       return hash;
  
      case CONST_INT:
        {
*************** hash_rtx (x, mode, create)
*** 2506,2512 ****
      }
  
    i = GET_RTX_LENGTH (code) - 1;
-   hash += (unsigned) code + (unsigned) GET_MODE (x);
    fmt = GET_RTX_FORMAT (code);
    for (; i >= 0; i--)
      {
--- 2508,2513 ----
*************** cselib_lookup (x, mode, create)
*** 2765,2772 ****
      return e;
  
    e = new_cselib_val (hashval, mode);
!   e->locs = new_elt_loc_list (e->locs, cselib_subst_to_values (x));
    *slot = (void *) e;
    return e;
  }
  
--- 2766,2776 ----
      return e;
  
    e = new_cselib_val (hashval, mode);
!   /* 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;
  }
  


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