[LLVMdev] sext..to instruction
matthijs at stdin.nl
Tue Oct 7 02:24:21 PDT 2008
Hi Le Anh,
> how can it determinate, that the i16 value %x positive is (65535)?
> And the second example:
I guess you should read up on the "two's complement" format, which is how a
signed value is stored in most architectures (and in these examples).
In short, a sext operation takes the highest bit of the original number (the
sign bit) and copies it into all the higher positions. This makes sure that
the number and the sign do not change, due to the way two's complement works.
In general, the sext operation can enlarge a signed value, while preserving
both sign and magnitude, even when the target you are compiling for has some
other way of storing signed numbers.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: Digital signature
More information about the llvm-dev