1; Test rounding functions for z10.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4
5; Test rint for f32.
6declare float @llvm.rint.f32(float %f)
7define float @f1(float %f) {
8; CHECK-LABEL: f1:
9; CHECK: fiebr %f0, 0, %f0
10; CHECK: br %r14
11  %res = call float @llvm.rint.f32(float %f)
12  ret float %res
13}
14
15; Test rint for f64.
16declare double @llvm.rint.f64(double %f)
17define double @f2(double %f) {
18; CHECK-LABEL: f2:
19; CHECK: fidbr %f0, 0, %f0
20; CHECK: br %r14
21  %res = call double @llvm.rint.f64(double %f)
22  ret double %res
23}
24
25; Test rint for f128.
26declare fp128 @llvm.rint.f128(fp128 %f)
27define void @f3(fp128 *%ptr) {
28; CHECK-LABEL: f3:
29; CHECK: fixbr %f0, 0, %f0
30; CHECK: br %r14
31  %src = load fp128, fp128 *%ptr
32  %res = call fp128 @llvm.rint.f128(fp128 %src)
33  store fp128 %res, fp128 *%ptr
34  ret void
35}
36
37; Test nearbyint for f32.
38declare float @llvm.nearbyint.f32(float %f)
39define float @f4(float %f) {
40; CHECK-LABEL: f4:
41; CHECK: brasl %r14, nearbyintf@PLT
42; CHECK: br %r14
43  %res = call float @llvm.nearbyint.f32(float %f)
44  ret float %res
45}
46
47; Test nearbyint for f64.
48declare double @llvm.nearbyint.f64(double %f)
49define double @f5(double %f) {
50; CHECK-LABEL: f5:
51; CHECK: brasl %r14, nearbyint@PLT
52; CHECK: br %r14
53  %res = call double @llvm.nearbyint.f64(double %f)
54  ret double %res
55}
56
57; Test nearbyint for f128.
58declare fp128 @llvm.nearbyint.f128(fp128 %f)
59define void @f6(fp128 *%ptr) {
60; CHECK-LABEL: f6:
61; CHECK: brasl %r14, nearbyintl@PLT
62; CHECK: br %r14
63  %src = load fp128, fp128 *%ptr
64  %res = call fp128 @llvm.nearbyint.f128(fp128 %src)
65  store fp128 %res, fp128 *%ptr
66  ret void
67}
68
69; Test floor for f32.
70declare float @llvm.floor.f32(float %f)
71define float @f7(float %f) {
72; CHECK-LABEL: f7:
73; CHECK: brasl %r14, floorf@PLT
74; CHECK: br %r14
75  %res = call float @llvm.floor.f32(float %f)
76  ret float %res
77}
78
79; Test floor for f64.
80declare double @llvm.floor.f64(double %f)
81define double @f8(double %f) {
82; CHECK-LABEL: f8:
83; CHECK: brasl %r14, floor@PLT
84; CHECK: br %r14
85  %res = call double @llvm.floor.f64(double %f)
86  ret double %res
87}
88
89; Test floor for f128.
90declare fp128 @llvm.floor.f128(fp128 %f)
91define void @f9(fp128 *%ptr) {
92; CHECK-LABEL: f9:
93; CHECK: brasl %r14, floorl@PLT
94; CHECK: br %r14
95  %src = load fp128, fp128 *%ptr
96  %res = call fp128 @llvm.floor.f128(fp128 %src)
97  store fp128 %res, fp128 *%ptr
98  ret void
99}
100
101; Test ceil for f32.
102declare float @llvm.ceil.f32(float %f)
103define float @f10(float %f) {
104; CHECK-LABEL: f10:
105; CHECK: brasl %r14, ceilf@PLT
106; CHECK: br %r14
107  %res = call float @llvm.ceil.f32(float %f)
108  ret float %res
109}
110
111; Test ceil for f64.
112declare double @llvm.ceil.f64(double %f)
113define double @f11(double %f) {
114; CHECK-LABEL: f11:
115; CHECK: brasl %r14, ceil@PLT
116; CHECK: br %r14
117  %res = call double @llvm.ceil.f64(double %f)
118  ret double %res
119}
120
121; Test ceil for f128.
122declare fp128 @llvm.ceil.f128(fp128 %f)
123define void @f12(fp128 *%ptr) {
124; CHECK-LABEL: f12:
125; CHECK: brasl %r14, ceill@PLT
126; CHECK: br %r14
127  %src = load fp128, fp128 *%ptr
128  %res = call fp128 @llvm.ceil.f128(fp128 %src)
129  store fp128 %res, fp128 *%ptr
130  ret void
131}
132
133; Test trunc for f32.
134declare float @llvm.trunc.f32(float %f)
135define float @f13(float %f) {
136; CHECK-LABEL: f13:
137; CHECK: brasl %r14, truncf@PLT
138; CHECK: br %r14
139  %res = call float @llvm.trunc.f32(float %f)
140  ret float %res
141}
142
143; Test trunc for f64.
144declare double @llvm.trunc.f64(double %f)
145define double @f14(double %f) {
146; CHECK-LABEL: f14:
147; CHECK: brasl %r14, trunc@PLT
148; CHECK: br %r14
149  %res = call double @llvm.trunc.f64(double %f)
150  ret double %res
151}
152
153; Test trunc for f128.
154declare fp128 @llvm.trunc.f128(fp128 %f)
155define void @f15(fp128 *%ptr) {
156; CHECK-LABEL: f15:
157; CHECK: brasl %r14, truncl@PLT
158; CHECK: br %r14
159  %src = load fp128, fp128 *%ptr
160  %res = call fp128 @llvm.trunc.f128(fp128 %src)
161  store fp128 %res, fp128 *%ptr
162  ret void
163}
164
165; Test round for f32.
166declare float @llvm.round.f32(float %f)
167define float @f16(float %f) {
168; CHECK-LABEL: f16:
169; CHECK: brasl %r14, roundf@PLT
170; CHECK: br %r14
171  %res = call float @llvm.round.f32(float %f)
172  ret float %res
173}
174
175; Test round for f64.
176declare double @llvm.round.f64(double %f)
177define double @f17(double %f) {
178; CHECK-LABEL: f17:
179; CHECK: brasl %r14, round@PLT
180; CHECK: br %r14
181  %res = call double @llvm.round.f64(double %f)
182  ret double %res
183}
184
185; Test round for f128.
186declare fp128 @llvm.round.f128(fp128 %f)
187define void @f18(fp128 *%ptr) {
188; CHECK-LABEL: f18:
189; CHECK: brasl %r14, roundl@PLT
190; CHECK: br %r14
191  %src = load fp128, fp128 *%ptr
192  %res = call fp128 @llvm.round.f128(fp128 %src)
193  store fp128 %res, fp128 *%ptr
194  ret void
195}
196