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 <vscale x 1 x half> @trunc_nxv1f16(<vscale x 1 x half> %x) strictfp {
8 ; CHECK-LABEL: trunc_nxv1f16:
10 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
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: vfcvt.rtz.x.f.v v9, v8, v0.t
18 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
19 ; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu
20 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
22 %a = call <vscale x 1 x half> @llvm.experimental.constrained.trunc.nxv1f16(<vscale x 1 x half> %x, metadata !"fpexcept.strict")
23 ret <vscale x 1 x half> %a
25 declare <vscale x 1 x half> @llvm.experimental.constrained.trunc.nxv1f16(<vscale x 1 x half>, metadata)
27 define <vscale x 2 x half> @trunc_nxv2f16(<vscale x 2 x half> %x) strictfp {
28 ; CHECK-LABEL: trunc_nxv2f16:
30 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
31 ; CHECK-NEXT: vmfne.vv v0, v8, v8
32 ; CHECK-NEXT: lui a0, %hi(.LCPI1_0)
33 ; CHECK-NEXT: flh fa5, %lo(.LCPI1_0)(a0)
34 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
35 ; CHECK-NEXT: vfabs.v v9, v8
36 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
37 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
38 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
39 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
40 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
42 %a = call <vscale x 2 x half> @llvm.experimental.constrained.trunc.nxv2f16(<vscale x 2 x half> %x, metadata !"fpexcept.strict")
43 ret <vscale x 2 x half> %a
45 declare <vscale x 2 x half> @llvm.experimental.constrained.trunc.nxv2f16(<vscale x 2 x half>, metadata)
47 define <vscale x 4 x half> @trunc_nxv4f16(<vscale x 4 x half> %x) strictfp {
48 ; CHECK-LABEL: trunc_nxv4f16:
50 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
51 ; CHECK-NEXT: vmfne.vv v0, v8, v8
52 ; CHECK-NEXT: lui a0, %hi(.LCPI2_0)
53 ; CHECK-NEXT: flh fa5, %lo(.LCPI2_0)(a0)
54 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
55 ; CHECK-NEXT: vfabs.v v9, v8
56 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
57 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
58 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
59 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu
60 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
62 %a = call <vscale x 4 x half> @llvm.experimental.constrained.trunc.nxv4f16(<vscale x 4 x half> %x, metadata !"fpexcept.strict")
63 ret <vscale x 4 x half> %a
65 declare <vscale x 4 x half> @llvm.experimental.constrained.trunc.nxv4f16(<vscale x 4 x half>, metadata)
67 define <vscale x 8 x half> @trunc_nxv8f16(<vscale x 8 x half> %x) strictfp {
68 ; CHECK-LABEL: trunc_nxv8f16:
70 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
71 ; CHECK-NEXT: vmfne.vv v0, v8, v8
72 ; CHECK-NEXT: lui a0, %hi(.LCPI3_0)
73 ; CHECK-NEXT: flh fa5, %lo(.LCPI3_0)(a0)
74 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
75 ; CHECK-NEXT: vfabs.v v10, v8
76 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
77 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
78 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
79 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu
80 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
82 %a = call <vscale x 8 x half> @llvm.experimental.constrained.trunc.nxv8f16(<vscale x 8 x half> %x, metadata !"fpexcept.strict")
83 ret <vscale x 8 x half> %a
85 declare <vscale x 8 x half> @llvm.experimental.constrained.trunc.nxv8f16(<vscale x 8 x half>, metadata)
87 define <vscale x 16 x half> @trunc_nxv16f16(<vscale x 16 x half> %x) strictfp {
88 ; CHECK-LABEL: trunc_nxv16f16:
90 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
91 ; CHECK-NEXT: vmfne.vv v0, v8, v8
92 ; CHECK-NEXT: lui a0, %hi(.LCPI4_0)
93 ; CHECK-NEXT: flh fa5, %lo(.LCPI4_0)(a0)
94 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
95 ; CHECK-NEXT: vfabs.v v12, v8
96 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
97 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
98 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
99 ; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu
100 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
102 %a = call <vscale x 16 x half> @llvm.experimental.constrained.trunc.nxv16f16(<vscale x 16 x half> %x, metadata !"fpexcept.strict")
103 ret <vscale x 16 x half> %a
105 declare <vscale x 16 x half> @llvm.experimental.constrained.trunc.nxv16f16(<vscale x 16 x half>, metadata)
107 define <vscale x 32 x half> @trunc_nxv32f16(<vscale x 32 x half> %x) strictfp {
108 ; CHECK-LABEL: trunc_nxv32f16:
110 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
111 ; CHECK-NEXT: vmfne.vv v0, v8, v8
112 ; CHECK-NEXT: lui a0, %hi(.LCPI5_0)
113 ; CHECK-NEXT: flh fa5, %lo(.LCPI5_0)(a0)
114 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
115 ; CHECK-NEXT: vfabs.v v16, v8
116 ; CHECK-NEXT: vmflt.vf v0, v16, fa5
117 ; CHECK-NEXT: vfcvt.rtz.x.f.v v16, v8, v0.t
118 ; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t
119 ; CHECK-NEXT: vsetvli zero, zero, e16, m8, ta, mu
120 ; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t
122 %a = call <vscale x 32 x half> @llvm.experimental.constrained.trunc.nxv32f16(<vscale x 32 x half> %x, metadata !"fpexcept.strict")
123 ret <vscale x 32 x half> %a
125 declare <vscale x 32 x half> @llvm.experimental.constrained.trunc.nxv32f16(<vscale x 32 x half>, metadata)
127 define <vscale x 1 x float> @trunc_nxv1f32(<vscale x 1 x float> %x) strictfp {
128 ; CHECK-LABEL: trunc_nxv1f32:
130 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
131 ; CHECK-NEXT: vmfne.vv v0, v8, v8
132 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
133 ; CHECK-NEXT: vfabs.v v9, v8
134 ; CHECK-NEXT: lui a0, 307200
135 ; CHECK-NEXT: fmv.w.x fa5, a0
136 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
137 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
138 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
139 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu
140 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
142 %a = call <vscale x 1 x float> @llvm.experimental.constrained.trunc.nxv1f32(<vscale x 1 x float> %x, metadata !"fpexcept.strict")
143 ret <vscale x 1 x float> %a
145 declare <vscale x 1 x float> @llvm.experimental.constrained.trunc.nxv1f32(<vscale x 1 x float>, metadata)
147 define <vscale x 2 x float> @trunc_nxv2f32(<vscale x 2 x float> %x) strictfp {
148 ; CHECK-LABEL: trunc_nxv2f32:
150 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
151 ; CHECK-NEXT: vmfne.vv v0, v8, v8
152 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
153 ; CHECK-NEXT: vfabs.v v9, v8
154 ; CHECK-NEXT: lui a0, 307200
155 ; CHECK-NEXT: fmv.w.x fa5, a0
156 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
157 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
158 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
159 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu
160 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
162 %a = call <vscale x 2 x float> @llvm.experimental.constrained.trunc.nxv2f32(<vscale x 2 x float> %x, metadata !"fpexcept.strict")
163 ret <vscale x 2 x float> %a
165 declare <vscale x 2 x float> @llvm.experimental.constrained.trunc.nxv2f32(<vscale x 2 x float>, metadata)
167 define <vscale x 4 x float> @trunc_nxv4f32(<vscale x 4 x float> %x) strictfp {
168 ; CHECK-LABEL: trunc_nxv4f32:
170 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
171 ; CHECK-NEXT: vmfne.vv v0, v8, v8
172 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
173 ; CHECK-NEXT: vfabs.v v10, v8
174 ; CHECK-NEXT: lui a0, 307200
175 ; CHECK-NEXT: fmv.w.x fa5, a0
176 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
177 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
178 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
179 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu
180 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
182 %a = call <vscale x 4 x float> @llvm.experimental.constrained.trunc.nxv4f32(<vscale x 4 x float> %x, metadata !"fpexcept.strict")
183 ret <vscale x 4 x float> %a
185 declare <vscale x 4 x float> @llvm.experimental.constrained.trunc.nxv4f32(<vscale x 4 x float>, metadata)
187 define <vscale x 8 x float> @trunc_nxv8f32(<vscale x 8 x float> %x) strictfp {
188 ; CHECK-LABEL: trunc_nxv8f32:
190 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
191 ; CHECK-NEXT: vmfne.vv v0, v8, v8
192 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
193 ; CHECK-NEXT: vfabs.v v12, v8
194 ; CHECK-NEXT: lui a0, 307200
195 ; CHECK-NEXT: fmv.w.x fa5, a0
196 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
197 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
198 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
199 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu
200 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
202 %a = call <vscale x 8 x float> @llvm.experimental.constrained.trunc.nxv8f32(<vscale x 8 x float> %x, metadata !"fpexcept.strict")
203 ret <vscale x 8 x float> %a
205 declare <vscale x 8 x float> @llvm.experimental.constrained.trunc.nxv8f32(<vscale x 8 x float>, metadata)
207 define <vscale x 16 x float> @trunc_nxv16f32(<vscale x 16 x float> %x) strictfp {
208 ; CHECK-LABEL: trunc_nxv16f32:
210 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
211 ; CHECK-NEXT: vmfne.vv v0, v8, v8
212 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
213 ; CHECK-NEXT: vfabs.v v16, v8
214 ; CHECK-NEXT: lui a0, 307200
215 ; CHECK-NEXT: fmv.w.x fa5, a0
216 ; CHECK-NEXT: vmflt.vf v0, v16, fa5
217 ; CHECK-NEXT: vfcvt.rtz.x.f.v v16, v8, v0.t
218 ; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t
219 ; CHECK-NEXT: vsetvli zero, zero, e32, m8, ta, mu
220 ; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t
222 %a = call <vscale x 16 x float> @llvm.experimental.constrained.trunc.nxv16f32(<vscale x 16 x float> %x, metadata !"fpexcept.strict")
223 ret <vscale x 16 x float> %a
225 declare <vscale x 16 x float> @llvm.experimental.constrained.trunc.nxv16f32(<vscale x 16 x float>, metadata)
227 define <vscale x 1 x double> @trunc_nxv1f64(<vscale x 1 x double> %x) strictfp {
228 ; CHECK-LABEL: trunc_nxv1f64:
230 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
231 ; CHECK-NEXT: vmfne.vv v0, v8, v8
232 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
233 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
234 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
235 ; CHECK-NEXT: vfabs.v v9, v8
236 ; CHECK-NEXT: vmflt.vf v0, v9, fa5
237 ; CHECK-NEXT: vfcvt.rtz.x.f.v v9, v8, v0.t
238 ; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t
239 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu
240 ; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t
242 %a = call <vscale x 1 x double> @llvm.experimental.constrained.trunc.nxv1f64(<vscale x 1 x double> %x, metadata !"fpexcept.strict")
243 ret <vscale x 1 x double> %a
245 declare <vscale x 1 x double> @llvm.experimental.constrained.trunc.nxv1f64(<vscale x 1 x double>, metadata)
247 define <vscale x 2 x double> @trunc_nxv2f64(<vscale x 2 x double> %x) strictfp {
248 ; CHECK-LABEL: trunc_nxv2f64:
250 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
251 ; CHECK-NEXT: vmfne.vv v0, v8, v8
252 ; CHECK-NEXT: lui a0, %hi(.LCPI12_0)
253 ; CHECK-NEXT: fld fa5, %lo(.LCPI12_0)(a0)
254 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
255 ; CHECK-NEXT: vfabs.v v10, v8
256 ; CHECK-NEXT: vmflt.vf v0, v10, fa5
257 ; CHECK-NEXT: vfcvt.rtz.x.f.v v10, v8, v0.t
258 ; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t
259 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu
260 ; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t
262 %a = call <vscale x 2 x double> @llvm.experimental.constrained.trunc.nxv2f64(<vscale x 2 x double> %x, metadata !"fpexcept.strict")
263 ret <vscale x 2 x double> %a
265 declare <vscale x 2 x double> @llvm.experimental.constrained.trunc.nxv2f64(<vscale x 2 x double>, metadata)
267 define <vscale x 4 x double> @trunc_nxv4f64(<vscale x 4 x double> %x) strictfp {
268 ; CHECK-LABEL: trunc_nxv4f64:
270 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
271 ; CHECK-NEXT: vmfne.vv v0, v8, v8
272 ; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
273 ; CHECK-NEXT: fld fa5, %lo(.LCPI13_0)(a0)
274 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
275 ; CHECK-NEXT: vfabs.v v12, v8
276 ; CHECK-NEXT: vmflt.vf v0, v12, fa5
277 ; CHECK-NEXT: vfcvt.rtz.x.f.v v12, v8, v0.t
278 ; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t
279 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu
280 ; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t
282 %a = call <vscale x 4 x double> @llvm.experimental.constrained.trunc.nxv4f64(<vscale x 4 x double> %x, metadata !"fpexcept.strict")
283 ret <vscale x 4 x double> %a
285 declare <vscale x 4 x double> @llvm.experimental.constrained.trunc.nxv4f64(<vscale x 4 x double>, metadata)
287 define <vscale x 8 x double> @trunc_nxv8f64(<vscale x 8 x double> %x) strictfp {
288 ; CHECK-LABEL: trunc_nxv8f64:
290 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
291 ; CHECK-NEXT: vmfne.vv v0, v8, v8
292 ; CHECK-NEXT: lui a0, %hi(.LCPI14_0)
293 ; CHECK-NEXT: fld fa5, %lo(.LCPI14_0)(a0)
294 ; CHECK-NEXT: vfadd.vv v8, v8, v8, v0.t
295 ; CHECK-NEXT: vfabs.v v16, v8
296 ; CHECK-NEXT: vmflt.vf v0, v16, fa5
297 ; CHECK-NEXT: vfcvt.rtz.x.f.v v16, v8, v0.t
298 ; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t
299 ; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu
300 ; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t
302 %a = call <vscale x 8 x double> @llvm.experimental.constrained.trunc.nxv8f64(<vscale x 8 x double> %x, metadata !"fpexcept.strict")
303 ret <vscale x 8 x double> %a
305 declare <vscale x 8 x double> @llvm.experimental.constrained.trunc.nxv8f64(<vscale x 8 x double>, metadata)