get_condition causes overlow for sign extended constants

Joern Rennecke amylaar@cygnus.co.uk
Wed Oct 22 07:48:00 GMT 1997


>     It would fix the problem I pointed out, but it would create new
>     problems.  If op0 has a narrower mode than HOST_WIDE_INT, overflow
>     will not be detected by your version.
> 
> How is that possible?  The shift amount isn't being changed.  So if the
> shift of -1 would overflow, why wouldn't the current shift of 1 in the
> similar situation?

The shift amount is variable; but that is a moot point.

I am not talking about overflow that results from shifting 1 / -1,
but about overflow that results from subtracting 1 from const_val.

Thus, for a 64 bit host & 32 bit / 8 bit addressable unit target,
you solve the problem of detecting SImode overflow of 0x80000000 - 1,
(with 0x80000000 being represented as 0xffffffff80000000)
but create a new problems, e.g. HImode 0x8000 + 1 overflows,
but since (HOST_IDE_INT)-1 << (GET_MODE_BITSIZE (HImode) - 1)
is 0xffffffffffff8000 , which is different from 0x8000,
this overflow is not detected.

Thus, when using your suggestion, (GE (reg:HI n), (const_int 0x8000))
would be changed to (GT (reg:HI n), (const_int 0x7fff)) , which is something
completely different.  This would even happen for native compiles on
32 bit machines.




More information about the Gcc mailing list