[llvm-dev] About CodeGen quality

Ehsan Amiri via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 15 23:13:01 PDT 2017


Forgot to reply to all

Hi Eli


    struct S {
      unsigned int a : 8;
      unsigned int b : 8;
      unsigned int c : 8;
      unsigned int d : 8;

      unsigned int e;
    }

We want to read S->b for example. The size of struct S is 64 bits, and
seems LLVM treats it as i64.
Below is the IR corresponding to S->b, IIRC.

    %0 = load i64, *i64 ptr, align 4;
    %1 = %0 lshr 8;
    %2 = %1 and 255;


This looks fine.


Why can't we expect InstCombine to simplify this to an 8 bit load, assuming
each of %0 and %1 has only one use ?

Thanks
Ehsan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170616/2f73ed1e/attachment.html>


More information about the llvm-dev mailing list