[LLVMdev] sext..to instruction

Eli Friedman eli.friedman at gmail.com
Mon Oct 6 09:48:31 PDT 2008


On Mon, Oct 6, 2008 at 9:30 AM, Le Anh Quang
<anh_quang.le at mailbox.tu-dresden.de> wrote:
> Hi,
> I have a question about the "sext..to" instruction. In the document, I found
> two examples:
> %x = sext i8 -1 to i16
> It means:
> i8 -1   = 1111 1111 --> 1111 1111 1111 1111 = i16
> how can it determinate, that the i16 value %x positive is (65535)?
> And the second example:
>
> %y = sext i1 true to i32
> 1 --> 1111 1111 1111 1111 1111 1111 1111 1111
> In this example, %y is -1
>
> I'm not sure about it, when sext to results a positve/negative value?

Types like i16 aren't inherently signed or unsigned.  1111 1111 1111
1111 is both 65535 and -1; the interpretation depends on how the
result is used.

-Eli



More information about the llvm-dev mailing list