public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* suggest assert wide_int larger than hashval_t
@ 2010-07-19  6:44 Jay K
  2010-07-19  7:03 ` suggest assert wide_int larger than hashval_t (32bit hwint?) Jay K
  2010-07-19  7:36 ` suggest assert wide_int larger than hashval_t Ian Lance Taylor
  0 siblings, 2 replies; 4+ messages in thread
From: Jay K @ 2010-07-19  6:44 UTC (permalink / raw)
  To: gcc


I get this in 4.3.5:

../../gcc/gcc/varasm.c: In function `const_rtx_hash_1':
../../gcc/gcc/varasm.c:3387: warning: right shift count >= width of type

./include/hashtab.h:typedef unsigned int hashval_t;

  unsigned HOST_WIDE_INT hwi;
  hashval_t h, *hp;
 ...
    const int shift = sizeof (hashval_t) * CHAR_BIT;
    const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
    int i;

    h ^= (hashval_t) hwi;
    for (i = 1; i < n; ++i)
      {
        hwi >>= shift;  here


It looks about the same in 4.5.0 except without const:


    int shift = (sizeof (hashval_t) * CHAR_BIT);


Something is amiss here locally, for the types to be the same size.


But maybe add gcc_assert(sizeof(hashval_t) < sizeof(HOST_WIDE_INT),
outside the loop? It should be optimized away anyway.


Maybe I'd get -Werror but I use -disable-bootstrap.
Native compiler is gcc, but old.


Thanks,
 - Jay

 		 	   		  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: suggest assert wide_int larger than hashval_t (32bit hwint?)
  2010-07-19  6:44 suggest assert wide_int larger than hashval_t Jay K
@ 2010-07-19  7:03 ` Jay K
  2010-07-19  7:36 ` suggest assert wide_int larger than hashval_t Ian Lance Taylor
  1 sibling, 0 replies; 4+ messages in thread
From: Jay K @ 2010-07-19  7:03 UTC (permalink / raw)
  To: gcc


Hm, it seems on some 32bit systems, where there is no -m64, wideint can be a mere 32bits.

In which case the code should probably say:

hwi = ((hwi >> (shift - 1)) >> 1);

This was targeting OpenBSD/x86.
Maybe I should just stick need_64bit_hwint = yes on config.gcc for that and move along?
Assume there is always long long or __int64?
Coverage of this case is pretty rare now from my skimming.

 - Jay

----------------------------------------
> From: jay.krell@cornell.edu
> To: gcc@gcc.gnu.org
> Subject: suggest assert wide_int larger than hashval_t
> Date: Mon, 19 Jul 2010 06:44:33 +0000
>
>
> I get this in 4.3.5:
>
> ../../gcc/gcc/varasm.c: In function `const_rtx_hash_1':
> ../../gcc/gcc/varasm.c:3387: warning: right shift count >= width of type
>
> ./include/hashtab.h:typedef unsigned int hashval_t;
>
>   unsigned HOST_WIDE_INT hwi;
>   hashval_t h, *hp;
>  ...
>     const int shift = sizeof (hashval_t) * CHAR_BIT;
>     const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
>     int i;
>
>     h ^= (hashval_t) hwi;
>     for (i = 1; i < n; ++i)
>       {
>         hwi >>= shift;  here
>
>
> It looks about the same in 4.5.0 except without const:
>
>
>     int shift = (sizeof (hashval_t) * CHAR_BIT);
>
>
> Something is amiss here locally, for the types to be the same size.
>
>
> But maybe add gcc_assert(sizeof(hashval_t) < sizeof(HOST_WIDE_INT),
> outside the loop? It should be optimized away anyway.
>
>
> Maybe I'd get -Werror but I use -disable-bootstrap.
> Native compiler is gcc, but old.
>
>
> Thanks,
>  - Jay
>
>
 		 	   		  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: suggest assert wide_int larger than hashval_t
  2010-07-19  6:44 suggest assert wide_int larger than hashval_t Jay K
  2010-07-19  7:03 ` suggest assert wide_int larger than hashval_t (32bit hwint?) Jay K
@ 2010-07-19  7:36 ` Ian Lance Taylor
  2010-07-19  7:55   ` Jay K
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2010-07-19  7:36 UTC (permalink / raw)
  To: Jay K; +Cc: gcc

Jay K <jay.krell@cornell.edu> writes:

> I get this in 4.3.5:
>
> ../../gcc/gcc/varasm.c: In function `const_rtx_hash_1':
> ../../gcc/gcc/varasm.c:3387: warning: right shift count >= width of type
>
> ./include/hashtab.h:typedef unsigned int hashval_t;
>
>   unsigned HOST_WIDE_INT hwi;
>   hashval_t h, *hp;
>  ...
>     const int shift = sizeof (hashval_t) * CHAR_BIT;
>     const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
>     int i;
>
>     h ^= (hashval_t) hwi;
>     for (i = 1; i < n; ++i)
>       {
>         hwi >>= shift;  here

It's not an actual problem, because the code is never executed in the
case where right shift count >= width of type.  Note that the loop
starts at 1.  If this is breaking bootstrap that it needs to be
addressed one way or another, otherwise it's not too serious.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: suggest assert wide_int larger than hashval_t
  2010-07-19  7:36 ` suggest assert wide_int larger than hashval_t Ian Lance Taylor
@ 2010-07-19  7:55   ` Jay K
  0 siblings, 0 replies; 4+ messages in thread
From: Jay K @ 2010-07-19  7:55 UTC (permalink / raw)
  To: iant; +Cc: gcc


It's "just" a warning, no "real" affects seen.
I patched my copy to say
  hwi = ((hwi >> (shift - 1)) >> 1);

Thanks,
 - Jay

----------------------------------------
> From: iant@google.com
> To: jay.krell@cornell.edu
> CC: gcc@gcc.gnu.org
> Subject: Re: suggest assert wide_int larger than hashval_t
> Date: Mon, 19 Jul 2010 00:36:06 -0700
>
> Jay K  writes:
>
> > I get this in 4.3.5:
> >
> > ../../gcc/gcc/varasm.c: In function `const_rtx_hash_1':
> > ../../gcc/gcc/varasm.c:3387: warning: right shift count >= width of type
> >
> > ./include/hashtab.h:typedef unsigned int hashval_t;
> >
> >   unsigned HOST_WIDE_INT hwi;
> >   hashval_t h, *hp;
> >  ...
> >     const int shift = sizeof (hashval_t) * CHAR_BIT;
> >     const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
> >     int i;
> >
> >     h ^= (hashval_t) hwi;
> >     for (i = 1; i < n; ++i)
> >       {
> >         hwi >>= shift;  here
>
> It's not an actual problem, because the code is never executed in the
> case where right shift count >= width of type. Note that the loop
> starts at 1. If this is breaking bootstrap that it needs to be
> addressed one way or another, otherwise it's not too serious.
>
> Ian
 		 	   		  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-19  7:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-19  6:44 suggest assert wide_int larger than hashval_t Jay K
2010-07-19  7:03 ` suggest assert wide_int larger than hashval_t (32bit hwint?) Jay K
2010-07-19  7:36 ` suggest assert wide_int larger than hashval_t Ian Lance Taylor
2010-07-19  7:55   ` Jay K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).