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: mn10300 64-bit clean-up


On May 20, 2000, Richard Henderson <rth@cygnus.com> wrote:

> On Sat, May 20, 2000 at 02:57:12PM -0300, Alexandre Oliva wrote:
>> ! 	    fprintf (file, "%ld",
>> ! 		     (long)((INTVAL (x) << (HOST_BITS_PER_WIDE_INT - 32))
>> ! 			    >> (HOST_BITS_PER_WIDE_INT - 32)));

> 6.5.7/5
> # The result of E1 >> E2 .... If E1 has a signed type and a negative
> # value, the resulting value is implementation defined.

What happened to the sign extension rule that I invented? :-) :-)

> You need to play with unsigned types and modulo arithmetic to be sure.

>   (long)((((unsigned long)INTVAL (x) & 0xffffffff) ^ 0x80000000) - 0x80000000)

To be really sure, we'd have to ensure that 0xffffffff is not
sign-extended, as it may be in a K&R C compiler.  Do we care?
How about `s/0xffffffff/(((((unsigned long)1) << 16) << 16) - 1)/'?

>> - 	    val[1] = val[0] < 0 ? -1 : 0;
>> + 	    val[1] = (val[0] >> 31) >> 1;

> This doesn't seem right.  Previously we resulted in exactly -1 or 0,
> and now...  well, I guess you are, but you sure are working hard to 
> get it.

No, I'm extracting the high word in case HOST_WIDE_INT is 64-bits
long.  It will be exactly -1 or 0 in the 32-bits case.

-- 
Alexandre Oliva    Enjoy Guaranį, see http://www.ic.unicamp.br/~oliva/
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me


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