[LLVMdev] Size of packed struct type <{<3 x i32>, i32}>
Jan Sjodin
jan_sjodin at yahoo.com
Wed May 5 08:29:27 PDT 2010
I have a packed struct <{<3 x i32>, i32}> type that LLVM determines to be 20 bytes.
Is this the expected size for this type?
I wrote a small example to illustrate:
; ModuleID = 'myexample.bc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
target triple = "x86_64-pc-linux"
%mytype = type <{<3 x i32>, i32}>
define void @myexample(%mytype* %src, i64 %index, i32* %result) {
entry:
%vectoraddr = getelementptr %mytype* %src, i64 %index, i32 0
%vector = load <3 x i32>* %vectoraddr
%tmp1 = extractelement <3 x i32> %vector, i32 2
store i32 %tmp1, i32* %result
ret void
}
When I generate code (llc revision: 103084) i get:
.Leh_func_begin0:
# BB#0: # %entry
leaq (%rsi,%rsi,4), %rax <- Multiply index by 5
pshufd $2, (%rdi,%rax,4), %xmm0 <- multiply again by 4 (element size 20) and add base pointer
movd %xmm0, (%rdx)
ret
My guess was that the size should be 16 because I thought there should be no padding between elements.
- Jan
More information about the llvm-dev
mailing list