[llvm-dev] Handling native i16 types in clang and opt

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sun May 21 01:40:21 PDT 2017


Do you have a simple test case you can send?  I'm having trouble
replicating this on x86-64 with the simplest possible test.

unsigned short foo(unsigned short a, unsigned short b) {
  return a + b;
}

This gives IR with no mention of i32. Maybe there's somethings
misconfigured for your target or I need a more complex test case.

~Craig

On Sun, May 21, 2017 at 1:22 AM, Alex Susu via llvm-dev <
llvm-dev at lists.llvm.org> 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.
>
>     Is there a way to avoid these conversion made by clang back and forth
> from i16 to i32, if my source program uses only short types?
>     Otherwise, how can I make the IC pass handle sdiv the way it does with
> add (sub), mul? (that is, if the input operands are i16, the add/mul
> operation will eventually be i16, with any unnecessary conversion back and
> forth from i32 removed).
>
>   Thank you,
>     Alex
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170521/9f445ab1/attachment.html>


More information about the llvm-dev mailing list