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
3 ; RUN: not --crash llc -mtriple=aarch64_be -mattr=+sve < %s
5 define <vscale x 16 x i8> @bitcast_i16_to_i8(<vscale x 8 x i16> %v) {
6 ; CHECK-LABEL: bitcast_i16_to_i8:
9 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 16 x i8>
10 ret <vscale x 16 x i8> %bc
13 define <vscale x 16 x i8> @bitcast_i32_to_i8(<vscale x 4 x i32> %v) {
14 ; CHECK-LABEL: bitcast_i32_to_i8:
17 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 16 x i8>
18 ret <vscale x 16 x i8> %bc
21 define <vscale x 16 x i8> @bitcast_i64_to_i8(<vscale x 2 x i64> %v) {
22 ; CHECK-LABEL: bitcast_i64_to_i8:
25 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 16 x i8>
26 ret <vscale x 16 x i8> %bc
29 define <vscale x 16 x i8> @bitcast_half_to_i8(<vscale x 8 x half> %v) {
30 ; CHECK-LABEL: bitcast_half_to_i8:
33 %bc = bitcast <vscale x 8 x half> %v to <vscale x 16 x i8>
34 ret <vscale x 16 x i8> %bc
37 define <vscale x 16 x i8> @bitcast_float_to_i8(<vscale x 4 x float> %v) {
38 ; CHECK-LABEL: bitcast_float_to_i8:
41 %bc = bitcast <vscale x 4 x float> %v to <vscale x 16 x i8>
42 ret <vscale x 16 x i8> %bc
45 define <vscale x 16 x i8> @bitcast_double_to_i8(<vscale x 2 x double> %v) {
46 ; CHECK-LABEL: bitcast_double_to_i8:
49 %bc = bitcast <vscale x 2 x double> %v to <vscale x 16 x i8>
50 ret <vscale x 16 x i8> %bc
53 define <vscale x 8 x i16> @bitcast_i8_to_i16(<vscale x 16 x i8> %v) {
54 ; CHECK-LABEL: bitcast_i8_to_i16:
57 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 8 x i16>
58 ret <vscale x 8 x i16> %bc
61 define <vscale x 8 x i16> @bitcast_i32_to_i16(<vscale x 4 x i32> %v) {
62 ; CHECK-LABEL: bitcast_i32_to_i16:
65 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 8 x i16>
66 ret <vscale x 8 x i16> %bc
69 define <vscale x 8 x i16> @bitcast_i64_to_i16(<vscale x 2 x i64> %v) {
70 ; CHECK-LABEL: bitcast_i64_to_i16:
73 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 8 x i16>
74 ret <vscale x 8 x i16> %bc
77 define <vscale x 8 x i16> @bitcast_half_to_i16(<vscale x 8 x half> %v) {
78 ; CHECK-LABEL: bitcast_half_to_i16:
81 %bc = bitcast <vscale x 8 x half> %v to <vscale x 8 x i16>
82 ret <vscale x 8 x i16> %bc
85 define <vscale x 8 x i16> @bitcast_float_to_i16(<vscale x 4 x float> %v) {
86 ; CHECK-LABEL: bitcast_float_to_i16:
89 %bc = bitcast <vscale x 4 x float> %v to <vscale x 8 x i16>
90 ret <vscale x 8 x i16> %bc
93 define <vscale x 8 x i16> @bitcast_double_to_i16(<vscale x 2 x double> %v) {
94 ; CHECK-LABEL: bitcast_double_to_i16:
97 %bc = bitcast <vscale x 2 x double> %v to <vscale x 8 x i16>
98 ret <vscale x 8 x i16> %bc
101 define <vscale x 4 x i32> @bitcast_i8_to_i32(<vscale x 16 x i8> %v) {
102 ; CHECK-LABEL: bitcast_i8_to_i32:
105 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 4 x i32>
106 ret <vscale x 4 x i32> %bc
109 define <vscale x 4 x i32> @bitcast_i16_to_i32(<vscale x 8 x i16> %v) {
110 ; CHECK-LABEL: bitcast_i16_to_i32:
113 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 4 x i32>
114 ret <vscale x 4 x i32> %bc
117 define <vscale x 4 x i32> @bitcast_i64_to_i32(<vscale x 2 x i64> %v) {
118 ; CHECK-LABEL: bitcast_i64_to_i32:
121 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 4 x i32>
122 ret <vscale x 4 x i32> %bc
125 define <vscale x 4 x i32> @bitcast_half_to_i32(<vscale x 8 x half> %v) {
126 ; CHECK-LABEL: bitcast_half_to_i32:
129 %bc = bitcast <vscale x 8 x half> %v to <vscale x 4 x i32>
130 ret <vscale x 4 x i32> %bc
133 define <vscale x 4 x i32> @bitcast_float_to_i32(<vscale x 4 x float> %v) {
134 ; CHECK-LABEL: bitcast_float_to_i32:
137 %bc = bitcast <vscale x 4 x float> %v to <vscale x 4 x i32>
138 ret <vscale x 4 x i32> %bc
141 define <vscale x 4 x i32> @bitcast_double_to_i32(<vscale x 2 x double> %v) {
142 ; CHECK-LABEL: bitcast_double_to_i32:
145 %bc = bitcast <vscale x 2 x double> %v to <vscale x 4 x i32>
146 ret <vscale x 4 x i32> %bc
149 define <vscale x 2 x i64> @bitcast_i8_to_i64(<vscale x 16 x i8> %v) {
150 ; CHECK-LABEL: bitcast_i8_to_i64:
153 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 2 x i64>
154 ret <vscale x 2 x i64> %bc
157 define <vscale x 2 x i64> @bitcast_i16_to_i64(<vscale x 8 x i16> %v) {
158 ; CHECK-LABEL: bitcast_i16_to_i64:
161 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 2 x i64>
162 ret <vscale x 2 x i64> %bc
165 define <vscale x 2 x i64> @bitcast_i32_to_i64(<vscale x 4 x i32> %v) {
166 ; CHECK-LABEL: bitcast_i32_to_i64:
169 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 2 x i64>
170 ret <vscale x 2 x i64> %bc
173 define <vscale x 2 x i64> @bitcast_half_to_i64(<vscale x 8 x half> %v) {
174 ; CHECK-LABEL: bitcast_half_to_i64:
177 %bc = bitcast <vscale x 8 x half> %v to <vscale x 2 x i64>
178 ret <vscale x 2 x i64> %bc
181 define <vscale x 2 x i64> @bitcast_float_to_i64(<vscale x 4 x float> %v) {
182 ; CHECK-LABEL: bitcast_float_to_i64:
185 %bc = bitcast <vscale x 4 x float> %v to <vscale x 2 x i64>
186 ret <vscale x 2 x i64> %bc
189 define <vscale x 2 x i64> @bitcast_double_to_i64(<vscale x 2 x double> %v) {
190 ; CHECK-LABEL: bitcast_double_to_i64:
193 %bc = bitcast <vscale x 2 x double> %v to <vscale x 2 x i64>
194 ret <vscale x 2 x i64> %bc
197 define <vscale x 8 x half> @bitcast_i8_to_half(<vscale x 16 x i8> %v) {
198 ; CHECK-LABEL: bitcast_i8_to_half:
201 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 8 x half>
202 ret <vscale x 8 x half> %bc
205 define <vscale x 8 x half> @bitcast_i16_to_half(<vscale x 8 x i16> %v) {
206 ; CHECK-LABEL: bitcast_i16_to_half:
209 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 8 x half>
210 ret <vscale x 8 x half> %bc
213 define <vscale x 8 x half> @bitcast_i32_to_half(<vscale x 4 x i32> %v) {
214 ; CHECK-LABEL: bitcast_i32_to_half:
217 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 8 x half>
218 ret <vscale x 8 x half> %bc
221 define <vscale x 8 x half> @bitcast_i64_to_half(<vscale x 2 x i64> %v) {
222 ; CHECK-LABEL: bitcast_i64_to_half:
225 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 8 x half>
226 ret <vscale x 8 x half> %bc
229 define <vscale x 8 x half> @bitcast_float_to_half(<vscale x 4 x float> %v) {
230 ; CHECK-LABEL: bitcast_float_to_half:
233 %bc = bitcast <vscale x 4 x float> %v to <vscale x 8 x half>
234 ret <vscale x 8 x half> %bc
237 define <vscale x 8 x half> @bitcast_double_to_half(<vscale x 2 x double> %v) {
238 ; CHECK-LABEL: bitcast_double_to_half:
241 %bc = bitcast <vscale x 2 x double> %v to <vscale x 8 x half>
242 ret <vscale x 8 x half> %bc
245 define <vscale x 4 x float> @bitcast_i8_to_float(<vscale x 16 x i8> %v) {
246 ; CHECK-LABEL: bitcast_i8_to_float:
249 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 4 x float>
250 ret <vscale x 4 x float> %bc
253 define <vscale x 4 x float> @bitcast_i16_to_float(<vscale x 8 x i16> %v) {
254 ; CHECK-LABEL: bitcast_i16_to_float:
257 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 4 x float>
258 ret <vscale x 4 x float> %bc
261 define <vscale x 4 x float> @bitcast_i32_to_float(<vscale x 4 x i32> %v) {
262 ; CHECK-LABEL: bitcast_i32_to_float:
265 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 4 x float>
266 ret <vscale x 4 x float> %bc
269 define <vscale x 4 x float> @bitcast_i64_to_float(<vscale x 2 x i64> %v) {
270 ; CHECK-LABEL: bitcast_i64_to_float:
273 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 4 x float>
274 ret <vscale x 4 x float> %bc
277 define <vscale x 4 x float> @bitcast_half_to_float(<vscale x 8 x half> %v) {
278 ; CHECK-LABEL: bitcast_half_to_float:
281 %bc = bitcast <vscale x 8 x half> %v to <vscale x 4 x float>
282 ret <vscale x 4 x float> %bc
285 define <vscale x 4 x float> @bitcast_double_to_float(<vscale x 2 x double> %v) {
286 ; CHECK-LABEL: bitcast_double_to_float:
289 %bc = bitcast <vscale x 2 x double> %v to <vscale x 4 x float>
290 ret <vscale x 4 x float> %bc
293 define <vscale x 2 x double> @bitcast_i8_to_double(<vscale x 16 x i8> %v) {
294 ; CHECK-LABEL: bitcast_i8_to_double:
297 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 2 x double>
298 ret <vscale x 2 x double> %bc
301 define <vscale x 2 x double> @bitcast_i16_to_double(<vscale x 8 x i16> %v) {
302 ; CHECK-LABEL: bitcast_i16_to_double:
305 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 2 x double>
306 ret <vscale x 2 x double> %bc
309 define <vscale x 2 x double> @bitcast_i32_to_double(<vscale x 4 x i32> %v) {
310 ; CHECK-LABEL: bitcast_i32_to_double:
313 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 2 x double>
314 ret <vscale x 2 x double> %bc
317 define <vscale x 2 x double> @bitcast_i64_to_double(<vscale x 2 x i64> %v) {
318 ; CHECK-LABEL: bitcast_i64_to_double:
321 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 2 x double>
322 ret <vscale x 2 x double> %bc
325 define <vscale x 2 x double> @bitcast_half_to_double(<vscale x 8 x half> %v) {
326 ; CHECK-LABEL: bitcast_half_to_double:
329 %bc = bitcast <vscale x 8 x half> %v to <vscale x 2 x double>
330 ret <vscale x 2 x double> %bc
333 define <vscale x 2 x double> @bitcast_float_to_double(<vscale x 4 x float> %v) {
334 ; CHECK-LABEL: bitcast_float_to_double:
337 %bc = bitcast <vscale x 4 x float> %v to <vscale x 2 x double>
338 ret <vscale x 2 x double> %bc
341 define <vscale x 16 x i8> @bitcast_bfloat_to_i8(<vscale x 8 x bfloat> %v) #0 {
342 ; CHECK-LABEL: bitcast_bfloat_to_i8:
345 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 16 x i8>
346 ret <vscale x 16 x i8> %bc
349 define <vscale x 8 x i16> @bitcast_bfloat_to_i16(<vscale x 8 x bfloat> %v) #0 {
350 ; CHECK-LABEL: bitcast_bfloat_to_i16:
353 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 8 x i16>
354 ret <vscale x 8 x i16> %bc
357 define <vscale x 4 x i32> @bitcast_bfloat_to_i32(<vscale x 8 x bfloat> %v) #0 {
358 ; CHECK-LABEL: bitcast_bfloat_to_i32:
361 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 4 x i32>
362 ret <vscale x 4 x i32> %bc
365 define <vscale x 2 x i64> @bitcast_bfloat_to_i64(<vscale x 8 x bfloat> %v) #0 {
366 ; CHECK-LABEL: bitcast_bfloat_to_i64:
369 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 2 x i64>
370 ret <vscale x 2 x i64> %bc
373 define <vscale x 8 x half> @bitcast_bfloat_to_half(<vscale x 8 x bfloat> %v) #0 {
374 ; CHECK-LABEL: bitcast_bfloat_to_half:
377 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 8 x half>
378 ret <vscale x 8 x half> %bc
381 define <vscale x 4 x float> @bitcast_bfloat_to_float(<vscale x 8 x bfloat> %v) #0 {
382 ; CHECK-LABEL: bitcast_bfloat_to_float:
385 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 4 x float>
386 ret <vscale x 4 x float> %bc
389 define <vscale x 2 x double> @bitcast_bfloat_to_double(<vscale x 8 x bfloat> %v) #0 {
390 ; CHECK-LABEL: bitcast_bfloat_to_double:
393 %bc = bitcast <vscale x 8 x bfloat> %v to <vscale x 2 x double>
394 ret <vscale x 2 x double> %bc
397 define <vscale x 8 x bfloat> @bitcast_i8_to_bfloat(<vscale x 16 x i8> %v) #0 {
398 ; CHECK-LABEL: bitcast_i8_to_bfloat:
401 %bc = bitcast <vscale x 16 x i8> %v to <vscale x 8 x bfloat>
402 ret <vscale x 8 x bfloat> %bc
405 define <vscale x 8 x bfloat> @bitcast_i16_to_bfloat(<vscale x 8 x i16> %v) #0 {
406 ; CHECK-LABEL: bitcast_i16_to_bfloat:
409 %bc = bitcast <vscale x 8 x i16> %v to <vscale x 8 x bfloat>
410 ret <vscale x 8 x bfloat> %bc
413 define <vscale x 8 x bfloat> @bitcast_i32_to_bfloat(<vscale x 4 x i32> %v) #0 {
414 ; CHECK-LABEL: bitcast_i32_to_bfloat:
417 %bc = bitcast <vscale x 4 x i32> %v to <vscale x 8 x bfloat>
418 ret <vscale x 8 x bfloat> %bc
421 define <vscale x 8 x bfloat> @bitcast_i64_to_bfloat(<vscale x 2 x i64> %v) #0 {
422 ; CHECK-LABEL: bitcast_i64_to_bfloat:
425 %bc = bitcast <vscale x 2 x i64> %v to <vscale x 8 x bfloat>
426 ret <vscale x 8 x bfloat> %bc
429 define <vscale x 8 x bfloat> @bitcast_half_to_bfloat(<vscale x 8 x half> %v) #0 {
430 ; CHECK-LABEL: bitcast_half_to_bfloat:
433 %bc = bitcast <vscale x 8 x half> %v to <vscale x 8 x bfloat>
434 ret <vscale x 8 x bfloat> %bc
437 define <vscale x 8 x bfloat> @bitcast_float_to_bfloat(<vscale x 4 x float> %v) #0 {
438 ; CHECK-LABEL: bitcast_float_to_bfloat:
441 %bc = bitcast <vscale x 4 x float> %v to <vscale x 8 x bfloat>
442 ret <vscale x 8 x bfloat> %bc
445 define <vscale x 8 x bfloat> @bitcast_double_to_bfloat(<vscale x 2 x double> %v) #0 {
446 ; CHECK-LABEL: bitcast_double_to_bfloat:
449 %bc = bitcast <vscale x 2 x double> %v to <vscale x 8 x bfloat>
450 ret <vscale x 8 x bfloat> %bc
453 define <vscale x 2 x i16> @bitcast_short2_half_to_i16(<vscale x 2 x half> %v) {
454 ; CHECK-LABEL: bitcast_short2_half_to_i16:
457 %bc = bitcast <vscale x 2 x half> %v to <vscale x 2 x i16>
458 ret <vscale x 2 x i16> %bc
461 define <vscale x 4 x i16> @bitcast_short4_half_to_i16(<vscale x 4 x half> %v) {
462 ; CHECK-LABEL: bitcast_short4_half_to_i16:
465 %bc = bitcast <vscale x 4 x half> %v to <vscale x 4 x i16>
466 ret <vscale x 4 x i16> %bc
469 define <vscale x 2 x i16> @bitcast_short2_bfloat_to_i16(<vscale x 2 x bfloat> %v) #0 {
470 ; CHECK-LABEL: bitcast_short2_bfloat_to_i16:
473 %bc = bitcast <vscale x 2 x bfloat> %v to <vscale x 2 x i16>
474 ret <vscale x 2 x i16> %bc
477 define <vscale x 4 x i16> @bitcast_short4_bfloat_to_i16(<vscale x 4 x bfloat> %v) #0 {
478 ; CHECK-LABEL: bitcast_short4_bfloat_to_i16:
481 %bc = bitcast <vscale x 4 x bfloat> %v to <vscale x 4 x i16>
482 ret <vscale x 4 x i16> %bc
485 define <vscale x 2 x half> @bitcast_short2_i16_to_half(<vscale x 2 x i16> %v) {
486 ; CHECK-LABEL: bitcast_short2_i16_to_half:
489 %bc = bitcast <vscale x 2 x i16> %v to <vscale x 2 x half>
490 ret <vscale x 2 x half> %bc
493 define <vscale x 4 x half> @bitcast_short4_i16_to_half(<vscale x 4 x i16> %v) {
494 ; CHECK-LABEL: bitcast_short4_i16_to_half:
497 %bc = bitcast <vscale x 4 x i16> %v to <vscale x 4 x half>
498 ret <vscale x 4 x half> %bc
501 define <vscale x 2 x bfloat> @bitcast_short2_i16_to_bfloat(<vscale x 2 x i16> %v) #0 {
502 ; CHECK-LABEL: bitcast_short2_i16_to_bfloat:
505 %bc = bitcast <vscale x 2 x i16> %v to <vscale x 2 x bfloat>
506 ret <vscale x 2 x bfloat> %bc
509 define <vscale x 4 x bfloat> @bitcast_short4_i16_to_bfloat(<vscale x 4 x i16> %v) #0 {
510 ; CHECK-LABEL: bitcast_short4_i16_to_bfloat:
513 %bc = bitcast <vscale x 4 x i16> %v to <vscale x 4 x bfloat>
514 ret <vscale x 4 x bfloat> %bc
517 define <vscale x 2 x i32> @bitcast_short_float_to_i32(<vscale x 2 x double> %v) #0 {
518 ; CHECK-LABEL: bitcast_short_float_to_i32:
520 ; CHECK-NEXT: ptrue p0.d
521 ; CHECK-NEXT: fcvt z0.s, p0/m, z0.d
523 %trunc = fptrunc <vscale x 2 x double> %v to <vscale x 2 x float>
524 %bitcast = bitcast <vscale x 2 x float> %trunc to <vscale x 2 x i32>
525 ret <vscale x 2 x i32> %bitcast
528 define <vscale x 2 x double> @bitcast_short_i32_to_float(<vscale x 2 x i64> %v) #0 {
529 ; CHECK-LABEL: bitcast_short_i32_to_float:
531 ; CHECK-NEXT: ptrue p0.d
532 ; CHECK-NEXT: fcvt z0.d, p0/m, z0.s
534 %trunc = trunc <vscale x 2 x i64> %v to <vscale x 2 x i32>
535 %bitcast = bitcast <vscale x 2 x i32> %trunc to <vscale x 2 x float>
536 %extended = fpext <vscale x 2 x float> %bitcast to <vscale x 2 x double>
537 ret <vscale x 2 x double> %extended
540 define <vscale x 2 x float> @bitcast_short_half_to_float(<vscale x 4 x half> %v) #0 {
541 ; CHECK-LABEL: bitcast_short_half_to_float:
543 ; CHECK-NEXT: ptrue p0.s
544 ; CHECK-NEXT: fadd z0.h, p0/m, z0.h, z0.h
546 %add = fadd <vscale x 4 x half> %v, %v
547 %bitcast = bitcast <vscale x 4 x half> %add to <vscale x 2 x float>
548 ret <vscale x 2 x float> %bitcast
551 ; +bf16 is required for the bfloat version.
552 attributes #0 = { "target-features"="+sve,+bf16" }