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, ma
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: vfcvt.x.f.v v9, v8, v0.t
22 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
23 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
24 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
26 %a = call <1 x half> @llvm.experimental.constrained.roundeven.v1f16(<1 x half> %x, metadata !"fpexcept.strict")
29 declare <1 x half> @llvm.experimental.constrained.roundeven.v1f16(<1 x half>, metadata)
31 define <2 x half> @roundeven_v2f16(<2 x half> %x) strictfp {
32 ; CHECK-LABEL: roundeven_v2f16:
34 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
35 ; CHECK-NEXT: vmfne.vv v0, v8, v8
36 ; CHECK-NEXT: lui a0, %hi(.LCPI1_0)
37 ; CHECK-NEXT: flh fa5, %lo(.LCPI1_0)(a0)
38 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
39 ; CHECK-NEXT: vfabs.v v9, v8
40 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
41 ; CHECK-NEXT: fsrmi a0, 0
42 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
44 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
45 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
46 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
48 %a = call <2 x half> @llvm.experimental.constrained.roundeven.v2f16(<2 x half> %x, metadata !"fpexcept.strict")
51 declare <2 x half> @llvm.experimental.constrained.roundeven.v2f16(<2 x half>, metadata)
53 define <4 x half> @roundeven_v4f16(<4 x half> %x) strictfp {
54 ; CHECK-LABEL: roundeven_v4f16:
56 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
57 ; CHECK-NEXT: vmfne.vv v0, v8, v8
58 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
59 ; CHECK-NEXT: flh fa5, %lo(.LCPI2_0)(a0)
60 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
61 ; CHECK-NEXT: vfabs.v v9, v8
62 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
63 ; CHECK-NEXT: fsrmi a0, 0
64 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
66 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
67 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
68 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
70 %a = call <4 x half> @llvm.experimental.constrained.roundeven.v4f16(<4 x half> %x, metadata !"fpexcept.strict")
73 declare <4 x half> @llvm.experimental.constrained.roundeven.v4f16(<4 x half>, metadata)
75 define <8 x half> @roundeven_v8f16(<8 x half> %x) strictfp {
76 ; CHECK-LABEL: roundeven_v8f16:
78 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
79 ; CHECK-NEXT: vmfne.vv v0, v8, v8
80 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
81 ; CHECK-NEXT: flh fa5, %lo(.LCPI3_0)(a0)
82 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
83 ; CHECK-NEXT: vfabs.v v9, v8
84 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
85 ; CHECK-NEXT: fsrmi a0, 0
86 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
88 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
89 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu
90 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
92 %a = call <8 x half> @llvm.experimental.constrained.roundeven.v8f16(<8 x half> %x, metadata !"fpexcept.strict")
95 declare <8 x half> @llvm.experimental.constrained.roundeven.v8f16(<8 x half>, metadata)
97 define <16 x half> @roundeven_v16f16(<16 x half> %x) strictfp {
98 ; CHECK-LABEL: roundeven_v16f16:
100 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, ma
101 ; CHECK-NEXT: vmfne.vv v0, v8, v8
102 ; CHECK-NEXT: lui a0, %hi(.LCPI4_0)
103 ; CHECK-NEXT: flh fa5, %lo(.LCPI4_0)(a0)
104 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
105 ; CHECK-NEXT: vfabs.v v10, v8
106 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
107 ; CHECK-NEXT: fsrmi a0, 0
108 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
109 ; CHECK-NEXT: fsrm a0
110 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
111 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu
112 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
114 %a = call <16 x half> @llvm.experimental.constrained.roundeven.v16f16(<16 x half> %x, metadata !"fpexcept.strict")
117 declare <16 x half> @llvm.experimental.constrained.roundeven.v16f16(<16 x half>, metadata)
119 define <32 x half> @roundeven_v32f16(<32 x half> %x) strictfp {
120 ; CHECK-LABEL: roundeven_v32f16:
122 ; CHECK-NEXT: li a0, 32
123 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma
124 ; CHECK-NEXT: vmfne.vv v0, v8, v8
125 ; CHECK-NEXT: lui a0, %hi(.LCPI5_0)
126 ; CHECK-NEXT: flh fa5, %lo(.LCPI5_0)(a0)
127 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
128 ; CHECK-NEXT: vfabs.v v12, v8
129 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
130 ; CHECK-NEXT: fsrmi a0, 0
131 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
132 ; CHECK-NEXT: fsrm a0
133 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
134 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu
135 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
137 %a = call <32 x half> @llvm.experimental.constrained.roundeven.v32f16(<32 x half> %x, metadata !"fpexcept.strict")
140 declare <32 x half> @llvm.experimental.constrained.roundeven.v32f16(<32 x half>, metadata)
142 define <1 x float> @roundeven_v1f32(<1 x float> %x) strictfp {
143 ; CHECK-LABEL: roundeven_v1f32:
145 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
146 ; CHECK-NEXT: vmfne.vv v0, v8, v8
147 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
148 ; CHECK-NEXT: vfabs.v v9, v8
149 ; CHECK-NEXT: lui a0, 307200
150 ; CHECK-NEXT: fmv.w.x fa5, a0
151 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
152 ; CHECK-NEXT: fsrmi a0, 0
153 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
154 ; CHECK-NEXT: fsrm a0
155 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
156 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
157 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
159 %a = call <1 x float> @llvm.experimental.constrained.roundeven.v1f32(<1 x float> %x, metadata !"fpexcept.strict")
162 declare <1 x float> @llvm.experimental.constrained.roundeven.v1f32(<1 x float>, metadata)
164 define <2 x float> @roundeven_v2f32(<2 x float> %x) strictfp {
165 ; CHECK-LABEL: roundeven_v2f32:
167 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
168 ; CHECK-NEXT: vmfne.vv v0, v8, v8
169 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
170 ; CHECK-NEXT: vfabs.v v9, v8
171 ; CHECK-NEXT: lui a0, 307200
172 ; CHECK-NEXT: fmv.w.x fa5, a0
173 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
174 ; CHECK-NEXT: fsrmi a0, 0
175 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
176 ; CHECK-NEXT: fsrm a0
177 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
178 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
179 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
181 %a = call <2 x float> @llvm.experimental.constrained.roundeven.v2f32(<2 x float> %x, metadata !"fpexcept.strict")
184 declare <2 x float> @llvm.experimental.constrained.roundeven.v2f32(<2 x float>, metadata)
186 define <4 x float> @roundeven_v4f32(<4 x float> %x) strictfp {
187 ; CHECK-LABEL: roundeven_v4f32:
189 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
190 ; CHECK-NEXT: vmfne.vv v0, v8, v8
191 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
192 ; CHECK-NEXT: vfabs.v v9, v8
193 ; CHECK-NEXT: lui a0, 307200
194 ; CHECK-NEXT: fmv.w.x fa5, a0
195 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
196 ; CHECK-NEXT: fsrmi a0, 0
197 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
198 ; CHECK-NEXT: fsrm a0
199 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
200 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu
201 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
203 %a = call <4 x float> @llvm.experimental.constrained.roundeven.v4f32(<4 x float> %x, metadata !"fpexcept.strict")
206 declare <4 x float> @llvm.experimental.constrained.roundeven.v4f32(<4 x float>, metadata)
208 define <8 x float> @roundeven_v8f32(<8 x float> %x) strictfp {
209 ; CHECK-LABEL: roundeven_v8f32:
211 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
212 ; CHECK-NEXT: vmfne.vv v0, v8, v8
213 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
214 ; CHECK-NEXT: vfabs.v v10, v8
215 ; CHECK-NEXT: lui a0, 307200
216 ; CHECK-NEXT: fmv.w.x fa5, a0
217 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
218 ; CHECK-NEXT: fsrmi a0, 0
219 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
220 ; CHECK-NEXT: fsrm a0
221 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
222 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu
223 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
225 %a = call <8 x float> @llvm.experimental.constrained.roundeven.v8f32(<8 x float> %x, metadata !"fpexcept.strict")
228 declare <8 x float> @llvm.experimental.constrained.roundeven.v8f32(<8 x float>, metadata)
230 define <16 x float> @roundeven_v16f32(<16 x float> %x) strictfp {
231 ; CHECK-LABEL: roundeven_v16f32:
233 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
234 ; CHECK-NEXT: vmfne.vv v0, v8, v8
235 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
236 ; CHECK-NEXT: vfabs.v v12, v8
237 ; CHECK-NEXT: lui a0, 307200
238 ; CHECK-NEXT: fmv.w.x fa5, a0
239 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
240 ; CHECK-NEXT: fsrmi a0, 0
241 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
242 ; CHECK-NEXT: fsrm a0
243 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
244 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu
245 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
247 %a = call <16 x float> @llvm.experimental.constrained.roundeven.v16f32(<16 x float> %x, metadata !"fpexcept.strict")
250 declare <16 x float> @llvm.experimental.constrained.roundeven.v16f32(<16 x float>, metadata)
252 define <1 x double> @roundeven_v1f64(<1 x double> %x) strictfp {
253 ; CHECK-LABEL: roundeven_v1f64:
255 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
256 ; CHECK-NEXT: vmfne.vv v0, v8, v8
257 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
258 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
259 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
260 ; CHECK-NEXT: vfabs.v v9, v8
261 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
262 ; CHECK-NEXT: fsrmi a0, 0
263 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
264 ; CHECK-NEXT: fsrm a0
265 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
266 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
267 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
269 %a = call <1 x double> @llvm.experimental.constrained.roundeven.v1f64(<1 x double> %x, metadata !"fpexcept.strict")
272 declare <1 x double> @llvm.experimental.constrained.roundeven.v1f64(<1 x double>, metadata)
274 define <2 x double> @roundeven_v2f64(<2 x double> %x) strictfp {
275 ; CHECK-LABEL: roundeven_v2f64:
277 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
278 ; CHECK-NEXT: vmfne.vv v0, v8, v8
279 ; CHECK-NEXT: lui a0, %hi(.LCPI12_0)
280 ; CHECK-NEXT: fld fa5, %lo(.LCPI12_0)(a0)
281 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
282 ; CHECK-NEXT: vfabs.v v9, v8
283 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
284 ; CHECK-NEXT: fsrmi a0, 0
285 ; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t
286 ; CHECK-NEXT: fsrm a0
287 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
288 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
289 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
291 %a = call <2 x double> @llvm.experimental.constrained.roundeven.v2f64(<2 x double> %x, metadata !"fpexcept.strict")
294 declare <2 x double> @llvm.experimental.constrained.roundeven.v2f64(<2 x double>, metadata)
296 define <4 x double> @roundeven_v4f64(<4 x double> %x) strictfp {
297 ; CHECK-LABEL: roundeven_v4f64:
299 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
300 ; CHECK-NEXT: vmfne.vv v0, v8, v8
301 ; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
302 ; CHECK-NEXT: fld fa5, %lo(.LCPI13_0)(a0)
303 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
304 ; CHECK-NEXT: vfabs.v v10, v8
305 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
306 ; CHECK-NEXT: fsrmi a0, 0
307 ; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t
308 ; CHECK-NEXT: fsrm a0
309 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
310 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
311 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
313 %a = call <4 x double> @llvm.experimental.constrained.roundeven.v4f64(<4 x double> %x, metadata !"fpexcept.strict")
316 declare <4 x double> @llvm.experimental.constrained.roundeven.v4f64(<4 x double>, metadata)
318 define <8 x double> @roundeven_v8f64(<8 x double> %x) strictfp {
319 ; CHECK-LABEL: roundeven_v8f64:
321 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, ma
322 ; CHECK-NEXT: vmfne.vv v0, v8, v8
323 ; CHECK-NEXT: lui a0, %hi(.LCPI14_0)
324 ; CHECK-NEXT: fld fa5, %lo(.LCPI14_0)(a0)
325 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
326 ; CHECK-NEXT: vfabs.v v12, v8
327 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
328 ; CHECK-NEXT: fsrmi a0, 0
329 ; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t
330 ; CHECK-NEXT: fsrm a0
331 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
332 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu
333 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
335 %a = call <8 x double> @llvm.experimental.constrained.roundeven.v8f64(<8 x double> %x, metadata !"fpexcept.strict")
338 declare <8 x double> @llvm.experimental.constrained.roundeven.v8f64(<8 x double>, metadata)