1; Test strict 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.experimental.constrained.rint.f32(float, metadata, metadata)
7define float @f1(float %f) #0 {
8; CHECK-LABEL: f1:
9; CHECK: fiebr %f0, 0, %f0
10; CHECK: br %r14
11  %res = call float @llvm.experimental.constrained.rint.f32(
12                        float %f,
13                        metadata !"round.dynamic",
14                        metadata !"fpexcept.strict") #0
15  ret float %res
16}
17
18; Test rint for f64.
19declare double @llvm.experimental.constrained.rint.f64(double, metadata, metadata)
20define double @f2(double %f) #0 {
21; CHECK-LABEL: f2:
22; CHECK: fidbr %f0, 0, %f0
23; CHECK: br %r14
24  %res = call double @llvm.experimental.constrained.rint.f64(
25                        double %f,
26                        metadata !"round.dynamic",
27                        metadata !"fpexcept.strict") #0
28  ret double %res
29}
30
31; Test rint for f128.
32declare fp128 @llvm.experimental.constrained.rint.f128(fp128, metadata, metadata)
33define void @f3(fp128 *%ptr) #0 {
34; CHECK-LABEL: f3:
35; CHECK: fixbr %f0, 0, %f0
36; CHECK: br %r14
37  %src = load fp128, fp128 *%ptr
38  %res = call fp128 @llvm.experimental.constrained.rint.f128(
39                        fp128 %src,
40                        metadata !"round.dynamic",
41                        metadata !"fpexcept.strict") #0
42  store fp128 %res, fp128 *%ptr
43  ret void
44}
45
46; Test nearbyint for f32.
47declare float @llvm.experimental.constrained.nearbyint.f32(float, metadata, metadata)
48define float @f4(float %f) #0 {
49; CHECK-LABEL: f4:
50; CHECK: brasl %r14, nearbyintf@PLT
51; CHECK: br %r14
52  %res = call float @llvm.experimental.constrained.nearbyint.f32(
53                        float %f,
54                        metadata !"round.dynamic",
55                        metadata !"fpexcept.strict") #0
56  ret float %res
57}
58
59; Test nearbyint for f64.
60declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata)
61define double @f5(double %f) #0 {
62; CHECK-LABEL: f5:
63; CHECK: brasl %r14, nearbyint@PLT
64; CHECK: br %r14
65  %res = call double @llvm.experimental.constrained.nearbyint.f64(
66                        double %f,
67                        metadata !"round.dynamic",
68                        metadata !"fpexcept.strict") #0
69  ret double %res
70}
71
72; Test nearbyint for f128.
73declare fp128 @llvm.experimental.constrained.nearbyint.f128(fp128, metadata, metadata)
74define void @f6(fp128 *%ptr) #0 {
75; CHECK-LABEL: f6:
76; CHECK: brasl %r14, nearbyintl@PLT
77; CHECK: br %r14
78  %src = load fp128, fp128 *%ptr
79  %res = call fp128 @llvm.experimental.constrained.nearbyint.f128(
80                        fp128 %src,
81                        metadata !"round.dynamic",
82                        metadata !"fpexcept.strict") #0
83  store fp128 %res, fp128 *%ptr
84  ret void
85}
86
87; Test floor for f32.
88declare float @llvm.experimental.constrained.floor.f32(float, metadata)
89define float @f7(float %f) #0 {
90; CHECK-LABEL: f7:
91; CHECK: brasl %r14, floorf@PLT
92; CHECK: br %r14
93  %res = call float @llvm.experimental.constrained.floor.f32(
94                        float %f,
95                        metadata !"fpexcept.strict") #0
96  ret float %res
97}
98
99; Test floor for f64.
100declare double @llvm.experimental.constrained.floor.f64(double, metadata)
101define double @f8(double %f) #0 {
102; CHECK-LABEL: f8:
103; CHECK: brasl %r14, floor@PLT
104; CHECK: br %r14
105  %res = call double @llvm.experimental.constrained.floor.f64(
106                        double %f,
107                        metadata !"fpexcept.strict") #0
108  ret double %res
109}
110
111; Test floor for f128.
112declare fp128 @llvm.experimental.constrained.floor.f128(fp128, metadata)
113define void @f9(fp128 *%ptr) #0 {
114; CHECK-LABEL: f9:
115; CHECK: brasl %r14, floorl@PLT
116; CHECK: br %r14
117  %src = load fp128, fp128 *%ptr
118  %res = call fp128 @llvm.experimental.constrained.floor.f128(
119                        fp128 %src,
120                        metadata !"fpexcept.strict") #0
121  store fp128 %res, fp128 *%ptr
122  ret void
123}
124
125; Test ceil for f32.
126declare float @llvm.experimental.constrained.ceil.f32(float, metadata)
127define float @f10(float %f) #0 {
128; CHECK-LABEL: f10:
129; CHECK: brasl %r14, ceilf@PLT
130; CHECK: br %r14
131  %res = call float @llvm.experimental.constrained.ceil.f32(
132                        float %f,
133                        metadata !"fpexcept.strict") #0
134  ret float %res
135}
136
137; Test ceil for f64.
138declare double @llvm.experimental.constrained.ceil.f64(double, metadata)
139define double @f11(double %f) #0 {
140; CHECK-LABEL: f11:
141; CHECK: brasl %r14, ceil@PLT
142; CHECK: br %r14
143  %res = call double @llvm.experimental.constrained.ceil.f64(
144                        double %f,
145                        metadata !"fpexcept.strict") #0
146  ret double %res
147}
148
149; Test ceil for f128.
150declare fp128 @llvm.experimental.constrained.ceil.f128(fp128, metadata)
151define void @f12(fp128 *%ptr) #0 {
152; CHECK-LABEL: f12:
153; CHECK: brasl %r14, ceill@PLT
154; CHECK: br %r14
155  %src = load fp128, fp128 *%ptr
156  %res = call fp128 @llvm.experimental.constrained.ceil.f128(
157                        fp128 %src,
158                        metadata !"fpexcept.strict") #0
159  store fp128 %res, fp128 *%ptr
160  ret void
161}
162
163; Test trunc for f32.
164declare float @llvm.experimental.constrained.trunc.f32(float, metadata)
165define float @f13(float %f) #0 {
166; CHECK-LABEL: f13:
167; CHECK: brasl %r14, truncf@PLT
168; CHECK: br %r14
169  %res = call float @llvm.experimental.constrained.trunc.f32(
170                        float %f,
171                        metadata !"fpexcept.strict") #0
172  ret float %res
173}
174
175; Test trunc for f64.
176declare double @llvm.experimental.constrained.trunc.f64(double, metadata)
177define double @f14(double %f) #0 {
178; CHECK-LABEL: f14:
179; CHECK: brasl %r14, trunc@PLT
180; CHECK: br %r14
181  %res = call double @llvm.experimental.constrained.trunc.f64(
182                        double %f,
183                        metadata !"fpexcept.strict") #0
184  ret double %res
185}
186
187; Test trunc for f128.
188declare fp128 @llvm.experimental.constrained.trunc.f128(fp128, metadata)
189define void @f15(fp128 *%ptr) #0 {
190; CHECK-LABEL: f15:
191; CHECK: brasl %r14, truncl@PLT
192; CHECK: br %r14
193  %src = load fp128, fp128 *%ptr
194  %res = call fp128 @llvm.experimental.constrained.trunc.f128(
195                        fp128 %src,
196                        metadata !"fpexcept.strict") #0
197  store fp128 %res, fp128 *%ptr
198  ret void
199}
200
201; Test round for f32.
202declare float @llvm.experimental.constrained.round.f32(float, metadata)
203define float @f16(float %f) #0 {
204; CHECK-LABEL: f16:
205; CHECK: brasl %r14, roundf@PLT
206; CHECK: br %r14
207  %res = call float @llvm.experimental.constrained.round.f32(
208                        float %f,
209                        metadata !"fpexcept.strict") #0
210  ret float %res
211}
212
213; Test round for f64.
214declare double @llvm.experimental.constrained.round.f64(double, metadata)
215define double @f17(double %f) #0 {
216; CHECK-LABEL: f17:
217; CHECK: brasl %r14, round@PLT
218; CHECK: br %r14
219  %res = call double @llvm.experimental.constrained.round.f64(
220                        double %f,
221                        metadata !"fpexcept.strict") #0
222  ret double %res
223}
224
225; Test round for f128.
226declare fp128 @llvm.experimental.constrained.round.f128(fp128, metadata)
227define void @f18(fp128 *%ptr) #0 {
228; CHECK-LABEL: f18:
229; CHECK: brasl %r14, roundl@PLT
230; CHECK: br %r14
231  %src = load fp128, fp128 *%ptr
232  %res = call fp128 @llvm.experimental.constrained.round.f128(
233                        fp128 %src,
234                        metadata !"fpexcept.strict") #0
235  store fp128 %res, fp128 *%ptr
236  ret void
237}
238
239attributes #0 = { strictfp }
240