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
4
5%struct.foo = type { [4 x i64] }
6
7; CHECK-LABEL: bar:
8; CHECK: movq %rdi, %rax
9
10; For the x32 ABI, pointers are 32-bit so 32-bit instructions will be used
11; X32ABI-LABEL: bar:
12; X32ABI: movl %edi, %eax
13
14define void @bar(%struct.foo* noalias sret  %agg.result, %struct.foo* %d) nounwind  {
15entry:
16	%d_addr = alloca %struct.foo*		; <%struct.foo**> [#uses=2]
17	%memtmp = alloca %struct.foo, align 8		; <%struct.foo*> [#uses=1]
18	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
19	store %struct.foo* %d, %struct.foo** %d_addr
20	%tmp = load %struct.foo*, %struct.foo** %d_addr, align 8		; <%struct.foo*> [#uses=1]
21	%tmp1 = getelementptr %struct.foo, %struct.foo* %agg.result, i32 0, i32 0		; <[4 x i64]*> [#uses=4]
22	%tmp2 = getelementptr %struct.foo, %struct.foo* %tmp, i32 0, i32 0		; <[4 x i64]*> [#uses=4]
23	%tmp3 = getelementptr [4 x i64], [4 x i64]* %tmp1, i32 0, i32 0		; <i64*> [#uses=1]
24	%tmp4 = getelementptr [4 x i64], [4 x i64]* %tmp2, i32 0, i32 0		; <i64*> [#uses=1]
25	%tmp5 = load i64, i64* %tmp4, align 8		; <i64> [#uses=1]
26	store i64 %tmp5, i64* %tmp3, align 8
27	%tmp6 = getelementptr [4 x i64], [4 x i64]* %tmp1, i32 0, i32 1		; <i64*> [#uses=1]
28	%tmp7 = getelementptr [4 x i64], [4 x i64]* %tmp2, i32 0, i32 1		; <i64*> [#uses=1]
29	%tmp8 = load i64, i64* %tmp7, align 8		; <i64> [#uses=1]
30	store i64 %tmp8, i64* %tmp6, align 8
31	%tmp9 = getelementptr [4 x i64], [4 x i64]* %tmp1, i32 0, i32 2		; <i64*> [#uses=1]
32	%tmp10 = getelementptr [4 x i64], [4 x i64]* %tmp2, i32 0, i32 2		; <i64*> [#uses=1]
33	%tmp11 = load i64, i64* %tmp10, align 8		; <i64> [#uses=1]
34	store i64 %tmp11, i64* %tmp9, align 8
35	%tmp12 = getelementptr [4 x i64], [4 x i64]* %tmp1, i32 0, i32 3		; <i64*> [#uses=1]
36	%tmp13 = getelementptr [4 x i64], [4 x i64]* %tmp2, i32 0, i32 3		; <i64*> [#uses=1]
37	%tmp14 = load i64, i64* %tmp13, align 8		; <i64> [#uses=1]
38	store i64 %tmp14, i64* %tmp12, align 8
39	%tmp15 = getelementptr %struct.foo, %struct.foo* %memtmp, i32 0, i32 0		; <[4 x i64]*> [#uses=4]
40	%tmp16 = getelementptr %struct.foo, %struct.foo* %agg.result, i32 0, i32 0		; <[4 x i64]*> [#uses=4]
41	%tmp17 = getelementptr [4 x i64], [4 x i64]* %tmp15, i32 0, i32 0		; <i64*> [#uses=1]
42	%tmp18 = getelementptr [4 x i64], [4 x i64]* %tmp16, i32 0, i32 0		; <i64*> [#uses=1]
43	%tmp19 = load i64, i64* %tmp18, align 8		; <i64> [#uses=1]
44	store i64 %tmp19, i64* %tmp17, align 8
45	%tmp20 = getelementptr [4 x i64], [4 x i64]* %tmp15, i32 0, i32 1		; <i64*> [#uses=1]
46	%tmp21 = getelementptr [4 x i64], [4 x i64]* %tmp16, i32 0, i32 1		; <i64*> [#uses=1]
47	%tmp22 = load i64, i64* %tmp21, align 8		; <i64> [#uses=1]
48	store i64 %tmp22, i64* %tmp20, align 8
49	%tmp23 = getelementptr [4 x i64], [4 x i64]* %tmp15, i32 0, i32 2		; <i64*> [#uses=1]
50	%tmp24 = getelementptr [4 x i64], [4 x i64]* %tmp16, i32 0, i32 2		; <i64*> [#uses=1]
51	%tmp25 = load i64, i64* %tmp24, align 8		; <i64> [#uses=1]
52	store i64 %tmp25, i64* %tmp23, align 8
53	%tmp26 = getelementptr [4 x i64], [4 x i64]* %tmp15, i32 0, i32 3		; <i64*> [#uses=1]
54	%tmp27 = getelementptr [4 x i64], [4 x i64]* %tmp16, i32 0, i32 3		; <i64*> [#uses=1]
55	%tmp28 = load i64, i64* %tmp27, align 8		; <i64> [#uses=1]
56	store i64 %tmp28, i64* %tmp26, align 8
57	br label %return
58
59return:		; preds = %entry
60	ret void
61}
62
63; CHECK-LABEL: foo:
64; CHECK: movq %rdi, %rax
65
66; For the x32 ABI, pointers are 32-bit so 32-bit instructions will be used
67; X32ABI-LABEL: foo:
68; X32ABI: movl %edi, %eax
69
70define void @foo({ i64 }* noalias nocapture sret %agg.result) nounwind {
71  store { i64 } { i64 0 }, { i64 }* %agg.result
72  ret void
73}
74