1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
6 define <vscale x 8 x float> @fcvts_nxv8f16(<vscale x 8 x half> %a) {
7 ; CHECK-LABEL: fcvts_nxv8f16:
9 ; CHECK-NEXT: uunpklo z1.s, z0.h
10 ; CHECK-NEXT: ptrue p0.s
11 ; CHECK-NEXT: uunpkhi z2.s, z0.h
12 ; CHECK-NEXT: movprfx z0, z1
13 ; CHECK-NEXT: fcvt z0.s, p0/m, z1.h
14 ; CHECK-NEXT: movprfx z1, z2
15 ; CHECK-NEXT: fcvt z1.s, p0/m, z2.h
17 %res = fpext <vscale x 8 x half> %a to <vscale x 8 x float>
18 ret <vscale x 8 x float> %res
21 define <vscale x 4 x double> @fcvtd_nxv4f16(<vscale x 4 x half> %a) {
22 ; CHECK-LABEL: fcvtd_nxv4f16:
24 ; CHECK-NEXT: uunpklo z1.d, z0.s
25 ; CHECK-NEXT: ptrue p0.d
26 ; CHECK-NEXT: uunpkhi z2.d, z0.s
27 ; CHECK-NEXT: movprfx z0, z1
28 ; CHECK-NEXT: fcvt z0.d, p0/m, z1.h
29 ; CHECK-NEXT: movprfx z1, z2
30 ; CHECK-NEXT: fcvt z1.d, p0/m, z2.h
32 %res = fpext <vscale x 4 x half> %a to <vscale x 4 x double>
33 ret <vscale x 4 x double> %res
36 define <vscale x 8 x double> @fcvtd_nxv8f16(<vscale x 8 x half> %a) {
37 ; CHECK-LABEL: fcvtd_nxv8f16:
39 ; CHECK-NEXT: uunpklo z1.s, z0.h
40 ; CHECK-NEXT: ptrue p0.d
41 ; CHECK-NEXT: uunpkhi z0.s, z0.h
42 ; CHECK-NEXT: uunpklo z2.d, z1.s
43 ; CHECK-NEXT: uunpkhi z1.d, z1.s
44 ; CHECK-NEXT: uunpklo z3.d, z0.s
45 ; CHECK-NEXT: uunpkhi z4.d, z0.s
46 ; CHECK-NEXT: movprfx z0, z2
47 ; CHECK-NEXT: fcvt z0.d, p0/m, z2.h
48 ; CHECK-NEXT: movprfx z2, z3
49 ; CHECK-NEXT: fcvt z2.d, p0/m, z3.h
50 ; CHECK-NEXT: movprfx z3, z4
51 ; CHECK-NEXT: fcvt z3.d, p0/m, z4.h
52 ; CHECK-NEXT: fcvt z1.d, p0/m, z1.h
54 %res = fpext <vscale x 8 x half> %a to <vscale x 8 x double>
55 ret <vscale x 8 x double> %res
58 define <vscale x 4 x double> @fcvtd_nxv4f32(<vscale x 4 x float> %a) {
59 ; CHECK-LABEL: fcvtd_nxv4f32:
61 ; CHECK-NEXT: uunpklo z1.d, z0.s
62 ; CHECK-NEXT: ptrue p0.d
63 ; CHECK-NEXT: uunpkhi z2.d, z0.s
64 ; CHECK-NEXT: movprfx z0, z1
65 ; CHECK-NEXT: fcvt z0.d, p0/m, z1.s
66 ; CHECK-NEXT: movprfx z1, z2
67 ; CHECK-NEXT: fcvt z1.d, p0/m, z2.s
69 %res = fpext <vscale x 4 x float> %a to <vscale x 4 x double>
70 ret <vscale x 4 x double> %res
73 define <vscale x 8 x double> @fcvtd_nxv8f32(<vscale x 8 x float> %a) {
74 ; CHECK-LABEL: fcvtd_nxv8f32:
76 ; CHECK-NEXT: uunpklo z2.d, z0.s
77 ; CHECK-NEXT: uunpkhi z3.d, z0.s
78 ; CHECK-NEXT: ptrue p0.d
79 ; CHECK-NEXT: uunpklo z4.d, z1.s
80 ; CHECK-NEXT: movprfx z0, z2
81 ; CHECK-NEXT: fcvt z0.d, p0/m, z2.s
82 ; CHECK-NEXT: movprfx z2, z4
83 ; CHECK-NEXT: fcvt z2.d, p0/m, z4.s
84 ; CHECK-NEXT: uunpkhi z5.d, z1.s
85 ; CHECK-NEXT: movprfx z1, z3
86 ; CHECK-NEXT: fcvt z1.d, p0/m, z3.s
87 ; CHECK-NEXT: movprfx z3, z5
88 ; CHECK-NEXT: fcvt z3.d, p0/m, z5.s
90 %res = fpext <vscale x 8 x float> %a to <vscale x 8 x double>
91 ret <vscale x 8 x double> %res
96 define <vscale x 8 x half> @fcvth_nxv8f32(<vscale x 8 x float> %a) {
97 ; CHECK-LABEL: fcvth_nxv8f32:
99 ; CHECK-NEXT: ptrue p0.s
100 ; CHECK-NEXT: fcvt z1.h, p0/m, z1.s
101 ; CHECK-NEXT: fcvt z0.h, p0/m, z0.s
102 ; CHECK-NEXT: uzp1 z0.h, z0.h, z1.h
104 %res = fptrunc <vscale x 8 x float> %a to <vscale x 8 x half>
105 ret <vscale x 8 x half> %res
108 define <vscale x 8 x half> @fcvth_nxv8f64(<vscale x 8 x double> %a) {
109 ; CHECK-LABEL: fcvth_nxv8f64:
111 ; CHECK-NEXT: ptrue p0.d
112 ; CHECK-NEXT: fcvt z3.h, p0/m, z3.d
113 ; CHECK-NEXT: fcvt z2.h, p0/m, z2.d
114 ; CHECK-NEXT: fcvt z1.h, p0/m, z1.d
115 ; CHECK-NEXT: fcvt z0.h, p0/m, z0.d
116 ; CHECK-NEXT: uzp1 z2.s, z2.s, z3.s
117 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
118 ; CHECK-NEXT: uzp1 z0.h, z0.h, z2.h
120 %res = fptrunc <vscale x 8 x double> %a to <vscale x 8 x half>
121 ret <vscale x 8 x half> %res
124 define <vscale x 4 x half> @fcvth_nxv4f64(<vscale x 4 x double> %a) {
125 ; CHECK-LABEL: fcvth_nxv4f64:
127 ; CHECK-NEXT: ptrue p0.d
128 ; CHECK-NEXT: fcvt z1.h, p0/m, z1.d
129 ; CHECK-NEXT: fcvt z0.h, p0/m, z0.d
130 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
132 %res = fptrunc <vscale x 4 x double> %a to <vscale x 4 x half>
133 ret <vscale x 4 x half> %res
136 define <vscale x 4 x float> @fcvts_nxv4f64(<vscale x 4 x double> %a) {
137 ; CHECK-LABEL: fcvts_nxv4f64:
139 ; CHECK-NEXT: ptrue p0.d
140 ; CHECK-NEXT: fcvt z1.s, p0/m, z1.d
141 ; CHECK-NEXT: fcvt z0.s, p0/m, z0.d
142 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
144 %res = fptrunc <vscale x 4 x double> %a to <vscale x 4 x float>
145 ret <vscale x 4 x float> %res
148 define <vscale x 8 x float> @fcvts_nxv8f64(<vscale x 8 x double> %a) {
149 ; CHECK-LABEL: fcvts_nxv8f64:
151 ; CHECK-NEXT: ptrue p0.d
152 ; CHECK-NEXT: fcvt z1.s, p0/m, z1.d
153 ; CHECK-NEXT: fcvt z0.s, p0/m, z0.d
154 ; CHECK-NEXT: fcvt z3.s, p0/m, z3.d
155 ; CHECK-NEXT: fcvt z2.s, p0/m, z2.d
156 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
157 ; CHECK-NEXT: uzp1 z1.s, z2.s, z3.s
159 %res = fptrunc <vscale x 8 x double> %a to <vscale x 8 x float>
160 ret <vscale x 8 x float> %res
166 define <vscale x 4 x i32> @fcvtzs_s_nxv4f64(<vscale x 4 x double> %a) {
167 ; CHECK-LABEL: fcvtzs_s_nxv4f64:
169 ; CHECK-NEXT: ptrue p0.d
170 ; CHECK-NEXT: fcvtzs z1.d, p0/m, z1.d
171 ; CHECK-NEXT: fcvtzs z0.d, p0/m, z0.d
172 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
174 %res = fptosi <vscale x 4 x double> %a to <vscale x 4 x i32>
175 ret <vscale x 4 x i32> %res
178 define <vscale x 8 x i16> @fcvtzs_h_nxv8f64(<vscale x 8 x double> %a) {
179 ; CHECK-LABEL: fcvtzs_h_nxv8f64:
181 ; CHECK-NEXT: ptrue p0.d
182 ; CHECK-NEXT: fcvtzs z3.d, p0/m, z3.d
183 ; CHECK-NEXT: fcvtzs z2.d, p0/m, z2.d
184 ; CHECK-NEXT: fcvtzs z1.d, p0/m, z1.d
185 ; CHECK-NEXT: fcvtzs z0.d, p0/m, z0.d
186 ; CHECK-NEXT: uzp1 z2.s, z2.s, z3.s
187 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
188 ; CHECK-NEXT: uzp1 z0.h, z0.h, z2.h
190 %res = fptosi <vscale x 8 x double> %a to <vscale x 8 x i16>
191 ret <vscale x 8 x i16> %res
195 define <vscale x 4 x i64> @fcvtzs_d_nxv4f32(<vscale x 4 x float> %a) {
196 ; CHECK-LABEL: fcvtzs_d_nxv4f32:
198 ; CHECK-NEXT: uunpklo z1.d, z0.s
199 ; CHECK-NEXT: ptrue p0.d
200 ; CHECK-NEXT: uunpkhi z2.d, z0.s
201 ; CHECK-NEXT: movprfx z0, z1
202 ; CHECK-NEXT: fcvtzs z0.d, p0/m, z1.s
203 ; CHECK-NEXT: movprfx z1, z2
204 ; CHECK-NEXT: fcvtzs z1.d, p0/m, z2.s
206 %res = fptosi <vscale x 4 x float> %a to <vscale x 4 x i64>
207 ret <vscale x 4 x i64> %res
210 define <vscale x 16 x i32> @fcvtzs_s_nxv16f16(<vscale x 16 x half> %a) {
211 ; CHECK-LABEL: fcvtzs_s_nxv16f16:
213 ; CHECK-NEXT: uunpklo z2.s, z0.h
214 ; CHECK-NEXT: uunpkhi z3.s, z0.h
215 ; CHECK-NEXT: ptrue p0.s
216 ; CHECK-NEXT: uunpklo z4.s, z1.h
217 ; CHECK-NEXT: movprfx z0, z2
218 ; CHECK-NEXT: fcvtzs z0.s, p0/m, z2.h
219 ; CHECK-NEXT: movprfx z2, z4
220 ; CHECK-NEXT: fcvtzs z2.s, p0/m, z4.h
221 ; CHECK-NEXT: uunpkhi z5.s, z1.h
222 ; CHECK-NEXT: movprfx z1, z3
223 ; CHECK-NEXT: fcvtzs z1.s, p0/m, z3.h
224 ; CHECK-NEXT: movprfx z3, z5
225 ; CHECK-NEXT: fcvtzs z3.s, p0/m, z5.h
227 %res = fptosi <vscale x 16 x half> %a to <vscale x 16 x i32>
228 ret <vscale x 16 x i32> %res
234 define <vscale x 4 x i32> @fcvtzu_s_nxv4f64(<vscale x 4 x double> %a) {
235 ; CHECK-LABEL: fcvtzu_s_nxv4f64:
237 ; CHECK-NEXT: ptrue p0.d
238 ; CHECK-NEXT: fcvtzs z1.d, p0/m, z1.d
239 ; CHECK-NEXT: fcvtzs z0.d, p0/m, z0.d
240 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
242 %res = fptoui <vscale x 4 x double> %a to <vscale x 4 x i32>
243 ret <vscale x 4 x i32> %res
247 define <vscale x 4 x i64> @fcvtzu_d_nxv4f32(<vscale x 4 x float> %a) {
248 ; CHECK-LABEL: fcvtzu_d_nxv4f32:
250 ; CHECK-NEXT: uunpklo z1.d, z0.s
251 ; CHECK-NEXT: ptrue p0.d
252 ; CHECK-NEXT: uunpkhi z2.d, z0.s
253 ; CHECK-NEXT: movprfx z0, z1
254 ; CHECK-NEXT: fcvtzu z0.d, p0/m, z1.s
255 ; CHECK-NEXT: movprfx z1, z2
256 ; CHECK-NEXT: fcvtzu z1.d, p0/m, z2.s
258 %res = fptoui <vscale x 4 x float> %a to <vscale x 4 x i64>
259 ret <vscale x 4 x i64> %res
265 define <vscale x 4 x float> @scvtf_s_nxv4i64(<vscale x 4 x i64> %a) {
266 ; CHECK-LABEL: scvtf_s_nxv4i64:
268 ; CHECK-NEXT: ptrue p0.d
269 ; CHECK-NEXT: scvtf z1.s, p0/m, z1.d
270 ; CHECK-NEXT: scvtf z0.s, p0/m, z0.d
271 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
273 %res = sitofp <vscale x 4 x i64> %a to <vscale x 4 x float>
274 ret <vscale x 4 x float> %res
277 define <vscale x 8 x half> @scvtf_h_nxv8i64(<vscale x 8 x i64> %a) {
278 ; CHECK-LABEL: scvtf_h_nxv8i64:
280 ; CHECK-NEXT: ptrue p0.d
281 ; CHECK-NEXT: scvtf z3.h, p0/m, z3.d
282 ; CHECK-NEXT: scvtf z2.h, p0/m, z2.d
283 ; CHECK-NEXT: scvtf z1.h, p0/m, z1.d
284 ; CHECK-NEXT: scvtf z0.h, p0/m, z0.d
285 ; CHECK-NEXT: uzp1 z2.s, z2.s, z3.s
286 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
287 ; CHECK-NEXT: uzp1 z0.h, z0.h, z2.h
289 %res = sitofp <vscale x 8 x i64> %a to <vscale x 8 x half>
290 ret <vscale x 8 x half> %res
294 define <vscale x 16 x float> @scvtf_s_nxv16i8(<vscale x 16 x i8> %a) {
295 ; CHECK-LABEL: scvtf_s_nxv16i8:
297 ; CHECK-NEXT: sunpklo z1.h, z0.b
298 ; CHECK-NEXT: ptrue p0.s
299 ; CHECK-NEXT: sunpkhi z0.h, z0.b
300 ; CHECK-NEXT: sunpklo z2.s, z1.h
301 ; CHECK-NEXT: sunpkhi z1.s, z1.h
302 ; CHECK-NEXT: sunpklo z3.s, z0.h
303 ; CHECK-NEXT: sunpkhi z4.s, z0.h
304 ; CHECK-NEXT: movprfx z0, z2
305 ; CHECK-NEXT: scvtf z0.s, p0/m, z2.s
306 ; CHECK-NEXT: movprfx z2, z3
307 ; CHECK-NEXT: scvtf z2.s, p0/m, z3.s
308 ; CHECK-NEXT: movprfx z3, z4
309 ; CHECK-NEXT: scvtf z3.s, p0/m, z4.s
310 ; CHECK-NEXT: scvtf z1.s, p0/m, z1.s
312 %res = sitofp <vscale x 16 x i8> %a to <vscale x 16 x float>
313 ret <vscale x 16 x float> %res
316 define <vscale x 4 x double> @scvtf_d_nxv4i32(<vscale x 4 x i32> %a) {
317 ; CHECK-LABEL: scvtf_d_nxv4i32:
319 ; CHECK-NEXT: sunpklo z1.d, z0.s
320 ; CHECK-NEXT: ptrue p0.d
321 ; CHECK-NEXT: sunpkhi z2.d, z0.s
322 ; CHECK-NEXT: movprfx z0, z1
323 ; CHECK-NEXT: scvtf z0.d, p0/m, z1.d
324 ; CHECK-NEXT: movprfx z1, z2
325 ; CHECK-NEXT: scvtf z1.d, p0/m, z2.d
327 %res = sitofp <vscale x 4 x i32> %a to <vscale x 4 x double>
328 ret <vscale x 4 x double> %res
331 define <vscale x 4 x double> @scvtf_d_nxv4i1(<vscale x 4 x i1> %a) {
332 ; CHECK-LABEL: scvtf_d_nxv4i1:
334 ; CHECK-NEXT: punpklo p2.h, p0.b
335 ; CHECK-NEXT: punpkhi p0.h, p0.b
336 ; CHECK-NEXT: ptrue p1.d
337 ; CHECK-NEXT: mov z0.d, p2/z, #-1 // =0xffffffffffffffff
338 ; CHECK-NEXT: mov z1.d, p0/z, #-1 // =0xffffffffffffffff
339 ; CHECK-NEXT: scvtf z0.d, p1/m, z0.d
340 ; CHECK-NEXT: scvtf z1.d, p1/m, z1.d
342 %res = sitofp <vscale x 4 x i1> %a to <vscale x 4 x double>
343 ret <vscale x 4 x double> %res
349 define <vscale x 4 x float> @ucvtf_s_nxv4i64(<vscale x 4 x i64> %a) {
350 ; CHECK-LABEL: ucvtf_s_nxv4i64:
352 ; CHECK-NEXT: ptrue p0.d
353 ; CHECK-NEXT: ucvtf z1.s, p0/m, z1.d
354 ; CHECK-NEXT: ucvtf z0.s, p0/m, z0.d
355 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
357 %res = uitofp <vscale x 4 x i64> %a to <vscale x 4 x float>
358 ret <vscale x 4 x float> %res
361 define <vscale x 8 x half> @ucvtf_h_nxv8i64(<vscale x 8 x i64> %a) {
362 ; CHECK-LABEL: ucvtf_h_nxv8i64:
364 ; CHECK-NEXT: ptrue p0.d
365 ; CHECK-NEXT: ucvtf z3.h, p0/m, z3.d
366 ; CHECK-NEXT: ucvtf z2.h, p0/m, z2.d
367 ; CHECK-NEXT: ucvtf z1.h, p0/m, z1.d
368 ; CHECK-NEXT: ucvtf z0.h, p0/m, z0.d
369 ; CHECK-NEXT: uzp1 z2.s, z2.s, z3.s
370 ; CHECK-NEXT: uzp1 z0.s, z0.s, z1.s
371 ; CHECK-NEXT: uzp1 z0.h, z0.h, z2.h
373 %res = uitofp <vscale x 8 x i64> %a to <vscale x 8 x half>
374 ret <vscale x 8 x half> %res
378 define <vscale x 4 x double> @ucvtf_d_nxv4i32(<vscale x 4 x i32> %a) {
379 ; CHECK-LABEL: ucvtf_d_nxv4i32:
381 ; CHECK-NEXT: uunpklo z1.d, z0.s
382 ; CHECK-NEXT: ptrue p0.d
383 ; CHECK-NEXT: uunpkhi z2.d, z0.s
384 ; CHECK-NEXT: movprfx z0, z1
385 ; CHECK-NEXT: ucvtf z0.d, p0/m, z1.d
386 ; CHECK-NEXT: movprfx z1, z2
387 ; CHECK-NEXT: ucvtf z1.d, p0/m, z2.d
389 %res = uitofp <vscale x 4 x i32> %a to <vscale x 4 x double>
390 ret <vscale x 4 x double> %res
393 define <vscale x 4 x double> @ucvtf_d_nxv4i1(<vscale x 4 x i1> %a) {
394 ; CHECK-LABEL: ucvtf_d_nxv4i1:
396 ; CHECK-NEXT: punpklo p2.h, p0.b
397 ; CHECK-NEXT: punpkhi p0.h, p0.b
398 ; CHECK-NEXT: ptrue p1.d
399 ; CHECK-NEXT: mov z0.d, p2/z, #1 // =0x1
400 ; CHECK-NEXT: mov z1.d, p0/z, #1 // =0x1
401 ; CHECK-NEXT: ucvtf z0.d, p1/m, z0.d
402 ; CHECK-NEXT: ucvtf z1.d, p1/m, z1.d
404 %res = uitofp <vscale x 4 x i1> %a to <vscale x 4 x double>
405 ret <vscale x 4 x double> %res