>>>>> "Nicholas" == Nicholas Nethercote <[EMAIL PROTECTED]> writes:

 Nicholas> This point about 33-bit machines is interesting because it
 Nicholas> raises an optimisation scenario that hasn't been mentioned
 Nicholas> so far.

 Nicholas> Consider doing 32-bit integer arithmetic on 64-bit machines
 Nicholas> which only support 64-bit arithmetic instructions.  On such
 Nicholas> machines you have to use sign-extensions or zero-extensions
 Nicholas> after 64-bit operations to ensure wrap-around semantics
 Nicholas> (unless you can prove that the operation will not overflow
 Nicholas> the bottom 32 bits, or that the value will not be used in a
 Nicholas> way that exposes the fact you're using 64-bit arithmetic).

 Nicholas> But -- if I have understood correctly -- if the 32-bit
 Nicholas> values are signed integers, a C compiler for such a machine
 Nicholas> could legitimately omit the sign-extension.

Not necessarily.  Not on MIPS, for example, because the spec requires
that signed values in registers must be sign extended or the
operations are undefined (not undefined for overflow -- undefined all
the time).

    paul

Reply via email to