1 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \
2 // RUN: -target-cpu pwr9 -target-feature +float128 -o - %s | FileCheck %s
4 // Test homogeneous fp128 aggregate passing and returning.
6 struct fp1
{ __float128 f
[1]; };
7 struct fp2
{ __float128 f
[2]; };
8 struct fp3
{ __float128 f
[3]; };
9 struct fp4
{ __float128 f
[4]; };
10 struct fp5
{ __float128 f
[5]; };
11 struct fp6
{ __float128 f
[6]; };
12 struct fp7
{ __float128 f
[7]; };
13 struct fp8
{ __float128 f
[8]; };
14 struct fp9
{ __float128 f
[9]; };
16 struct fpab
{ __float128 a
; __float128 b
; };
17 struct fpabc
{ __float128 a
; __float128 b
; __float128 c
; };
19 struct fp2a2b
{ __float128 a
[2]; __float128 b
[2]; };
21 // CHECK: define{{.*}} [1 x fp128] @func_f1(fp128 inreg %x.coerce)
22 struct fp1
func_f1(struct fp1 x
) { return x
; }
24 // CHECK: define{{.*}} [2 x fp128] @func_f2([2 x fp128] %x.coerce)
25 struct fp2
func_f2(struct fp2 x
) { return x
; }
27 // CHECK: define{{.*}} [3 x fp128] @func_f3([3 x fp128] %x.coerce)
28 struct fp3
func_f3(struct fp3 x
) { return x
; }
30 // CHECK: define{{.*}} [4 x fp128] @func_f4([4 x fp128] %x.coerce)
31 struct fp4
func_f4(struct fp4 x
) { return x
; }
33 // CHECK: define{{.*}} [5 x fp128] @func_f5([5 x fp128] %x.coerce)
34 struct fp5
func_f5(struct fp5 x
) { return x
; }
36 // CHECK: define{{.*}} [6 x fp128] @func_f6([6 x fp128] %x.coerce)
37 struct fp6
func_f6(struct fp6 x
) { return x
; }
39 // CHECK: define{{.*}} [7 x fp128] @func_f7([7 x fp128] %x.coerce)
40 struct fp7
func_f7(struct fp7 x
) { return x
; }
42 // CHECK: define{{.*}} [8 x fp128] @func_f8([8 x fp128] %x.coerce)
43 struct fp8
func_f8(struct fp8 x
) { return x
; }
45 // CHECK: define{{.*}} void @func_f9(ptr noalias sret(%struct.fp9) align 16 %agg.result, ptr noundef byval(%struct.fp9) align 16 %x)
46 struct fp9
func_f9(struct fp9 x
) { return x
; }
48 // CHECK: define{{.*}} [2 x fp128] @func_fab([2 x fp128] %x.coerce)
49 struct fpab
func_fab(struct fpab x
) { return x
; }
51 // CHECK: define{{.*}} [3 x fp128] @func_fabc([3 x fp128] %x.coerce)
52 struct fpabc
func_fabc(struct fpabc x
) { return x
; }
54 // CHECK: define{{.*}} [4 x fp128] @func_f2a2b([4 x fp128] %x.coerce)
55 struct fp2a2b
func_f2a2b(struct fp2a2b x
) { return x
; }
57 // CHECK-LABEL: @call_fp1
58 // CHECK: %[[TMP:[^ ]+]] = load fp128, ptr @global_f1, align 16
59 // CHECK: call [1 x fp128] @func_f1(fp128 inreg %[[TMP]])
61 void call_fp1(void) { global_f1
= func_f1(global_f1
); }
63 // CHECK-LABEL: @call_fp2
64 // CHECK: %[[TMP:[^ ]+]] = load [2 x fp128], ptr @global_f2, align 16
65 // CHECK: call [2 x fp128] @func_f2([2 x fp128] %[[TMP]])
67 void call_fp2(void) { global_f2
= func_f2(global_f2
); }
69 // CHECK-LABEL: @call_fp3
70 // CHECK: %[[TMP:[^ ]+]] = load [3 x fp128], ptr @global_f3, align 16
71 // CHECK: call [3 x fp128] @func_f3([3 x fp128] %[[TMP]])
73 void call_fp3(void) { global_f3
= func_f3(global_f3
); }
75 // CHECK-LABEL: @call_fp4
76 // CHECK: %[[TMP:[^ ]+]] = load [4 x fp128], ptr @global_f4, align 16
77 // CHECK: call [4 x fp128] @func_f4([4 x fp128] %[[TMP]])
79 void call_fp4(void) { global_f4
= func_f4(global_f4
); }
81 // CHECK-LABEL: @call_fp5
82 // CHECK: %[[TMP:[^ ]+]] = load [5 x fp128], ptr @global_f5, align 16
83 // CHECK: call [5 x fp128] @func_f5([5 x fp128] %[[TMP]])
85 void call_fp5(void) { global_f5
= func_f5(global_f5
); }
87 // CHECK-LABEL: @call_fp6
88 // CHECK: %[[TMP:[^ ]+]] = load [6 x fp128], ptr @global_f6, align 16
89 // CHECK: call [6 x fp128] @func_f6([6 x fp128] %[[TMP]])
91 void call_fp6(void) { global_f6
= func_f6(global_f6
); }
93 // CHECK-LABEL: @call_fp7
94 // CHECK: %[[TMP:[^ ]+]] = load [7 x fp128], ptr @global_f7, align 16
95 // CHECK: call [7 x fp128] @func_f7([7 x fp128] %[[TMP]])
97 void call_fp7(void) { global_f7
= func_f7(global_f7
); }
99 // CHECK-LABEL: @call_fp8
100 // CHECK: %[[TMP:[^ ]+]] = load [8 x fp128], ptr @global_f8, align 16
101 // CHECK: call [8 x fp128] @func_f8([8 x fp128] %[[TMP]])
102 struct fp8 global_f8
;
103 void call_fp8(void) { global_f8
= func_f8(global_f8
); }
105 // CHECK-LABEL: @call_fp9
106 // CHECK: %[[TMP1:[^ ]+]] = alloca %struct.fp9, align 16
107 // CHECK: call void @func_f9(ptr sret(%struct.fp9) align 16 %[[TMP2:[^ ]+]], ptr noundef byval(%struct.fp9) align 16 @global_f9
108 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 16 @global_f9, ptr align 16 %[[TMP2]], i64 144, i1 false
110 struct fp9 global_f9
;
111 void call_fp9(void) { global_f9
= func_f9(global_f9
); }
113 // CHECK-LABEL: @call_fpab
114 // CHECK: %[[TMP:[^ ]+]] = load [2 x fp128], ptr @global_fab
115 // CHECK: call [2 x fp128] @func_fab([2 x fp128] %[[TMP]])
116 struct fpab global_fab
;
117 void call_fpab(void) { global_fab
= func_fab(global_fab
); }
119 // CHECK-LABEL: @call_fpabc
120 // CHECK: %[[TMP:[^ ]+]] = load [3 x fp128], ptr @global_fabc
121 // CHECK: call [3 x fp128] @func_fabc([3 x fp128] %[[TMP]])
122 struct fpabc global_fabc
;
123 void call_fpabc(void) { global_fabc
= func_fabc(global_fabc
); }