[LLVMdev] signedness of types

Gordon Henriksen gordonhenriksen at mac.com
Tue Jun 3 05:03:37 PDT 2008


On Jun 3, 2008, at 07:44, Eli Friedman wrote:

> On Tue, Jun 3, 2008 at 2:42 AM, ST <st at iss.tu-darmstadt.de> wrote:
>>
>
>> I currently would like to find out the signedness of a instruction.  
>> But looking at the CBackend, it looks as if it is not that simple?  
>> So i have two questions:
>> Is there an easier way than guessing as it is done in the CBackend?
>> Is there a reason for that signedness is not part of the  
>> instruction type?
>
> A lot of LLVM integer instructions don't naturally have a sign.  For  
> example, signed addition and unsigned addition are exactly the same  
> operation in two's complement, so the LLVM assembly doesn't bother  
> to encode the signedness.  The CBacked "guesses" because the  
> necessary information is completely gone.


This is so because it avoids encoding many sign conversions, which  
makes the IR more transparent to optimization (and avoids sign  
conversions!). It's also a closer match to the hardware. LLVM used to  
have signed integer types.

— Gordon





More information about the llvm-dev mailing list