[llvm-dev] About CodeGen quality
陳韋任 via llvm-dev
llvm-dev at lists.llvm.org
Fri Jun 16 03:54:51 PDT 2017
Here is the complete IR I am dealing with, if that helps discussion.
-------------------------------------------------------------
%struct.A = type { %struct.Z*, %struct.Z*, %struct.Z*, %struct.Z*,
%struct.Z* }
%struct.Z = type { %union.X, [180 x %union.Y] }
%union.X = type { %struct.anon }
%struct.anon = type { i64 }
%union.Y = type { %struct.anon.0 }
%struct.anon.0 = type { i32 }
%struct.D = type { i64 }
; Function Attrs: norecurse nounwind
define void @func(%struct.A* noalias nocapture readonly %a, %struct.D*
noalias nocapture readonly %d) local_unnamed_addr #0 {
entry:
%a2 = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 1
%0 = load %struct.Z*, %struct.Z** %a2, align 4, !tbaa !1
%1 = getelementptr inbounds %struct.D, %struct.D* %d, i32 0, i32 0
%bf.load = load i64, i64* %1, align 4
%bf.lshr = lshr i64 %bf.load, 8
%2 = trunc i64 %bf.lshr to i32
%bf.cast = and i32 %2, 255
%3 = getelementptr inbounds %struct.Z, %struct.Z* %0, i32 0, i32 1,
i32 %bf.cast, i32 0, i32 0
%bf.load1 = load i32, i32* %3, align 4
%bf.clear2 = and i32 %bf.load1, 65535
store i32 %bf.clear2, i32* %3, align 4
ret void
}
-------------------------------------------------------------
Regards,
chenwj
2017-06-16 14:13 GMT+08:00 Ehsan Amiri via llvm-dev <llvm-dev at lists.llvm.org
>:
>
> 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
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170616/0ba02143/attachment.html>
More information about the llvm-dev
mailing list