1; Test strict rounding functions for z14 and above.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | 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: fiebra %f0, 0, %f0, 0
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: fidbra %f0, 0, %f0, 0
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: vl [[REG:%v[0-9]+]], 0(%r2)
36; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 0, 0
37; CHECK: vst [[RES]], 0(%r2)
38; CHECK: br %r14
39  %src = load fp128, fp128 *%ptr
40  %res = call fp128 @llvm.experimental.constrained.rint.f128(
41                        fp128 %src,
42                        metadata !"round.dynamic",
43                        metadata !"fpexcept.strict") #0
44  store fp128 %res, fp128 *%ptr
45  ret void
46}
47
48; Test nearbyint for f32.
49declare float @llvm.experimental.constrained.nearbyint.f32(float, metadata, metadata)
50define float @f4(float %f) #0 {
51; CHECK-LABEL: f4:
52; CHECK: fiebra %f0, 0, %f0, 4
53; CHECK: br %r14
54  %res = call float @llvm.experimental.constrained.nearbyint.f32(
55                        float %f,
56                        metadata !"round.dynamic",
57                        metadata !"fpexcept.strict") #0
58  ret float %res
59}
60
61; Test nearbyint for f64.
62declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata)
63define double @f5(double %f) #0 {
64; CHECK-LABEL: f5:
65; CHECK: fidbra %f0, 0, %f0, 4
66; CHECK: br %r14
67  %res = call double @llvm.experimental.constrained.nearbyint.f64(
68                        double %f,
69                        metadata !"round.dynamic",
70                        metadata !"fpexcept.strict") #0
71  ret double %res
72}
73
74; Test nearbyint for f128.
75declare fp128 @llvm.experimental.constrained.nearbyint.f128(fp128, metadata, metadata)
76define void @f6(fp128 *%ptr) #0 {
77; CHECK-LABEL: f6:
78; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
79; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 0
80; CHECK: vst [[RES]], 0(%r2)
81; CHECK: br %r14
82  %src = load fp128, fp128 *%ptr
83  %res = call fp128 @llvm.experimental.constrained.nearbyint.f128(
84                        fp128 %src,
85                        metadata !"round.dynamic",
86                        metadata !"fpexcept.strict") #0
87  store fp128 %res, fp128 *%ptr
88  ret void
89}
90
91; Test floor for f32.
92declare float @llvm.experimental.constrained.floor.f32(float, metadata)
93define float @f7(float %f) #0 {
94; CHECK-LABEL: f7:
95; CHECK: fiebra %f0, 7, %f0, 4
96; CHECK: br %r14
97  %res = call float @llvm.experimental.constrained.floor.f32(
98                        float %f,
99                        metadata !"fpexcept.strict") #0
100  ret float %res
101}
102
103; Test floor for f64.
104declare double @llvm.experimental.constrained.floor.f64(double, metadata)
105define double @f8(double %f) #0 {
106; CHECK-LABEL: f8:
107; CHECK: fidbra %f0, 7, %f0, 4
108; CHECK: br %r14
109  %res = call double @llvm.experimental.constrained.floor.f64(
110                        double %f,
111                        metadata !"fpexcept.strict") #0
112  ret double %res
113}
114
115; Test floor for f128.
116declare fp128 @llvm.experimental.constrained.floor.f128(fp128, metadata)
117define void @f9(fp128 *%ptr) #0 {
118; CHECK-LABEL: f9:
119; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
120; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 7
121; CHECK: vst [[RES]], 0(%r2)
122; CHECK: br %r14
123  %src = load fp128, fp128 *%ptr
124  %res = call fp128 @llvm.experimental.constrained.floor.f128(
125                        fp128 %src,
126                        metadata !"fpexcept.strict") #0
127  store fp128 %res, fp128 *%ptr
128  ret void
129}
130
131; Test ceil for f32.
132declare float @llvm.experimental.constrained.ceil.f32(float, metadata)
133define float @f10(float %f) #0 {
134; CHECK-LABEL: f10:
135; CHECK: fiebra %f0, 6, %f0, 4
136; CHECK: br %r14
137  %res = call float @llvm.experimental.constrained.ceil.f32(
138                        float %f,
139                        metadata !"fpexcept.strict") #0
140  ret float %res
141}
142
143; Test ceil for f64.
144declare double @llvm.experimental.constrained.ceil.f64(double, metadata)
145define double @f11(double %f) #0 {
146; CHECK-LABEL: f11:
147; CHECK: fidbra %f0, 6, %f0, 4
148; CHECK: br %r14
149  %res = call double @llvm.experimental.constrained.ceil.f64(
150                        double %f,
151                        metadata !"fpexcept.strict") #0
152  ret double %res
153}
154
155; Test ceil for f128.
156declare fp128 @llvm.experimental.constrained.ceil.f128(fp128, metadata)
157define void @f12(fp128 *%ptr) #0 {
158; CHECK-LABEL: f12:
159; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
160; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 6
161; CHECK: vst [[RES]], 0(%r2)
162; CHECK: br %r14
163  %src = load fp128, fp128 *%ptr
164  %res = call fp128 @llvm.experimental.constrained.ceil.f128(
165                        fp128 %src,
166                        metadata !"fpexcept.strict") #0
167  store fp128 %res, fp128 *%ptr
168  ret void
169}
170
171; Test trunc for f32.
172declare float @llvm.experimental.constrained.trunc.f32(float, metadata)
173define float @f13(float %f) #0 {
174; CHECK-LABEL: f13:
175; CHECK: fiebra %f0, 5, %f0, 4
176; CHECK: br %r14
177  %res = call float @llvm.experimental.constrained.trunc.f32(
178                        float %f,
179                        metadata !"fpexcept.strict") #0
180  ret float %res
181}
182
183; Test trunc for f64.
184declare double @llvm.experimental.constrained.trunc.f64(double, metadata)
185define double @f14(double %f) #0 {
186; CHECK-LABEL: f14:
187; CHECK: fidbra %f0, 5, %f0, 4
188; CHECK: br %r14
189  %res = call double @llvm.experimental.constrained.trunc.f64(
190                        double %f,
191                        metadata !"fpexcept.strict") #0
192  ret double %res
193}
194
195; Test trunc for f128.
196declare fp128 @llvm.experimental.constrained.trunc.f128(fp128, metadata)
197define void @f15(fp128 *%ptr) #0 {
198; CHECK-LABEL: f15:
199; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
200; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 5
201; CHECK: vst [[RES]], 0(%r2)
202; CHECK: br %r14
203  %src = load fp128, fp128 *%ptr
204  %res = call fp128 @llvm.experimental.constrained.trunc.f128(
205                        fp128 %src,
206                        metadata !"fpexcept.strict") #0
207  store fp128 %res, fp128 *%ptr
208  ret void
209}
210
211; Test round for f32.
212declare float @llvm.experimental.constrained.round.f32(float, metadata)
213define float @f16(float %f) #0 {
214; CHECK-LABEL: f16:
215; CHECK: fiebra %f0, 1, %f0, 4
216; CHECK: br %r14
217  %res = call float @llvm.experimental.constrained.round.f32(
218                        float %f,
219                        metadata !"fpexcept.strict") #0
220  ret float %res
221}
222
223; Test round for f64.
224declare double @llvm.experimental.constrained.round.f64(double, metadata)
225define double @f17(double %f) #0 {
226; CHECK-LABEL: f17:
227; CHECK: fidbra %f0, 1, %f0, 4
228; CHECK: br %r14
229  %res = call double @llvm.experimental.constrained.round.f64(
230                        double %f,
231                        metadata !"fpexcept.strict") #0
232  ret double %res
233}
234
235; Test round for f128.
236declare fp128 @llvm.experimental.constrained.round.f128(fp128, metadata)
237define void @f18(fp128 *%ptr) #0 {
238; CHECK-LABEL: f18:
239; CHECK: vl [[REG:%v[0-9]+]], 0(%r2)
240; CHECK: wfixb [[RES:%v[0-9]+]], [[REG]], 4, 1
241; CHECK: vst [[RES]], 0(%r2)
242; CHECK: br %r14
243  %src = load fp128, fp128 *%ptr
244  %res = call fp128 @llvm.experimental.constrained.round.f128(
245                        fp128 %src,
246                        metadata !"fpexcept.strict") #0
247  store fp128 %res, fp128 *%ptr
248  ret void
249}
250
251attributes #0 = { strictfp }
252