1 ; RUN: llc -mtriple=x86_64-apple-darwin8 < %s | FileCheck %s
2 ; RUN: llc -mtriple=x86_64-pc-linux < %s | FileCheck %s
3 ; RUN: llc -mtriple=x86_64-pc-linux-gnux32 < %s | FileCheck -check-prefix=X32ABI %s
5 %struct.foo = type { [4 x i64] }
8 ; CHECK: movq %rdi, %rax
10 ; For the x32 ABI, pointers are 32-bit but passed in zero-extended to 64-bit
11 ; so either 32-bit or 64-bit instructions may be used.
13 ; X32ABI: mov{{l|q}} %{{r|e}}di, %{{r|e}}ax
15 define void @bar(ptr noalias sret(%struct.foo) %agg.result, ptr %d) nounwind {
17 %d_addr = alloca ptr ; <ptr> [#uses=2]
18 %memtmp = alloca %struct.foo, align 8 ; <ptr> [#uses=1]
19 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
20 store ptr %d, ptr %d_addr
21 %tmp = load ptr, ptr %d_addr, align 8 ; <ptr> [#uses=1]
22 %tmp1 = getelementptr %struct.foo, ptr %agg.result, i32 0, i32 0 ; <ptr> [#uses=4]
23 %tmp2 = getelementptr %struct.foo, ptr %tmp, i32 0, i32 0 ; <ptr> [#uses=4]
24 %tmp3 = getelementptr [4 x i64], ptr %tmp1, i32 0, i32 0 ; <ptr> [#uses=1]
25 %tmp4 = getelementptr [4 x i64], ptr %tmp2, i32 0, i32 0 ; <ptr> [#uses=1]
26 %tmp5 = load i64, ptr %tmp4, align 8 ; <i64> [#uses=1]
27 store i64 %tmp5, ptr %tmp3, align 8
28 %tmp6 = getelementptr [4 x i64], ptr %tmp1, i32 0, i32 1 ; <ptr> [#uses=1]
29 %tmp7 = getelementptr [4 x i64], ptr %tmp2, i32 0, i32 1 ; <ptr> [#uses=1]
30 %tmp8 = load i64, ptr %tmp7, align 8 ; <i64> [#uses=1]
31 store i64 %tmp8, ptr %tmp6, align 8
32 %tmp9 = getelementptr [4 x i64], ptr %tmp1, i32 0, i32 2 ; <ptr> [#uses=1]
33 %tmp10 = getelementptr [4 x i64], ptr %tmp2, i32 0, i32 2 ; <ptr> [#uses=1]
34 %tmp11 = load i64, ptr %tmp10, align 8 ; <i64> [#uses=1]
35 store i64 %tmp11, ptr %tmp9, align 8
36 %tmp12 = getelementptr [4 x i64], ptr %tmp1, i32 0, i32 3 ; <ptr> [#uses=1]
37 %tmp13 = getelementptr [4 x i64], ptr %tmp2, i32 0, i32 3 ; <ptr> [#uses=1]
38 %tmp14 = load i64, ptr %tmp13, align 8 ; <i64> [#uses=1]
39 store i64 %tmp14, ptr %tmp12, align 8
40 %tmp15 = getelementptr %struct.foo, ptr %memtmp, i32 0, i32 0 ; <ptr> [#uses=4]
41 %tmp16 = getelementptr %struct.foo, ptr %agg.result, i32 0, i32 0 ; <ptr> [#uses=4]
42 %tmp17 = getelementptr [4 x i64], ptr %tmp15, i32 0, i32 0 ; <ptr> [#uses=1]
43 %tmp18 = getelementptr [4 x i64], ptr %tmp16, i32 0, i32 0 ; <ptr> [#uses=1]
44 %tmp19 = load i64, ptr %tmp18, align 8 ; <i64> [#uses=1]
45 store i64 %tmp19, ptr %tmp17, align 8
46 %tmp20 = getelementptr [4 x i64], ptr %tmp15, i32 0, i32 1 ; <ptr> [#uses=1]
47 %tmp21 = getelementptr [4 x i64], ptr %tmp16, i32 0, i32 1 ; <ptr> [#uses=1]
48 %tmp22 = load i64, ptr %tmp21, align 8 ; <i64> [#uses=1]
49 store i64 %tmp22, ptr %tmp20, align 8
50 %tmp23 = getelementptr [4 x i64], ptr %tmp15, i32 0, i32 2 ; <ptr> [#uses=1]
51 %tmp24 = getelementptr [4 x i64], ptr %tmp16, i32 0, i32 2 ; <ptr> [#uses=1]
52 %tmp25 = load i64, ptr %tmp24, align 8 ; <i64> [#uses=1]
53 store i64 %tmp25, ptr %tmp23, align 8
54 %tmp26 = getelementptr [4 x i64], ptr %tmp15, i32 0, i32 3 ; <ptr> [#uses=1]
55 %tmp27 = getelementptr [4 x i64], ptr %tmp16, i32 0, i32 3 ; <ptr> [#uses=1]
56 %tmp28 = load i64, ptr %tmp27, align 8 ; <i64> [#uses=1]
57 store i64 %tmp28, ptr %tmp26, align 8
60 return: ; preds = %entry
65 ; CHECK: movq %rdi, %rax
67 ; For the x32 ABI, pointers are 32-bit but passed in zero-extended to 64-bit
68 ; so either 32-bit or 64-bit instructions may be used.
70 ; X32ABI: mov{{l|q}} %{{r|e}}di, %{{r|e}}ax
72 define void @foo(ptr noalias nocapture sret({ i64 }) %agg.result) nounwind {
73 store { i64 } { i64 0 }, ptr %agg.result