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
4 ;; Splats of legal integer vector types
6 define <vscale x 16 x i8> @sve_splat_16xi8(i8 %val) {
7 ; CHECK-LABEL: sve_splat_16xi8:
9 ; CHECK-NEXT: mov z0.b, w0
11 %ins = insertelement <vscale x 16 x i8> undef, i8 %val, i32 0
12 %splat = shufflevector <vscale x 16 x i8> %ins, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
13 ret <vscale x 16 x i8> %splat
16 define <vscale x 8 x i16> @sve_splat_8xi16(i16 %val) {
17 ; CHECK-LABEL: sve_splat_8xi16:
19 ; CHECK-NEXT: mov z0.h, w0
21 %ins = insertelement <vscale x 8 x i16> undef, i16 %val, i32 0
22 %splat = shufflevector <vscale x 8 x i16> %ins, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
23 ret <vscale x 8 x i16> %splat
26 define <vscale x 4 x i32> @sve_splat_4xi32(i32 %val) {
27 ; CHECK-LABEL: sve_splat_4xi32:
29 ; CHECK-NEXT: mov z0.s, w0
31 %ins = insertelement <vscale x 4 x i32> undef, i32 %val, i32 0
32 %splat = shufflevector <vscale x 4 x i32> %ins, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
33 ret <vscale x 4 x i32> %splat
36 define <vscale x 2 x i64> @sve_splat_2xi64(i64 %val) {
37 ; CHECK-LABEL: sve_splat_2xi64:
39 ; CHECK-NEXT: mov z0.d, x0
41 %ins = insertelement <vscale x 2 x i64> undef, i64 %val, i32 0
42 %splat = shufflevector <vscale x 2 x i64> %ins, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
43 ret <vscale x 2 x i64> %splat
46 define <vscale x 16 x i8> @sve_splat_16xi8_imm() {
47 ; CHECK-LABEL: sve_splat_16xi8_imm:
49 ; CHECK-NEXT: mov z0.b, #1 // =0x1
51 %ins = insertelement <vscale x 16 x i8> undef, i8 1, i32 0
52 %splat = shufflevector <vscale x 16 x i8> %ins, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
53 ret <vscale x 16 x i8> %splat
56 define <vscale x 8 x i16> @sve_splat_8xi16_dup_imm() {
57 ; CHECK-LABEL: sve_splat_8xi16_dup_imm:
59 ; CHECK-NEXT: mov z0.h, #1 // =0x1
61 %ins = insertelement <vscale x 8 x i16> undef, i16 1, i32 0
62 %splat = shufflevector <vscale x 8 x i16> %ins, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
63 ret <vscale x 8 x i16> %splat
66 define <vscale x 8 x i16> @sve_splat_8xi16_dupm_imm() {
67 ; CHECK-LABEL: sve_splat_8xi16_dupm_imm:
69 ; CHECK-NEXT: mov z0.h, #16256 // =0x3f80
71 %ins = insertelement <vscale x 8 x i16> undef, i16 16256, i32 0 ; 0x3f80
72 %splat = shufflevector <vscale x 8 x i16> %ins, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
73 ret <vscale x 8 x i16> %splat
76 define <vscale x 4 x i32> @sve_splat_4xi32_dup_imm() {
77 ; CHECK-LABEL: sve_splat_4xi32_dup_imm:
79 ; CHECK-NEXT: mov z0.s, #1 // =0x1
81 %ins = insertelement <vscale x 4 x i32> undef, i32 1, i32 0
82 %splat = shufflevector <vscale x 4 x i32> %ins, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
83 ret <vscale x 4 x i32> %splat
86 define <vscale x 4 x i32> @sve_splat_4xi32_dupm_imm() {
87 ; CHECK-LABEL: sve_splat_4xi32_dupm_imm:
89 ; CHECK-NEXT: mov z0.s, #0xff0000
91 %ins = insertelement <vscale x 4 x i32> undef, i32 16711680, i32 0 ; 0xff0000
92 %splat = shufflevector <vscale x 4 x i32> %ins, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
93 ret <vscale x 4 x i32> %splat
96 define <vscale x 2 x i64> @sve_splat_2xi64_dup_imm() {
97 ; CHECK-LABEL: sve_splat_2xi64_dup_imm:
99 ; CHECK-NEXT: mov z0.d, #1 // =0x1
101 %ins = insertelement <vscale x 2 x i64> undef, i64 1, i32 0
102 %splat = shufflevector <vscale x 2 x i64> %ins, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
103 ret <vscale x 2 x i64> %splat
106 define <vscale x 2 x i64> @sve_splat_2xi64_dupm_imm() {
107 ; CHECK-LABEL: sve_splat_2xi64_dupm_imm:
109 ; CHECK-NEXT: mov z0.d, #0xffff00000000
111 %ins = insertelement <vscale x 2 x i64> undef, i64 281470681743360, i32 0 ; 0xffff00000000
112 %splat = shufflevector <vscale x 2 x i64> %ins, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
113 ret <vscale x 2 x i64> %splat
116 ;; Promote splats of smaller illegal integer vector types
118 define <vscale x 2 x i8> @sve_splat_2xi8(i8 %val) {
119 ; CHECK-LABEL: sve_splat_2xi8:
121 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
122 ; CHECK-NEXT: mov z0.d, x0
124 %ins = insertelement <vscale x 2 x i8> undef, i8 %val, i32 0
125 %splat = shufflevector <vscale x 2 x i8> %ins, <vscale x 2 x i8> undef, <vscale x 2 x i32> zeroinitializer
126 ret <vscale x 2 x i8> %splat
129 define <vscale x 4 x i8> @sve_splat_4xi8(i8 %val) {
130 ; CHECK-LABEL: sve_splat_4xi8:
132 ; CHECK-NEXT: mov z0.s, w0
134 %ins = insertelement <vscale x 4 x i8> undef, i8 %val, i32 0
135 %splat = shufflevector <vscale x 4 x i8> %ins, <vscale x 4 x i8> undef, <vscale x 4 x i32> zeroinitializer
136 ret <vscale x 4 x i8> %splat
139 define <vscale x 8 x i8> @sve_splat_8xi8(i8 %val) {
140 ; CHECK-LABEL: sve_splat_8xi8:
142 ; CHECK-NEXT: mov z0.h, w0
144 %ins = insertelement <vscale x 8 x i8> undef, i8 %val, i32 0
145 %splat = shufflevector <vscale x 8 x i8> %ins, <vscale x 8 x i8> undef, <vscale x 8 x i32> zeroinitializer
146 ret <vscale x 8 x i8> %splat
149 define <vscale x 8 x i8> @sve_splat_8xi8_imm() {
150 ; CHECK-LABEL: sve_splat_8xi8_imm:
152 ; CHECK-NEXT: mov z0.h, #255 // =0xff
154 %ins = insertelement <vscale x 8 x i8> undef, i8 -1, i32 0
155 %splat = shufflevector <vscale x 8 x i8> %ins, <vscale x 8 x i8> undef, <vscale x 8 x i32> zeroinitializer
156 ret <vscale x 8 x i8> %splat
159 define <vscale x 2 x i16> @sve_splat_2xi16(i16 %val) {
160 ; CHECK-LABEL: sve_splat_2xi16:
162 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
163 ; CHECK-NEXT: mov z0.d, x0
165 %ins = insertelement <vscale x 2 x i16> undef, i16 %val, i32 0
166 %splat = shufflevector <vscale x 2 x i16> %ins, <vscale x 2 x i16> undef, <vscale x 2 x i32> zeroinitializer
167 ret <vscale x 2 x i16> %splat
170 define <vscale x 4 x i16> @sve_splat_4xi16(i16 %val) {
171 ; CHECK-LABEL: sve_splat_4xi16:
173 ; CHECK-NEXT: mov z0.s, w0
175 %ins = insertelement <vscale x 4 x i16> undef, i16 %val, i32 0
176 %splat = shufflevector <vscale x 4 x i16> %ins, <vscale x 4 x i16> undef, <vscale x 4 x i32> zeroinitializer
177 ret <vscale x 4 x i16> %splat
180 define <vscale x 4 x i16> @sve_splat_4xi16_imm() {
181 ; CHECK-LABEL: sve_splat_4xi16_imm:
183 ; CHECK-NEXT: mov z0.s, #65535 // =0xffff
185 %ins = insertelement <vscale x 4 x i16> undef, i16 -1, i32 0
186 %splat = shufflevector <vscale x 4 x i16> %ins, <vscale x 4 x i16> undef, <vscale x 4 x i32> zeroinitializer
187 ret <vscale x 4 x i16> %splat
190 define <vscale x 2 x i32> @sve_splat_2xi32(i32 %val) {
191 ; CHECK-LABEL: sve_splat_2xi32:
193 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
194 ; CHECK-NEXT: mov z0.d, x0
196 %ins = insertelement <vscale x 2 x i32> undef, i32 %val, i32 0
197 %splat = shufflevector <vscale x 2 x i32> %ins, <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer
198 ret <vscale x 2 x i32> %splat
201 define <vscale x 2 x i32> @sve_splat_2xi32_imm() {
202 ; CHECK-LABEL: sve_splat_2xi32_imm:
204 ; CHECK-NEXT: mov z0.d, #0xffffffff
206 %ins = insertelement <vscale x 2 x i32> undef, i32 -1, i32 0
207 %splat = shufflevector <vscale x 2 x i32> %ins, <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer
208 ret <vscale x 2 x i32> %splat
211 ;; Widen/split splats of wide vector types.
213 define <vscale x 1 x i32> @sve_splat_1xi32(i32 %val) {
214 ; CHECK-LABEL: sve_splat_1xi32:
215 ; CHECK: // %bb.0: // %entry
216 ; CHECK-NEXT: mov z0.s, w0
219 %ins = insertelement <vscale x 1 x i32> undef, i32 %val, i32 0
220 %splat = shufflevector <vscale x 1 x i32> %ins, <vscale x 1 x i32> undef, <vscale x 1 x i32> zeroinitializer
221 ret <vscale x 1 x i32> %splat
224 define <vscale x 12 x i32> @sve_splat_12xi32(i32 %val) {
225 ; CHECK-LABEL: sve_splat_12xi32:
227 ; CHECK-NEXT: mov z0.s, w0
228 ; CHECK-NEXT: mov z1.d, z0.d
229 ; CHECK-NEXT: mov z2.d, z0.d
231 %ins = insertelement <vscale x 12 x i32> undef, i32 %val, i32 0
232 %splat = shufflevector <vscale x 12 x i32> %ins, <vscale x 12 x i32> undef, <vscale x 12 x i32> zeroinitializer
233 ret <vscale x 12 x i32> %splat
236 define <vscale x 2 x i1> @sve_splat_2xi1(i1 %val) {
237 ; CHECK-LABEL: sve_splat_2xi1:
239 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
240 ; CHECK-NEXT: sbfx x8, x0, #0, #1
241 ; CHECK-NEXT: whilelo p0.d, xzr, x8
243 %ins = insertelement <vscale x 2 x i1> undef, i1 %val, i32 0
244 %splat = shufflevector <vscale x 2 x i1> %ins, <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
245 ret <vscale x 2 x i1> %splat
248 define <vscale x 4 x i1> @sve_splat_4xi1(i1 %val) {
249 ; CHECK-LABEL: sve_splat_4xi1:
251 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
252 ; CHECK-NEXT: sbfx x8, x0, #0, #1
253 ; CHECK-NEXT: whilelo p0.s, xzr, x8
255 %ins = insertelement <vscale x 4 x i1> undef, i1 %val, i32 0
256 %splat = shufflevector <vscale x 4 x i1> %ins, <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer
257 ret <vscale x 4 x i1> %splat
260 define <vscale x 8 x i1> @sve_splat_8xi1(i1 %val) {
261 ; CHECK-LABEL: sve_splat_8xi1:
263 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
264 ; CHECK-NEXT: sbfx x8, x0, #0, #1
265 ; CHECK-NEXT: whilelo p0.h, xzr, x8
267 %ins = insertelement <vscale x 8 x i1> undef, i1 %val, i32 0
268 %splat = shufflevector <vscale x 8 x i1> %ins, <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer
269 ret <vscale x 8 x i1> %splat
272 define <vscale x 16 x i1> @sve_splat_16xi1(i1 %val) {
273 ; CHECK-LABEL: sve_splat_16xi1:
275 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
276 ; CHECK-NEXT: sbfx x8, x0, #0, #1
277 ; CHECK-NEXT: whilelo p0.b, xzr, x8
279 %ins = insertelement <vscale x 16 x i1> undef, i1 %val, i32 0
280 %splat = shufflevector <vscale x 16 x i1> %ins, <vscale x 16 x i1> undef, <vscale x 16 x i32> zeroinitializer
281 ret <vscale x 16 x i1> %splat
284 ;; Splats of legal floating point vector types
286 define <vscale x 8 x bfloat> @splat_nxv8bf16(bfloat %val) #0 {
287 ; CHECK-LABEL: splat_nxv8bf16:
289 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
290 ; CHECK-NEXT: mov z0.h, h0
292 %1 = insertelement <vscale x 8 x bfloat> undef, bfloat %val, i32 0
293 %2 = shufflevector <vscale x 8 x bfloat> %1, <vscale x 8 x bfloat> undef, <vscale x 8 x i32> zeroinitializer
294 ret <vscale x 8 x bfloat> %2
297 define <vscale x 4 x bfloat> @splat_nxv4bf16(bfloat %val) #0 {
298 ; CHECK-LABEL: splat_nxv4bf16:
300 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
301 ; CHECK-NEXT: mov z0.h, h0
303 %1 = insertelement <vscale x 4 x bfloat> undef, bfloat %val, i32 0
304 %2 = shufflevector <vscale x 4 x bfloat> %1, <vscale x 4 x bfloat> undef, <vscale x 4 x i32> zeroinitializer
305 ret <vscale x 4 x bfloat> %2
308 define <vscale x 2 x bfloat> @splat_nxv2bf16(bfloat %val) #0 {
309 ; CHECK-LABEL: splat_nxv2bf16:
311 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
312 ; CHECK-NEXT: mov z0.h, h0
314 %1 = insertelement <vscale x 2 x bfloat> undef, bfloat %val, i32 0
315 %2 = shufflevector <vscale x 2 x bfloat> %1, <vscale x 2 x bfloat> undef, <vscale x 2 x i32> zeroinitializer
316 ret <vscale x 2 x bfloat> %2
319 define <vscale x 8 x half> @splat_nxv8f16(half %val) {
320 ; CHECK-LABEL: splat_nxv8f16:
322 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
323 ; CHECK-NEXT: mov z0.h, h0
325 %1 = insertelement <vscale x 8 x half> undef, half %val, i32 0
326 %2 = shufflevector <vscale x 8 x half> %1, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer
327 ret <vscale x 8 x half> %2
330 define <vscale x 4 x half> @splat_nxv4f16(half %val) {
331 ; CHECK-LABEL: splat_nxv4f16:
333 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
334 ; CHECK-NEXT: mov z0.h, h0
336 %1 = insertelement <vscale x 4 x half> undef, half %val, i32 0
337 %2 = shufflevector <vscale x 4 x half> %1, <vscale x 4 x half> undef, <vscale x 4 x i32> zeroinitializer
338 ret <vscale x 4 x half> %2
341 define <vscale x 2 x half> @splat_nxv2f16(half %val) {
342 ; CHECK-LABEL: splat_nxv2f16:
344 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
345 ; CHECK-NEXT: mov z0.h, h0
347 %1 = insertelement <vscale x 2 x half> undef, half %val, i32 0
348 %2 = shufflevector <vscale x 2 x half> %1, <vscale x 2 x half> undef, <vscale x 2 x i32> zeroinitializer
349 ret <vscale x 2 x half> %2
352 define <vscale x 4 x float> @splat_nxv4f32(float %val) {
353 ; CHECK-LABEL: splat_nxv4f32:
355 ; CHECK-NEXT: // kill: def $s0 killed $s0 def $z0
356 ; CHECK-NEXT: mov z0.s, s0
358 %1 = insertelement <vscale x 4 x float> undef, float %val, i32 0
359 %2 = shufflevector <vscale x 4 x float> %1, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
360 ret <vscale x 4 x float> %2
363 define <vscale x 2 x float> @splat_nxv2f32(float %val) {
364 ; CHECK-LABEL: splat_nxv2f32:
366 ; CHECK-NEXT: // kill: def $s0 killed $s0 def $z0
367 ; CHECK-NEXT: mov z0.s, s0
369 %1 = insertelement <vscale x 2 x float> undef, float %val, i32 0
370 %2 = shufflevector <vscale x 2 x float> %1, <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
371 ret <vscale x 2 x float> %2
374 define <vscale x 2 x double> @splat_nxv2f64(double %val) {
375 ; CHECK-LABEL: splat_nxv2f64:
377 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
378 ; CHECK-NEXT: mov z0.d, d0
380 %1 = insertelement <vscale x 2 x double> undef, double %val, i32 0
381 %2 = shufflevector <vscale x 2 x double> %1, <vscale x 2 x double> undef, <vscale x 2 x i32> zeroinitializer
382 ret <vscale x 2 x double> %2
385 define <vscale x 8 x bfloat> @splat_nxv8bf16_zero() #0 {
386 ; CHECK-LABEL: splat_nxv8bf16_zero:
388 ; CHECK-NEXT: mov z0.h, #0 // =0x0
390 ret <vscale x 8 x bfloat> zeroinitializer
393 define <vscale x 4 x bfloat> @splat_nxv4bf16_zero() #0 {
394 ; CHECK-LABEL: splat_nxv4bf16_zero:
396 ; CHECK-NEXT: mov z0.h, #0 // =0x0
398 ret <vscale x 4 x bfloat> zeroinitializer
401 define <vscale x 2 x bfloat> @splat_nxv2bf16_zero() #0 {
402 ; CHECK-LABEL: splat_nxv2bf16_zero:
404 ; CHECK-NEXT: mov z0.h, #0 // =0x0
406 ret <vscale x 2 x bfloat> zeroinitializer
409 define <vscale x 8 x half> @splat_nxv8f16_zero() {
410 ; CHECK-LABEL: splat_nxv8f16_zero:
412 ; CHECK-NEXT: mov z0.h, #0 // =0x0
414 ret <vscale x 8 x half> zeroinitializer
417 define <vscale x 4 x half> @splat_nxv4f16_zero() {
418 ; CHECK-LABEL: splat_nxv4f16_zero:
420 ; CHECK-NEXT: mov z0.h, #0 // =0x0
422 ret <vscale x 4 x half> zeroinitializer
425 define <vscale x 2 x half> @splat_nxv2f16_zero() {
426 ; CHECK-LABEL: splat_nxv2f16_zero:
428 ; CHECK-NEXT: mov z0.h, #0 // =0x0
430 ret <vscale x 2 x half> zeroinitializer
433 define <vscale x 4 x float> @splat_nxv4f32_zero() {
434 ; CHECK-LABEL: splat_nxv4f32_zero:
436 ; CHECK-NEXT: mov z0.s, #0 // =0x0
438 ret <vscale x 4 x float> zeroinitializer
441 define <vscale x 2 x float> @splat_nxv2f32_zero() {
442 ; CHECK-LABEL: splat_nxv2f32_zero:
444 ; CHECK-NEXT: mov z0.s, #0 // =0x0
446 ret <vscale x 2 x float> zeroinitializer
449 define <vscale x 2 x double> @splat_nxv2f64_zero() {
450 ; CHECK-LABEL: splat_nxv2f64_zero:
452 ; CHECK-NEXT: mov z0.d, #0 // =0x0
454 ret <vscale x 2 x double> zeroinitializer
457 define <vscale x 8 x half> @splat_nxv8f16_imm() {
458 ; CHECK-LABEL: splat_nxv8f16_imm:
460 ; CHECK-NEXT: fmov z0.h, #1.00000000
462 %1 = insertelement <vscale x 8 x half> undef, half 1.0, i32 0
463 %2 = shufflevector <vscale x 8 x half> %1, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer
464 ret <vscale x 8 x half> %2
467 define <vscale x 4 x half> @splat_nxv4f16_imm() {
468 ; CHECK-LABEL: splat_nxv4f16_imm:
470 ; CHECK-NEXT: fmov z0.h, #1.00000000
472 %1 = insertelement <vscale x 4 x half> undef, half 1.0, i32 0
473 %2 = shufflevector <vscale x 4 x half> %1, <vscale x 4 x half> undef, <vscale x 4 x i32> zeroinitializer
474 ret <vscale x 4 x half> %2
477 define <vscale x 2 x half> @splat_nxv2f16_imm() {
478 ; CHECK-LABEL: splat_nxv2f16_imm:
480 ; CHECK-NEXT: fmov z0.h, #1.00000000
482 %1 = insertelement <vscale x 2 x half> undef, half 1.0, i32 0
483 %2 = shufflevector <vscale x 2 x half> %1, <vscale x 2 x half> undef, <vscale x 2 x i32> zeroinitializer
484 ret <vscale x 2 x half> %2
487 define <vscale x 4 x float> @splat_nxv4f32_imm() {
488 ; CHECK-LABEL: splat_nxv4f32_imm:
490 ; CHECK-NEXT: fmov z0.s, #1.00000000
492 %1 = insertelement <vscale x 4 x float> undef, float 1.0, i32 0
493 %2 = shufflevector <vscale x 4 x float> %1, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
494 ret <vscale x 4 x float> %2
497 define <vscale x 2 x float> @splat_nxv2f32_imm() {
498 ; CHECK-LABEL: splat_nxv2f32_imm:
500 ; CHECK-NEXT: fmov z0.s, #1.00000000
502 %1 = insertelement <vscale x 2 x float> undef, float 1.0, i32 0
503 %2 = shufflevector <vscale x 2 x float> %1, <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
504 ret <vscale x 2 x float> %2
507 define <vscale x 2 x double> @splat_nxv2f64_imm() {
508 ; CHECK-LABEL: splat_nxv2f64_imm:
510 ; CHECK-NEXT: fmov z0.d, #1.00000000
512 %1 = insertelement <vscale x 2 x double> undef, double 1.0, i32 0
513 %2 = shufflevector <vscale x 2 x double> %1, <vscale x 2 x double> undef, <vscale x 2 x i32> zeroinitializer
514 ret <vscale x 2 x double> %2
517 define <vscale x 4 x i32> @splat_nxv4i32_fold(<vscale x 4 x i32> %x) {
518 ; CHECK-LABEL: splat_nxv4i32_fold:
520 ; CHECK-NEXT: mov z0.s, #0 // =0x0
522 %r = sub <vscale x 4 x i32> %x, %x
523 ret <vscale x 4 x i32> %r
527 define <vscale x 4 x float> @splat_nxv4f32_fold(<vscale x 4 x float> %x) {
528 ; CHECK-LABEL: splat_nxv4f32_fold:
530 ; CHECK-NEXT: mov z0.s, #0 // =0x0
532 %r = fsub nnan <vscale x 4 x float> %x, %x
533 ret <vscale x 4 x float> %r
536 define <vscale x 2 x float> @splat_nxv2f32_fmov_fold() {
537 ; CHECK-LABEL: splat_nxv2f32_fmov_fold:
539 ; CHECK-NEXT: mov w8, #1109917696 // =0x42280000
540 ; CHECK-NEXT: mov z0.s, w8
542 %1 = insertelement <vscale x 2 x float> undef, float 4.200000e+01, i32 0
543 %2 = shufflevector <vscale x 2 x float> %1, <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
544 ret <vscale x 2 x float> %2
547 define <vscale x 4 x float> @splat_nxv4f32_fmov_fold() {
548 ; CHECK-LABEL: splat_nxv4f32_fmov_fold:
550 ; CHECK-NEXT: mov w8, #1109917696 // =0x42280000
551 ; CHECK-NEXT: mov z0.s, w8
553 %1 = insertelement <vscale x 4 x float> undef, float 4.200000e+01, i32 0
554 %2 = shufflevector <vscale x 4 x float> %1, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
555 ret <vscale x 4 x float> %2
558 define <vscale x 2 x double> @splat_nxv2f64_fmov_fold() {
559 ; CHECK-LABEL: splat_nxv2f64_fmov_fold:
561 ; CHECK-NEXT: mov x8, #4631107791820423168 // =0x4045000000000000
562 ; CHECK-NEXT: mov z0.d, x8
564 %1 = insertelement <vscale x 2 x double> undef, double 4.200000e+01, i32 0
565 %2 = shufflevector <vscale x 2 x double> %1, <vscale x 2 x double> undef, <vscale x 2 x i32> zeroinitializer
566 ret <vscale x 2 x double> %2
569 ; Splat of float constants not representable as a single immediate.
571 define <vscale x 2 x float> @splat_nxv2f32_imm_out_of_range() {
572 ; CHECK-LABEL: splat_nxv2f32_imm_out_of_range:
574 ; CHECK-NEXT: mov w8, #7864 // =0x1eb8
575 ; CHECK-NEXT: movk w8, #16469, lsl #16
576 ; CHECK-NEXT: mov z0.s, w8
578 %1 = insertelement <vscale x 2 x float> undef, float 3.3299999237060546875, i32 0
579 %2 = shufflevector <vscale x 2 x float> %1, <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
580 ret <vscale x 2 x float> %2
583 define <vscale x 4 x float> @splat_nxv4f32_imm_out_of_range() {
584 ; CHECK-LABEL: splat_nxv4f32_imm_out_of_range:
586 ; CHECK-NEXT: mov w8, #7864 // =0x1eb8
587 ; CHECK-NEXT: movk w8, #16469, lsl #16
588 ; CHECK-NEXT: mov z0.s, w8
590 %1 = insertelement <vscale x 4 x float> undef, float 3.3299999237060546875, i32 0
591 %2 = shufflevector <vscale x 4 x float> %1, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
592 ret <vscale x 4 x float> %2
595 define <vscale x 2 x double> @splat_nxv2f64_imm_out_of_range() {
596 ; CHECK-LABEL: splat_nxv2f64_imm_out_of_range:
598 ; CHECK-NEXT: ptrue p0.d
599 ; CHECK-NEXT: adrp x8, .LCPI57_0
600 ; CHECK-NEXT: add x8, x8, :lo12:.LCPI57_0
601 ; CHECK-NEXT: ld1rd { z0.d }, p0/z, [x8]
603 %1 = insertelement <vscale x 2 x double> undef, double 3.33, i32 0
604 %2 = shufflevector <vscale x 2 x double> %1, <vscale x 2 x double> undef, <vscale x 2 x i32> zeroinitializer
605 ret <vscale x 2 x double> %2
608 ; Splat for predicates
609 ; This guards optimizations that rely on splats of 1 being generated as a ptrue
611 define <vscale x 2 x i1> @sve_splat_i1_allactive() {
612 ; CHECK-LABEL: sve_splat_i1_allactive:
614 ; CHECK-NEXT: ptrue p0.d
616 %ins = insertelement <vscale x 2 x i1> undef, i1 1, i32 0
617 %splat = shufflevector <vscale x 2 x i1> %ins, <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
618 ret <vscale x 2 x i1> %splat
621 ; +bf16 is required for the bfloat version.
622 attributes #0 = { "target-features"="+sve,+bf16" }