1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
7 ; This file tests the code generation for `llvm.experimental.constrained.roundeven.*` on scalable vector type.
9 define <1 x half> @roundeven_v1f16(<1 x half> %x) strictfp {
10 ; CHECK-LABEL: roundeven_v1f16:
12 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, mu
13 ; CHECK-NEXT: vmfne.vv v0, v8, v8
14 ; CHECK-NEXT: lui a0, %hi(.LCPI0_0)
15 ; CHECK-NEXT: flh fa5, %lo(.LCPI0_0)(a0)
16 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
17 ; CHECK-NEXT: vfabs.v v9, v8
18 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
19 ; CHECK-NEXT: fsrmi a0, 0
20 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
21 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
23 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
24 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
25 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
27 %a = call <1 x half> @llvm.experimental.constrained.roundeven.v1f16(<1 x half> %x, metadata !"fpexcept.strict")
30 declare <1 x half> @llvm.experimental.constrained.roundeven.v1f16(<1 x half>, metadata)
32 define <2 x half> @roundeven_v2f16(<2 x half> %x) strictfp {
33 ; CHECK-LABEL: roundeven_v2f16:
35 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, mu
36 ; CHECK-NEXT: vmfne.vv v0, v8, v8
37 ; CHECK-NEXT: lui a0, %hi(.LCPI1_0)
38 ; CHECK-NEXT: flh fa5, %lo(.LCPI1_0)(a0)
39 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
40 ; CHECK-NEXT: vfabs.v v9, v8
41 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
42 ; CHECK-NEXT: fsrmi a0, 0
43 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
44 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
46 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
47 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
48 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
50 %a = call <2 x half> @llvm.experimental.constrained.roundeven.v2f16(<2 x half> %x, metadata !"fpexcept.strict")
53 declare <2 x half> @llvm.experimental.constrained.roundeven.v2f16(<2 x half>, metadata)
55 define <4 x half> @roundeven_v4f16(<4 x half> %x) strictfp {
56 ; CHECK-LABEL: roundeven_v4f16:
58 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
59 ; CHECK-NEXT: vmfne.vv v0, v8, v8
60 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
61 ; CHECK-NEXT: flh fa5, %lo(.LCPI2_0)(a0)
62 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
63 ; CHECK-NEXT: vfabs.v v9, v8
64 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
65 ; CHECK-NEXT: fsrmi a0, 0
66 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
67 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
69 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
70 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
71 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
73 %a = call <4 x half> @llvm.experimental.constrained.roundeven.v4f16(<4 x half> %x, metadata !"fpexcept.strict")
76 declare <4 x half> @llvm.experimental.constrained.roundeven.v4f16(<4 x half>, metadata)
78 define <8 x half> @roundeven_v8f16(<8 x half> %x) strictfp {
79 ; CHECK-LABEL: roundeven_v8f16:
81 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, mu
82 ; CHECK-NEXT: vmfne.vv v0, v8, v8
83 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
84 ; CHECK-NEXT: flh fa5, %lo(.LCPI3_0)(a0)
85 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
86 ; CHECK-NEXT: vfabs.v v9, v8
87 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
88 ; CHECK-NEXT: fsrmi a0, 0
89 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
90 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
92 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
93 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu
94 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
96 %a = call <8 x half> @llvm.experimental.constrained.roundeven.v8f16(<8 x half> %x, metadata !"fpexcept.strict")
99 declare <8 x half> @llvm.experimental.constrained.roundeven.v8f16(<8 x half>, metadata)
101 define <16 x half> @roundeven_v16f16(<16 x half> %x) strictfp {
102 ; CHECK-LABEL: roundeven_v16f16:
104 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, mu
105 ; CHECK-NEXT: vmfne.vv v0, v8, v8
106 ; CHECK-NEXT: lui a0, %hi(.LCPI4_0)
107 ; CHECK-NEXT: flh fa5, %lo(.LCPI4_0)(a0)
108 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
109 ; CHECK-NEXT: vfabs.v v10, v8
110 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
111 ; CHECK-NEXT: fsrmi a0, 0
112 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
113 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
114 ; CHECK-NEXT: fsrm a0
115 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
116 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu
117 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
119 %a = call <16 x half> @llvm.experimental.constrained.roundeven.v16f16(<16 x half> %x, metadata !"fpexcept.strict")
122 declare <16 x half> @llvm.experimental.constrained.roundeven.v16f16(<16 x half>, metadata)
124 define <32 x half> @roundeven_v32f16(<32 x half> %x) strictfp {
125 ; CHECK-LABEL: roundeven_v32f16:
127 ; CHECK-NEXT: li a0, 32
128 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, mu
129 ; CHECK-NEXT: vmfne.vv v0, v8, v8
130 ; CHECK-NEXT: lui a0, %hi(.LCPI5_0)
131 ; CHECK-NEXT: flh fa5, %lo(.LCPI5_0)(a0)
132 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
133 ; CHECK-NEXT: vfabs.v v12, v8
134 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
135 ; CHECK-NEXT: fsrmi a0, 0
136 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, ma
137 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
138 ; CHECK-NEXT: fsrm a0
139 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
140 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu
141 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
143 %a = call <32 x half> @llvm.experimental.constrained.roundeven.v32f16(<32 x half> %x, metadata !"fpexcept.strict")
146 declare <32 x half> @llvm.experimental.constrained.roundeven.v32f16(<32 x half>, metadata)
148 define <1 x float> @roundeven_v1f32(<1 x float> %x) strictfp {
149 ; CHECK-LABEL: roundeven_v1f32:
151 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, mu
152 ; CHECK-NEXT: vmfne.vv v0, v8, v8
153 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
154 ; CHECK-NEXT: vfabs.v v9, v8
155 ; CHECK-NEXT: lui a0, 307200
156 ; CHECK-NEXT: fmv.w.x fa5, a0
157 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
158 ; CHECK-NEXT: fsrmi a0, 0
159 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
160 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
161 ; CHECK-NEXT: fsrm a0
162 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
163 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
164 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
166 %a = call <1 x float> @llvm.experimental.constrained.roundeven.v1f32(<1 x float> %x, metadata !"fpexcept.strict")
169 declare <1 x float> @llvm.experimental.constrained.roundeven.v1f32(<1 x float>, metadata)
171 define <2 x float> @roundeven_v2f32(<2 x float> %x) strictfp {
172 ; CHECK-LABEL: roundeven_v2f32:
174 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, mu
175 ; CHECK-NEXT: vmfne.vv v0, v8, v8
176 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
177 ; CHECK-NEXT: vfabs.v v9, v8
178 ; CHECK-NEXT: lui a0, 307200
179 ; CHECK-NEXT: fmv.w.x fa5, a0
180 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
181 ; CHECK-NEXT: fsrmi a0, 0
182 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
183 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
184 ; CHECK-NEXT: fsrm a0
185 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
186 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
187 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
189 %a = call <2 x float> @llvm.experimental.constrained.roundeven.v2f32(<2 x float> %x, metadata !"fpexcept.strict")
192 declare <2 x float> @llvm.experimental.constrained.roundeven.v2f32(<2 x float>, metadata)
194 define <4 x float> @roundeven_v4f32(<4 x float> %x) strictfp {
195 ; CHECK-LABEL: roundeven_v4f32:
197 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, mu
198 ; CHECK-NEXT: vmfne.vv v0, v8, v8
199 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
200 ; CHECK-NEXT: vfabs.v v9, v8
201 ; CHECK-NEXT: lui a0, 307200
202 ; CHECK-NEXT: fmv.w.x fa5, a0
203 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
204 ; CHECK-NEXT: fsrmi a0, 0
205 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
206 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
207 ; CHECK-NEXT: fsrm a0
208 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
209 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu
210 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
212 %a = call <4 x float> @llvm.experimental.constrained.roundeven.v4f32(<4 x float> %x, metadata !"fpexcept.strict")
215 declare <4 x float> @llvm.experimental.constrained.roundeven.v4f32(<4 x float>, metadata)
217 define <8 x float> @roundeven_v8f32(<8 x float> %x) strictfp {
218 ; CHECK-LABEL: roundeven_v8f32:
220 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, mu
221 ; CHECK-NEXT: vmfne.vv v0, v8, v8
222 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
223 ; CHECK-NEXT: vfabs.v v10, v8
224 ; CHECK-NEXT: lui a0, 307200
225 ; CHECK-NEXT: fmv.w.x fa5, a0
226 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
227 ; CHECK-NEXT: fsrmi a0, 0
228 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
229 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
230 ; CHECK-NEXT: fsrm a0
231 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
232 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu
233 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
235 %a = call <8 x float> @llvm.experimental.constrained.roundeven.v8f32(<8 x float> %x, metadata !"fpexcept.strict")
238 declare <8 x float> @llvm.experimental.constrained.roundeven.v8f32(<8 x float>, metadata)
240 define <16 x float> @roundeven_v16f32(<16 x float> %x) strictfp {
241 ; CHECK-LABEL: roundeven_v16f32:
243 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, mu
244 ; CHECK-NEXT: vmfne.vv v0, v8, v8
245 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
246 ; CHECK-NEXT: vfabs.v v12, v8
247 ; CHECK-NEXT: lui a0, 307200
248 ; CHECK-NEXT: fmv.w.x fa5, a0
249 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
250 ; CHECK-NEXT: fsrmi a0, 0
251 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
252 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
253 ; CHECK-NEXT: fsrm a0
254 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
255 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu
256 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
258 %a = call <16 x float> @llvm.experimental.constrained.roundeven.v16f32(<16 x float> %x, metadata !"fpexcept.strict")
261 declare <16 x float> @llvm.experimental.constrained.roundeven.v16f32(<16 x float>, metadata)
263 define <1 x double> @roundeven_v1f64(<1 x double> %x) strictfp {
264 ; CHECK-LABEL: roundeven_v1f64:
266 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, mu
267 ; CHECK-NEXT: vmfne.vv v0, v8, v8
268 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
269 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
270 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
271 ; CHECK-NEXT: vfabs.v v9, v8
272 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
273 ; CHECK-NEXT: fsrmi a0, 0
274 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
275 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
276 ; CHECK-NEXT: fsrm a0
277 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
278 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
279 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
281 %a = call <1 x double> @llvm.experimental.constrained.roundeven.v1f64(<1 x double> %x, metadata !"fpexcept.strict")
284 declare <1 x double> @llvm.experimental.constrained.roundeven.v1f64(<1 x double>, metadata)
286 define <2 x double> @roundeven_v2f64(<2 x double> %x) strictfp {
287 ; CHECK-LABEL: roundeven_v2f64:
289 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, mu
290 ; CHECK-NEXT: vmfne.vv v0, v8, v8
291 ; CHECK-NEXT: lui a0, %hi(.LCPI12_0)
292 ; CHECK-NEXT: fld fa5, %lo(.LCPI12_0)(a0)
293 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
294 ; CHECK-NEXT: vfabs.v v9, v8
295 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
296 ; CHECK-NEXT: fsrmi a0, 0
297 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
298 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
299 ; CHECK-NEXT: fsrm a0
300 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
301 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
302 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
304 %a = call <2 x double> @llvm.experimental.constrained.roundeven.v2f64(<2 x double> %x, metadata !"fpexcept.strict")
307 declare <2 x double> @llvm.experimental.constrained.roundeven.v2f64(<2 x double>, metadata)
309 define <4 x double> @roundeven_v4f64(<4 x double> %x) strictfp {
310 ; CHECK-LABEL: roundeven_v4f64:
312 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, mu
313 ; CHECK-NEXT: vmfne.vv v0, v8, v8
314 ; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
315 ; CHECK-NEXT: fld fa5, %lo(.LCPI13_0)(a0)
316 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
317 ; CHECK-NEXT: vfabs.v v10, v8
318 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
319 ; CHECK-NEXT: fsrmi a0, 0
320 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
321 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
322 ; CHECK-NEXT: fsrm a0
323 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
324 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
325 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
327 %a = call <4 x double> @llvm.experimental.constrained.roundeven.v4f64(<4 x double> %x, metadata !"fpexcept.strict")
330 declare <4 x double> @llvm.experimental.constrained.roundeven.v4f64(<4 x double>, metadata)
332 define <8 x double> @roundeven_v8f64(<8 x double> %x) strictfp {
333 ; CHECK-LABEL: roundeven_v8f64:
335 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, mu
336 ; CHECK-NEXT: vmfne.vv v0, v8, v8
337 ; CHECK-NEXT: lui a0, %hi(.LCPI14_0)
338 ; CHECK-NEXT: fld fa5, %lo(.LCPI14_0)(a0)
339 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
340 ; CHECK-NEXT: vfabs.v v12, v8
341 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
342 ; CHECK-NEXT: fsrmi a0, 0
343 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
344 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
345 ; CHECK-NEXT: fsrm a0
346 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
347 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu
348 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
350 %a = call <8 x double> @llvm.experimental.constrained.roundeven.v8f64(<8 x double> %x, metadata !"fpexcept.strict")
353 declare <8 x double> @llvm.experimental.constrained.roundeven.v8f64(<8 x double>, metadata)