[llvm-dev] Handling native i16 types in clang and opt
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Mon May 22 10:27:00 PDT 2017
On 5/21/2017 1:22 AM, Alex Susu via llvm-dev wrote:
> Hello.
> My target architecture supports natively 16 bit integers (i16).
>
> Whenever I write in C programs using only short types, clang
> compiles the program to LLVM and converts the i16 data to i32 to
> perform arithmetic operations and then truncates the results to i16.
> Then, the InstructionCombining (INSTCOMBINE or IC) pass removes these
> conversions back and forth from i16, except for the (s)div LLVM IR
> operation.
sdiv in particular is special: it has undefined behavior on overflow.
"sdiv i32 -32768, -1" produces "i32 32768", but "sdiv i16 -32768, -1" is
undefined.
-Eli
More information about the llvm-dev
mailing list