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]

Re: cselib fix


Bernd,

Something has been bothering me about this patch.

Now the hash function will simply return the value number for REG and
MEM expressions.  That's fine.  But it will also return this value
number for any expression with a REG or MEM as its first argument.
This will therefore hash many different expressions to the same value.
This is not incorrect, of course, since the hash table lookup should
compare the expressions and detect when they don't match anyway, but
it does lead to many more collisions than we would like.

Sorry that I haven't been very communicative about this; my RSI has
started acting up again and I wanted to lay off the keyboarding a bit.

On Thu, 15 Mar 2001 12:53:19 +0000 (GMT), Bernd Schmidt wrote:
> This should fix the problem Colin Howell has found.  Seems like I
> broke this just two days after checking in the cselib code.  Of
> course we can't add the rtx code of an expression into the hash
> value for REGs and MEMs; the code absolutely depends on returning
> the same hash value for two rtx's with the same value.  Now where's
> my brown paper bag?
> 
> Bootstrapped on i686-linux.  Will install on 3.0 branch as well
> after another bootstrap.
> 
> 
> Bernd
> 
>         * cselib.c (hash_rtx): For REG and MEM, just use value of expression
>         without adding in rtx code and mode.
> 
> Index: cselib.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/cselib.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 cselib.c
> --- cselib.c    2001/03/09 17:03:46     1.3
> +++ cselib.c    2001/03/15 12:36:30
> @@ -579,8 +579,7 @@ hash_rtx (x, mode, create)
>        if (! e)
>         return 0;
> 
> -      hash += e->value;
> -      return hash ? hash : (unsigned int) MEM;
> +      return e->value;
> 
>      case CONST_INT:
>        hash += ((unsigned) CONST_INT << 7) + (unsigned) mode + INTVAL (x);

-- 
Colin Douglas Howell            E-mail:  chowell@redhat.com
Support Engineer                Support line:  (408) 542-9601
Red Hat, Inc.


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