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 define <1 x half> @trunc_v1f16(<1 x half> %x) strictfp {
8 ; CHECK-LABEL: trunc_v1f16:
10 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, mu
11 ; CHECK-NEXT: vmfne.vv v0, v8, v8
12 ; CHECK-NEXT: lui a0, %hi(.LCPI0_0)
13 ; CHECK-NEXT: flh fa5, %lo(.LCPI0_0)(a0)
14 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
15 ; CHECK-NEXT: vfabs.v v9, v8
16 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
17 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
18 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
19 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
20 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
21 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
23 %a = call <1 x half> @llvm.experimental.constrained.trunc.v1f16(<1 x half> %x, metadata !"fpexcept.strict")
26 declare <1 x half> @llvm.experimental.constrained.trunc.v1f16(<1 x half>, metadata)
28 define <2 x half> @trunc_v2f16(<2 x half> %x) strictfp {
29 ; CHECK-LABEL: trunc_v2f16:
31 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, mu
32 ; CHECK-NEXT: vmfne.vv v0, v8, v8
33 ; CHECK-NEXT: lui a0, %hi(.LCPI1_0)
34 ; CHECK-NEXT: flh fa5, %lo(.LCPI1_0)(a0)
35 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
36 ; CHECK-NEXT: vfabs.v v9, v8
37 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
38 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma
39 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
40 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
41 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
42 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
44 %a = call <2 x half> @llvm.experimental.constrained.trunc.v2f16(<2 x half> %x, metadata !"fpexcept.strict")
47 declare <2 x half> @llvm.experimental.constrained.trunc.v2f16(<2 x half>, metadata)
49 define <4 x half> @trunc_v4f16(<4 x half> %x) strictfp {
50 ; CHECK-LABEL: trunc_v4f16:
52 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
53 ; CHECK-NEXT: vmfne.vv v0, v8, v8
54 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
55 ; CHECK-NEXT: flh fa5, %lo(.LCPI2_0)(a0)
56 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
57 ; CHECK-NEXT: vfabs.v v9, v8
58 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
59 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
60 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
61 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
62 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
63 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
65 %a = call <4 x half> @llvm.experimental.constrained.trunc.v4f16(<4 x half> %x, metadata !"fpexcept.strict")
68 declare <4 x half> @llvm.experimental.constrained.trunc.v4f16(<4 x half>, metadata)
70 define <8 x half> @trunc_v8f16(<8 x half> %x) strictfp {
71 ; CHECK-LABEL: trunc_v8f16:
73 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, mu
74 ; CHECK-NEXT: vmfne.vv v0, v8, v8
75 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
76 ; CHECK-NEXT: flh fa5, %lo(.LCPI3_0)(a0)
77 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
78 ; CHECK-NEXT: vfabs.v v9, v8
79 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
80 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
81 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
82 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
83 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu
84 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
86 %a = call <8 x half> @llvm.experimental.constrained.trunc.v8f16(<8 x half> %x, metadata !"fpexcept.strict")
89 declare <8 x half> @llvm.experimental.constrained.trunc.v8f16(<8 x half>, metadata)
91 define <16 x half> @trunc_v16f16(<16 x half> %x) strictfp {
92 ; CHECK-LABEL: trunc_v16f16:
94 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, mu
95 ; CHECK-NEXT: vmfne.vv v0, v8, v8
96 ; CHECK-NEXT: lui a0, %hi(.LCPI4_0)
97 ; CHECK-NEXT: flh fa5, %lo(.LCPI4_0)(a0)
98 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
99 ; CHECK-NEXT: vfabs.v v10, v8
100 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
101 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
102 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
103 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
104 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu
105 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
107 %a = call <16 x half> @llvm.experimental.constrained.trunc.v16f16(<16 x half> %x, metadata !"fpexcept.strict")
110 declare <16 x half> @llvm.experimental.constrained.trunc.v16f16(<16 x half>, metadata)
112 define <32 x half> @trunc_v32f16(<32 x half> %x) strictfp {
113 ; CHECK-LABEL: trunc_v32f16:
115 ; CHECK-NEXT: li a0, 32
116 ; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, mu
117 ; CHECK-NEXT: vmfne.vv v0, v8, v8
118 ; CHECK-NEXT: lui a0, %hi(.LCPI5_0)
119 ; CHECK-NEXT: flh fa5, %lo(.LCPI5_0)(a0)
120 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
121 ; CHECK-NEXT: vfabs.v v12, v8
122 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
123 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, ma
124 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
125 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
126 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu
127 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
129 %a = call <32 x half> @llvm.experimental.constrained.trunc.v32f16(<32 x half> %x, metadata !"fpexcept.strict")
132 declare <32 x half> @llvm.experimental.constrained.trunc.v32f16(<32 x half>, metadata)
134 define <1 x float> @trunc_v1f32(<1 x float> %x) strictfp {
135 ; CHECK-LABEL: trunc_v1f32:
137 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, mu
138 ; CHECK-NEXT: vmfne.vv v0, v8, v8
139 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
140 ; CHECK-NEXT: vfabs.v v9, v8
141 ; CHECK-NEXT: lui a0, 307200
142 ; CHECK-NEXT: fmv.w.x fa5, a0
143 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
144 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
145 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
146 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
147 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
148 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
150 %a = call <1 x float> @llvm.experimental.constrained.trunc.v1f32(<1 x float> %x, metadata !"fpexcept.strict")
153 declare <1 x float> @llvm.experimental.constrained.trunc.v1f32(<1 x float>, metadata)
155 define <2 x float> @trunc_v2f32(<2 x float> %x) strictfp {
156 ; CHECK-LABEL: trunc_v2f32:
158 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, mu
159 ; CHECK-NEXT: vmfne.vv v0, v8, v8
160 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
161 ; CHECK-NEXT: vfabs.v v9, v8
162 ; CHECK-NEXT: lui a0, 307200
163 ; CHECK-NEXT: fmv.w.x fa5, a0
164 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
165 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
166 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
167 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
168 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
169 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
171 %a = call <2 x float> @llvm.experimental.constrained.trunc.v2f32(<2 x float> %x, metadata !"fpexcept.strict")
174 declare <2 x float> @llvm.experimental.constrained.trunc.v2f32(<2 x float>, metadata)
176 define <4 x float> @trunc_v4f32(<4 x float> %x) strictfp {
177 ; CHECK-LABEL: trunc_v4f32:
179 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, mu
180 ; CHECK-NEXT: vmfne.vv v0, v8, v8
181 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
182 ; CHECK-NEXT: vfabs.v v9, v8
183 ; CHECK-NEXT: lui a0, 307200
184 ; CHECK-NEXT: fmv.w.x fa5, a0
185 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
186 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
187 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
188 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
189 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu
190 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
192 %a = call <4 x float> @llvm.experimental.constrained.trunc.v4f32(<4 x float> %x, metadata !"fpexcept.strict")
195 declare <4 x float> @llvm.experimental.constrained.trunc.v4f32(<4 x float>, metadata)
197 define <8 x float> @trunc_v8f32(<8 x float> %x) strictfp {
198 ; CHECK-LABEL: trunc_v8f32:
200 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, mu
201 ; CHECK-NEXT: vmfne.vv v0, v8, v8
202 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
203 ; CHECK-NEXT: vfabs.v v10, v8
204 ; CHECK-NEXT: lui a0, 307200
205 ; CHECK-NEXT: fmv.w.x fa5, a0
206 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
207 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
208 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
209 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
210 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu
211 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
213 %a = call <8 x float> @llvm.experimental.constrained.trunc.v8f32(<8 x float> %x, metadata !"fpexcept.strict")
216 declare <8 x float> @llvm.experimental.constrained.trunc.v8f32(<8 x float>, metadata)
218 define <16 x float> @trunc_v16f32(<16 x float> %x) strictfp {
219 ; CHECK-LABEL: trunc_v16f32:
221 ; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, mu
222 ; CHECK-NEXT: vmfne.vv v0, v8, v8
223 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
224 ; CHECK-NEXT: vfabs.v v12, v8
225 ; CHECK-NEXT: lui a0, 307200
226 ; CHECK-NEXT: fmv.w.x fa5, a0
227 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
228 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
229 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
230 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
231 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu
232 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
234 %a = call <16 x float> @llvm.experimental.constrained.trunc.v16f32(<16 x float> %x, metadata !"fpexcept.strict")
237 declare <16 x float> @llvm.experimental.constrained.trunc.v16f32(<16 x float>, metadata)
239 define <1 x double> @trunc_v1f64(<1 x double> %x) strictfp {
240 ; CHECK-LABEL: trunc_v1f64:
242 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, mu
243 ; CHECK-NEXT: vmfne.vv v0, v8, v8
244 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
245 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
246 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
247 ; CHECK-NEXT: vfabs.v v9, v8
248 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
249 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
250 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
251 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
252 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
253 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
255 %a = call <1 x double> @llvm.experimental.constrained.trunc.v1f64(<1 x double> %x, metadata !"fpexcept.strict")
258 declare <1 x double> @llvm.experimental.constrained.trunc.v1f64(<1 x double>, metadata)
260 define <2 x double> @trunc_v2f64(<2 x double> %x) strictfp {
261 ; CHECK-LABEL: trunc_v2f64:
263 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, mu
264 ; CHECK-NEXT: vmfne.vv v0, v8, v8
265 ; CHECK-NEXT: lui a0, %hi(.LCPI12_0)
266 ; CHECK-NEXT: fld fa5, %lo(.LCPI12_0)(a0)
267 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
268 ; CHECK-NEXT: vfabs.v v9, v8
269 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
270 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
271 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
272 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
273 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
274 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
276 %a = call <2 x double> @llvm.experimental.constrained.trunc.v2f64(<2 x double> %x, metadata !"fpexcept.strict")
279 declare <2 x double> @llvm.experimental.constrained.trunc.v2f64(<2 x double>, metadata)
281 define <4 x double> @trunc_v4f64(<4 x double> %x) strictfp {
282 ; CHECK-LABEL: trunc_v4f64:
284 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, mu
285 ; CHECK-NEXT: vmfne.vv v0, v8, v8
286 ; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
287 ; CHECK-NEXT: fld fa5, %lo(.LCPI13_0)(a0)
288 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
289 ; CHECK-NEXT: vfabs.v v10, v8
290 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
291 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
292 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
293 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
294 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
295 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
297 %a = call <4 x double> @llvm.experimental.constrained.trunc.v4f64(<4 x double> %x, metadata !"fpexcept.strict")
300 declare <4 x double> @llvm.experimental.constrained.trunc.v4f64(<4 x double>, metadata)
302 define <8 x double> @trunc_v8f64(<8 x double> %x) strictfp {
303 ; CHECK-LABEL: trunc_v8f64:
305 ; CHECK-NEXT: vsetivli zero, 8, e64, m4, ta, mu
306 ; CHECK-NEXT: vmfne.vv v0, v8, v8
307 ; CHECK-NEXT: lui a0, %hi(.LCPI14_0)
308 ; CHECK-NEXT: fld fa5, %lo(.LCPI14_0)(a0)
309 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
310 ; CHECK-NEXT: vfabs.v v12, v8
311 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
312 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
313 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
314 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
315 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu
316 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
318 %a = call <8 x double> @llvm.experimental.constrained.trunc.v8f64(<8 x double> %x, metadata !"fpexcept.strict")
321 declare <8 x double> @llvm.experimental.constrained.trunc.v8f64(<8 x double>, metadata)