1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 < %s | FileCheck %s
4 define <vscale x 16 x i8> @test_lane0_16xi8(<vscale x 16 x i8> %a) {
5 ; CHECK-LABEL: test_lane0_16xi8:
7 ; CHECK-NEXT: ptrue p0.b, vl1
8 ; CHECK-NEXT: mov w8, #30 // =0x1e
9 ; CHECK-NEXT: mov z0.b, p0/m, w8
11 %b = insertelement <vscale x 16 x i8> %a, i8 30, i32 0
12 ret <vscale x 16 x i8> %b
15 define <vscale x 8 x i16> @test_lane0_8xi16(<vscale x 8 x i16> %a) {
16 ; CHECK-LABEL: test_lane0_8xi16:
18 ; CHECK-NEXT: ptrue p0.h, vl1
19 ; CHECK-NEXT: mov w8, #30 // =0x1e
20 ; CHECK-NEXT: mov z0.h, p0/m, w8
22 %b = insertelement <vscale x 8 x i16> %a, i16 30, i32 0
23 ret <vscale x 8 x i16> %b
26 define <vscale x 4 x i32> @test_lane0_4xi32(<vscale x 4 x i32> %a) {
27 ; CHECK-LABEL: test_lane0_4xi32:
29 ; CHECK-NEXT: ptrue p0.s, vl1
30 ; CHECK-NEXT: mov w8, #30 // =0x1e
31 ; CHECK-NEXT: mov z0.s, p0/m, w8
33 %b = insertelement <vscale x 4 x i32> %a, i32 30, i32 0
34 ret <vscale x 4 x i32> %b
37 define <vscale x 2 x i64> @test_lane0_2xi64(<vscale x 2 x i64> %a) {
38 ; CHECK-LABEL: test_lane0_2xi64:
40 ; CHECK-NEXT: ptrue p0.d, vl1
41 ; CHECK-NEXT: mov w8, #30 // =0x1e
42 ; CHECK-NEXT: mov z0.d, p0/m, x8
44 %b = insertelement <vscale x 2 x i64> %a, i64 30, i32 0
45 ret <vscale x 2 x i64> %b
48 define <vscale x 2 x double> @test_lane0_2xf64(<vscale x 2 x double> %a) {
49 ; CHECK-LABEL: test_lane0_2xf64:
51 ; CHECK-NEXT: fmov d1, #1.00000000
52 ; CHECK-NEXT: ptrue p0.d, vl1
53 ; CHECK-NEXT: mov z0.d, p0/m, z1.d
55 %b = insertelement <vscale x 2 x double> %a, double 1.0, i32 0
56 ret <vscale x 2 x double> %b
59 define <vscale x 4 x float> @test_lane0_4xf32(<vscale x 4 x float> %a) {
60 ; CHECK-LABEL: test_lane0_4xf32:
62 ; CHECK-NEXT: fmov s1, #1.00000000
63 ; CHECK-NEXT: ptrue p0.s, vl1
64 ; CHECK-NEXT: mov z0.s, p0/m, z1.s
66 %b = insertelement <vscale x 4 x float> %a, float 1.0, i32 0
67 ret <vscale x 4 x float> %b
70 define <vscale x 8 x half> @test_lane0_8xf16(<vscale x 8 x half> %a) {
71 ; CHECK-LABEL: test_lane0_8xf16:
73 ; CHECK-NEXT: fmov h1, #1.00000000
74 ; CHECK-NEXT: ptrue p0.h, vl1
75 ; CHECK-NEXT: mov z0.h, p0/m, z1.h
77 %b = insertelement <vscale x 8 x half> %a, half 1.0, i32 0
78 ret <vscale x 8 x half> %b
81 define <vscale x 8 x bfloat> @test_lane0_8xbf16(<vscale x 8 x bfloat> %a, bfloat %x) {
82 ; CHECK-LABEL: test_lane0_8xbf16:
84 ; CHECK-NEXT: ptrue p0.h, vl1
85 ; CHECK-NEXT: // kill: def $h1 killed $h1 def $z1
86 ; CHECK-NEXT: mov z0.h, p0/m, z1.h
88 %b = insertelement <vscale x 8 x bfloat> %a, bfloat %x, i32 0
89 ret <vscale x 8 x bfloat> %b
92 ; Undefined lane insert
93 define <vscale x 2 x i64> @test_lane4_2xi64(<vscale x 2 x i64> %a) {
94 ; CHECK-LABEL: test_lane4_2xi64:
96 ; CHECK-NEXT: mov w8, #4 // =0x4
97 ; CHECK-NEXT: index z1.d, #0, #1
98 ; CHECK-NEXT: ptrue p0.d
99 ; CHECK-NEXT: mov z2.d, x8
100 ; CHECK-NEXT: mov w8, #30 // =0x1e
101 ; CHECK-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
102 ; CHECK-NEXT: mov z0.d, p0/m, x8
104 %b = insertelement <vscale x 2 x i64> %a, i64 30, i32 4
105 ret <vscale x 2 x i64> %b
108 ; Undefined lane insert
109 define <vscale x 8 x half> @test_lane9_8xf16(<vscale x 8 x half> %a) {
110 ; CHECK-LABEL: test_lane9_8xf16:
112 ; CHECK-NEXT: mov w8, #9 // =0x9
113 ; CHECK-NEXT: index z1.h, #0, #1
114 ; CHECK-NEXT: ptrue p0.h
115 ; CHECK-NEXT: mov z2.h, w8
116 ; CHECK-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
117 ; CHECK-NEXT: fmov h1, #1.00000000
118 ; CHECK-NEXT: mov z0.h, p0/m, h1
120 %b = insertelement <vscale x 8 x half> %a, half 1.0, i32 9
121 ret <vscale x 8 x half> %b
124 define <vscale x 8 x bfloat> @test_lane9_8xbf16(<vscale x 8 x bfloat> %a, bfloat %x) {
125 ; CHECK-LABEL: test_lane9_8xbf16:
127 ; CHECK-NEXT: mov w8, #9 // =0x9
128 ; CHECK-NEXT: index z2.h, #0, #1
129 ; CHECK-NEXT: ptrue p0.h
130 ; CHECK-NEXT: mov z3.h, w8
131 ; CHECK-NEXT: cmpeq p0.h, p0/z, z2.h, z3.h
132 ; CHECK-NEXT: mov z0.h, p0/m, h1
134 %b = insertelement <vscale x 8 x bfloat> %a, bfloat %x, i32 9
135 ret <vscale x 8 x bfloat> %b
138 define <vscale x 16 x i8> @test_lane1_16xi8(<vscale x 16 x i8> %a) {
139 ; CHECK-LABEL: test_lane1_16xi8:
141 ; CHECK-NEXT: mov w8, #1 // =0x1
142 ; CHECK-NEXT: index z1.b, #0, #1
143 ; CHECK-NEXT: ptrue p0.b
144 ; CHECK-NEXT: mov z2.b, w8
145 ; CHECK-NEXT: mov w8, #30 // =0x1e
146 ; CHECK-NEXT: cmpeq p0.b, p0/z, z1.b, z2.b
147 ; CHECK-NEXT: mov z0.b, p0/m, w8
149 %b = insertelement <vscale x 16 x i8> %a, i8 30, i32 1
150 ret <vscale x 16 x i8> %b
153 define <vscale x 16 x i8> @test_lanex_16xi8(<vscale x 16 x i8> %a, i32 %x) {
154 ; CHECK-LABEL: test_lanex_16xi8:
156 ; CHECK-NEXT: index z1.b, #0, #1
157 ; CHECK-NEXT: mov w8, w0
158 ; CHECK-NEXT: ptrue p0.b
159 ; CHECK-NEXT: mov z2.b, w8
160 ; CHECK-NEXT: mov w8, #30 // =0x1e
161 ; CHECK-NEXT: cmpeq p0.b, p0/z, z1.b, z2.b
162 ; CHECK-NEXT: mov z0.b, p0/m, w8
164 %b = insertelement <vscale x 16 x i8> %a, i8 30, i32 %x
165 ret <vscale x 16 x i8> %b
169 ; Redundant lane insert
170 define <vscale x 4 x i32> @extract_insert_4xi32(<vscale x 4 x i32> %a) {
171 ; CHECK-LABEL: extract_insert_4xi32:
174 %b = extractelement <vscale x 4 x i32> %a, i32 2
175 %c = insertelement <vscale x 4 x i32> %a, i32 %b, i32 2
176 ret <vscale x 4 x i32> %c
179 define <vscale x 8 x i16> @test_lane6_undef_8xi16(i16 %a) {
180 ; CHECK-LABEL: test_lane6_undef_8xi16:
182 ; CHECK-NEXT: mov w8, #6 // =0x6
183 ; CHECK-NEXT: index z0.h, #0, #1
184 ; CHECK-NEXT: ptrue p0.h
185 ; CHECK-NEXT: mov z1.h, w8
186 ; CHECK-NEXT: cmpeq p0.h, p0/z, z0.h, z1.h
187 ; CHECK-NEXT: mov z0.h, p0/m, w0
189 %b = insertelement <vscale x 8 x i16> undef, i16 %a, i32 6
190 ret <vscale x 8 x i16> %b
193 define <vscale x 16 x i8> @test_lane0_undef_16xi8(i8 %a) {
194 ; CHECK-LABEL: test_lane0_undef_16xi8:
196 ; CHECK-NEXT: fmov s0, w0
198 %b = insertelement <vscale x 16 x i8> undef, i8 %a, i32 0
199 ret <vscale x 16 x i8> %b
202 define <vscale x 16 x i8> @test_insert0_of_extract0_16xi8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
203 ; CHECK-LABEL: test_insert0_of_extract0_16xi8:
205 ; CHECK-NEXT: fmov w8, s1
206 ; CHECK-NEXT: ptrue p0.b, vl1
207 ; CHECK-NEXT: mov z0.b, p0/m, w8
209 %c = extractelement <vscale x 16 x i8> %b, i32 0
210 %d = insertelement <vscale x 16 x i8> %a, i8 %c, i32 0
211 ret <vscale x 16 x i8> %d
214 define <vscale x 16 x i8> @test_insert64_of_extract64_16xi8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
215 ; CHECK-LABEL: test_insert64_of_extract64_16xi8:
217 ; CHECK-NEXT: mov w8, #64 // =0x40
218 ; CHECK-NEXT: whilels p0.b, xzr, x8
219 ; CHECK-NEXT: mov z2.b, w8
220 ; CHECK-NEXT: lastb w9, p0, z1.b
221 ; CHECK-NEXT: index z1.b, #0, #1
222 ; CHECK-NEXT: ptrue p0.b
223 ; CHECK-NEXT: cmpeq p0.b, p0/z, z1.b, z2.b
224 ; CHECK-NEXT: mov z0.b, p0/m, w9
226 %c = extractelement <vscale x 16 x i8> %b, i32 64
227 %d = insertelement <vscale x 16 x i8> %a, i8 %c, i32 64
228 ret <vscale x 16 x i8> %d
231 define <vscale x 16 x i8> @test_insert3_of_extract1_16xi8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
232 ; CHECK-LABEL: test_insert3_of_extract1_16xi8:
234 ; CHECK-NEXT: mov w8, #3 // =0x3
235 ; CHECK-NEXT: index z2.b, #0, #1
236 ; CHECK-NEXT: ptrue p0.b
237 ; CHECK-NEXT: mov z3.b, w8
238 ; CHECK-NEXT: umov w8, v1.b[1]
239 ; CHECK-NEXT: cmpeq p0.b, p0/z, z2.b, z3.b
240 ; CHECK-NEXT: mov z0.b, p0/m, w8
242 %c = extractelement <vscale x 16 x i8> %b, i32 1
243 %d = insertelement <vscale x 16 x i8> %a, i8 %c, i32 3
244 ret <vscale x 16 x i8> %d
247 define <vscale x 8 x half> @test_insert_into_undef_nxv8f16(half %a) {
248 ; CHECK-LABEL: test_insert_into_undef_nxv8f16:
250 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
252 %b = insertelement <vscale x 8 x half> undef, half %a, i32 0
253 ret <vscale x 8 x half> %b
256 define <vscale x 4 x half> @test_insert_into_undef_nxv4f16(half %a) {
257 ; CHECK-LABEL: test_insert_into_undef_nxv4f16:
259 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
261 %b = insertelement <vscale x 4 x half> undef, half %a, i32 0
262 ret <vscale x 4 x half> %b
265 define <vscale x 2 x half> @test_insert_into_undef_nxv2f16(half %a) {
266 ; CHECK-LABEL: test_insert_into_undef_nxv2f16:
268 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
270 %b = insertelement <vscale x 2 x half> undef, half %a, i32 0
271 ret <vscale x 2 x half> %b
274 define <vscale x 8 x bfloat> @test_insert_into_undef_nxv8bf16(bfloat %a) {
275 ; CHECK-LABEL: test_insert_into_undef_nxv8bf16:
277 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
279 %b = insertelement <vscale x 8 x bfloat> undef, bfloat %a, i32 0
280 ret <vscale x 8 x bfloat> %b
283 define <vscale x 4 x bfloat> @test_insert_into_undef_nxv4bf16(bfloat %a) {
284 ; CHECK-LABEL: test_insert_into_undef_nxv4bf16:
286 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
288 %b = insertelement <vscale x 4 x bfloat> undef, bfloat %a, i32 0
289 ret <vscale x 4 x bfloat> %b
292 define <vscale x 2 x bfloat> @test_insert_into_undef_nxv2bf16(bfloat %a) {
293 ; CHECK-LABEL: test_insert_into_undef_nxv2bf16:
295 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $z0
297 %b = insertelement <vscale x 2 x bfloat> undef, bfloat %a, i32 0
298 ret <vscale x 2 x bfloat> %b
301 define <vscale x 4 x float> @test_insert_into_undef_nxv4f32(float %a) {
302 ; CHECK-LABEL: test_insert_into_undef_nxv4f32:
304 ; CHECK-NEXT: // kill: def $s0 killed $s0 def $z0
306 %b = insertelement <vscale x 4 x float> undef, float %a, i32 0
307 ret <vscale x 4 x float> %b
310 define <vscale x 2 x float> @test_insert_into_undef_nxv2f32(float %a) {
311 ; CHECK-LABEL: test_insert_into_undef_nxv2f32:
313 ; CHECK-NEXT: // kill: def $s0 killed $s0 def $z0
315 %b = insertelement <vscale x 2 x float> undef, float %a, i32 0
316 ret <vscale x 2 x float> %b
319 define <vscale x 2 x double> @test_insert_into_undef_nxv2f64(double %a) {
320 ; CHECK-LABEL: test_insert_into_undef_nxv2f64:
322 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
324 %b = insertelement <vscale x 2 x double> undef, double %a, i32 0
325 ret <vscale x 2 x double> %b
328 ; Insert scalar at index
329 define <vscale x 2 x half> @test_insert_with_index_nxv2f16(half %h, i64 %idx) {
330 ; CHECK-LABEL: test_insert_with_index_nxv2f16:
332 ; CHECK-NEXT: index z1.d, #0, #1
333 ; CHECK-NEXT: mov z2.d, x0
334 ; CHECK-NEXT: ptrue p0.d
335 ; CHECK-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
336 ; CHECK-NEXT: mov z0.h, p0/m, h0
338 %res = insertelement <vscale x 2 x half> undef, half %h, i64 %idx
339 ret <vscale x 2 x half> %res
342 define <vscale x 4 x half> @test_insert_with_index_nxv4f16(half %h, i64 %idx) {
343 ; CHECK-LABEL: test_insert_with_index_nxv4f16:
345 ; CHECK-NEXT: index z1.s, #0, #1
346 ; CHECK-NEXT: mov z2.s, w0
347 ; CHECK-NEXT: ptrue p0.s
348 ; CHECK-NEXT: cmpeq p0.s, p0/z, z1.s, z2.s
349 ; CHECK-NEXT: mov z0.h, p0/m, h0
351 %res = insertelement <vscale x 4 x half> undef, half %h, i64 %idx
352 ret <vscale x 4 x half> %res
355 define <vscale x 8 x half> @test_insert_with_index_nxv8f16(half %h, i64 %idx) {
356 ; CHECK-LABEL: test_insert_with_index_nxv8f16:
358 ; CHECK-NEXT: index z1.h, #0, #1
359 ; CHECK-NEXT: mov z2.h, w0
360 ; CHECK-NEXT: ptrue p0.h
361 ; CHECK-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
362 ; CHECK-NEXT: mov z0.h, p0/m, h0
364 %res = insertelement <vscale x 8 x half> undef, half %h, i64 %idx
365 ret <vscale x 8 x half> %res
368 define <vscale x 2 x bfloat> @test_insert_with_index_nxv2bf16(bfloat %h, i64 %idx) {
369 ; CHECK-LABEL: test_insert_with_index_nxv2bf16:
371 ; CHECK-NEXT: index z1.d, #0, #1
372 ; CHECK-NEXT: mov z2.d, x0
373 ; CHECK-NEXT: ptrue p0.d
374 ; CHECK-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
375 ; CHECK-NEXT: mov z0.h, p0/m, h0
377 %res = insertelement <vscale x 2 x bfloat> undef, bfloat %h, i64 %idx
378 ret <vscale x 2 x bfloat> %res
381 define <vscale x 4 x bfloat> @test_insert_with_index_nxv4bf16(bfloat %h, i64 %idx) {
382 ; CHECK-LABEL: test_insert_with_index_nxv4bf16:
384 ; CHECK-NEXT: index z1.s, #0, #1
385 ; CHECK-NEXT: mov z2.s, w0
386 ; CHECK-NEXT: ptrue p0.s
387 ; CHECK-NEXT: cmpeq p0.s, p0/z, z1.s, z2.s
388 ; CHECK-NEXT: mov z0.h, p0/m, h0
390 %res = insertelement <vscale x 4 x bfloat> undef, bfloat %h, i64 %idx
391 ret <vscale x 4 x bfloat> %res
394 define <vscale x 8 x bfloat> @test_insert_with_index_nxv8bf16(bfloat %h, i64 %idx) {
395 ; CHECK-LABEL: test_insert_with_index_nxv8bf16:
397 ; CHECK-NEXT: index z1.h, #0, #1
398 ; CHECK-NEXT: mov z2.h, w0
399 ; CHECK-NEXT: ptrue p0.h
400 ; CHECK-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
401 ; CHECK-NEXT: mov z0.h, p0/m, h0
403 %res = insertelement <vscale x 8 x bfloat> undef, bfloat %h, i64 %idx
404 ret <vscale x 8 x bfloat> %res
407 define <vscale x 2 x float> @test_insert_with_index_nxv2f32(float %f, i64 %idx) {
408 ; CHECK-LABEL: test_insert_with_index_nxv2f32:
410 ; CHECK-NEXT: index z1.d, #0, #1
411 ; CHECK-NEXT: mov z2.d, x0
412 ; CHECK-NEXT: ptrue p0.d
413 ; CHECK-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
414 ; CHECK-NEXT: mov z0.s, p0/m, s0
416 %res = insertelement <vscale x 2 x float> undef, float %f, i64 %idx
417 ret <vscale x 2 x float> %res
420 define <vscale x 4 x float> @test_insert_with_index_nxv4f32(float %f, i64 %idx) {
421 ; CHECK-LABEL: test_insert_with_index_nxv4f32:
423 ; CHECK-NEXT: index z1.s, #0, #1
424 ; CHECK-NEXT: mov z2.s, w0
425 ; CHECK-NEXT: ptrue p0.s
426 ; CHECK-NEXT: cmpeq p0.s, p0/z, z1.s, z2.s
427 ; CHECK-NEXT: mov z0.s, p0/m, s0
429 %res = insertelement <vscale x 4 x float> undef, float %f, i64 %idx
430 ret <vscale x 4 x float> %res
433 define <vscale x 2 x double> @test_insert_with_index_nxv2f64(double %d, i64 %idx) {
434 ; CHECK-LABEL: test_insert_with_index_nxv2f64:
436 ; CHECK-NEXT: index z1.d, #0, #1
437 ; CHECK-NEXT: mov z2.d, x0
438 ; CHECK-NEXT: ptrue p0.d
439 ; CHECK-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
440 ; CHECK-NEXT: mov z0.d, p0/m, d0
442 %res = insertelement <vscale x 2 x double> undef, double %d, i64 %idx
443 ret <vscale x 2 x double> %res
447 define <vscale x 2 x i1> @test_predicate_insert_2xi1_immediate (<vscale x 2 x i1> %val, i1 %elt) {
448 ; CHECK-LABEL: test_predicate_insert_2xi1_immediate:
450 ; CHECK-NEXT: mov z0.d, p0/z, #1 // =0x1
451 ; CHECK-NEXT: ptrue p0.d, vl1
452 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
453 ; CHECK-NEXT: mov z0.d, p0/m, x0
454 ; CHECK-NEXT: ptrue p0.d
455 ; CHECK-NEXT: and z0.d, z0.d, #0x1
456 ; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0
458 %res = insertelement <vscale x 2 x i1> %val, i1 %elt, i32 0
459 ret <vscale x 2 x i1> %res
462 define <vscale x 4 x i1> @test_predicate_insert_4xi1_immediate (<vscale x 4 x i1> %val, i1 %elt) {
463 ; CHECK-LABEL: test_predicate_insert_4xi1_immediate:
465 ; CHECK-NEXT: mov w8, #2 // =0x2
466 ; CHECK-NEXT: index z0.s, #0, #1
467 ; CHECK-NEXT: ptrue p1.s
468 ; CHECK-NEXT: mov z1.s, w8
469 ; CHECK-NEXT: cmpeq p2.s, p1/z, z0.s, z1.s
470 ; CHECK-NEXT: mov z0.s, p0/z, #1 // =0x1
471 ; CHECK-NEXT: mov z0.s, p2/m, w0
472 ; CHECK-NEXT: and z0.s, z0.s, #0x1
473 ; CHECK-NEXT: cmpne p0.s, p1/z, z0.s, #0
475 %res = insertelement <vscale x 4 x i1> %val, i1 %elt, i32 2
476 ret <vscale x 4 x i1> %res
479 define <vscale x 8 x i1> @test_predicate_insert_8xi1_immediate (<vscale x 8 x i1> %val, i32 %idx) {
480 ; CHECK-LABEL: test_predicate_insert_8xi1_immediate:
482 ; CHECK-NEXT: index z0.h, #0, #1
483 ; CHECK-NEXT: mov w8, w0
484 ; CHECK-NEXT: ptrue p1.h
485 ; CHECK-NEXT: mov z1.h, w8
486 ; CHECK-NEXT: mov w8, #1 // =0x1
487 ; CHECK-NEXT: cmpeq p2.h, p1/z, z0.h, z1.h
488 ; CHECK-NEXT: mov z0.h, p0/z, #1 // =0x1
489 ; CHECK-NEXT: mov z0.h, p2/m, w8
490 ; CHECK-NEXT: and z0.h, z0.h, #0x1
491 ; CHECK-NEXT: cmpne p0.h, p1/z, z0.h, #0
493 %res = insertelement <vscale x 8 x i1> %val, i1 1, i32 %idx
494 ret <vscale x 8 x i1> %res
497 define <vscale x 16 x i1> @test_predicate_insert_16xi1_immediate (<vscale x 16 x i1> %val) {
498 ; CHECK-LABEL: test_predicate_insert_16xi1_immediate:
500 ; CHECK-NEXT: mov w8, #4 // =0x4
501 ; CHECK-NEXT: index z0.b, #0, #1
502 ; CHECK-NEXT: ptrue p1.b
503 ; CHECK-NEXT: mov z1.b, w8
504 ; CHECK-NEXT: mov w8, wzr
505 ; CHECK-NEXT: cmpeq p2.b, p1/z, z0.b, z1.b
506 ; CHECK-NEXT: mov z0.b, p0/z, #1 // =0x1
507 ; CHECK-NEXT: mov z0.b, p2/m, w8
508 ; CHECK-NEXT: and z0.b, z0.b, #0x1
509 ; CHECK-NEXT: cmpne p0.b, p1/z, z0.b, #0
511 %res = insertelement <vscale x 16 x i1> %val, i1 0, i32 4
512 ret <vscale x 16 x i1> %res
516 define <vscale x 2 x i1> @test_predicate_insert_2xi1(<vscale x 2 x i1> %val, i1 %elt, i32 %idx) {
517 ; CHECK-LABEL: test_predicate_insert_2xi1:
519 ; CHECK-NEXT: index z0.d, #0, #1
520 ; CHECK-NEXT: mov w8, w1
521 ; CHECK-NEXT: ptrue p1.d
522 ; CHECK-NEXT: mov z1.d, x8
523 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
524 ; CHECK-NEXT: cmpeq p2.d, p1/z, z0.d, z1.d
525 ; CHECK-NEXT: mov z0.d, p0/z, #1 // =0x1
526 ; CHECK-NEXT: mov z0.d, p2/m, x0
527 ; CHECK-NEXT: and z0.d, z0.d, #0x1
528 ; CHECK-NEXT: cmpne p0.d, p1/z, z0.d, #0
530 %res = insertelement <vscale x 2 x i1> %val, i1 %elt, i32 %idx
531 ret <vscale x 2 x i1> %res
534 define <vscale x 4 x i1> @test_predicate_insert_4xi1(<vscale x 4 x i1> %val, i1 %elt, i32 %idx) {
535 ; CHECK-LABEL: test_predicate_insert_4xi1:
537 ; CHECK-NEXT: index z0.s, #0, #1
538 ; CHECK-NEXT: mov w8, w1
539 ; CHECK-NEXT: ptrue p1.s
540 ; CHECK-NEXT: mov z1.s, w8
541 ; CHECK-NEXT: cmpeq p2.s, p1/z, z0.s, z1.s
542 ; CHECK-NEXT: mov z0.s, p0/z, #1 // =0x1
543 ; CHECK-NEXT: mov z0.s, p2/m, w0
544 ; CHECK-NEXT: and z0.s, z0.s, #0x1
545 ; CHECK-NEXT: cmpne p0.s, p1/z, z0.s, #0
547 %res = insertelement <vscale x 4 x i1> %val, i1 %elt, i32 %idx
548 ret <vscale x 4 x i1> %res
550 define <vscale x 8 x i1> @test_predicate_insert_8xi1(<vscale x 8 x i1> %val, i1 %elt, i32 %idx) {
551 ; CHECK-LABEL: test_predicate_insert_8xi1:
553 ; CHECK-NEXT: index z0.h, #0, #1
554 ; CHECK-NEXT: mov w8, w1
555 ; CHECK-NEXT: ptrue p1.h
556 ; CHECK-NEXT: mov z1.h, w8
557 ; CHECK-NEXT: cmpeq p2.h, p1/z, z0.h, z1.h
558 ; CHECK-NEXT: mov z0.h, p0/z, #1 // =0x1
559 ; CHECK-NEXT: mov z0.h, p2/m, w0
560 ; CHECK-NEXT: and z0.h, z0.h, #0x1
561 ; CHECK-NEXT: cmpne p0.h, p1/z, z0.h, #0
563 %res = insertelement <vscale x 8 x i1> %val, i1 %elt, i32 %idx
564 ret <vscale x 8 x i1> %res
567 define <vscale x 16 x i1> @test_predicate_insert_16xi1(<vscale x 16 x i1> %val, i1 %elt, i32 %idx) {
568 ; CHECK-LABEL: test_predicate_insert_16xi1:
570 ; CHECK-NEXT: index z0.b, #0, #1
571 ; CHECK-NEXT: mov w8, w1
572 ; CHECK-NEXT: ptrue p1.b
573 ; CHECK-NEXT: mov z1.b, w8
574 ; CHECK-NEXT: cmpeq p2.b, p1/z, z0.b, z1.b
575 ; CHECK-NEXT: mov z0.b, p0/z, #1 // =0x1
576 ; CHECK-NEXT: mov z0.b, p2/m, w0
577 ; CHECK-NEXT: and z0.b, z0.b, #0x1
578 ; CHECK-NEXT: cmpne p0.b, p1/z, z0.b, #0
580 %res = insertelement <vscale x 16 x i1> %val, i1 %elt, i32 %idx
581 ret <vscale x 16 x i1> %res
584 define <vscale x 32 x i1> @test_predicate_insert_32xi1(<vscale x 32 x i1> %val, i1 %elt, i32 %idx) uwtable {
585 ; CHECK-LABEL: test_predicate_insert_32xi1:
587 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
588 ; CHECK-NEXT: .cfi_def_cfa_offset 16
589 ; CHECK-NEXT: .cfi_offset w29, -16
590 ; CHECK-NEXT: addvl sp, sp, #-2
591 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
592 ; CHECK-NEXT: rdvl x8, #2
593 ; CHECK-NEXT: mov z0.b, p1/z, #1 // =0x1
594 ; CHECK-NEXT: mov z1.b, p0/z, #1 // =0x1
595 ; CHECK-NEXT: sub x8, x8, #1
596 ; CHECK-NEXT: mov w9, w1
597 ; CHECK-NEXT: ptrue p1.b
598 ; CHECK-NEXT: cmp x9, x8
599 ; CHECK-NEXT: csel x8, x9, x8, lo
600 ; CHECK-NEXT: mov x9, sp
601 ; CHECK-NEXT: st1b { z0.b }, p1, [sp, #1, mul vl]
602 ; CHECK-NEXT: st1b { z1.b }, p1, [sp]
603 ; CHECK-NEXT: strb w0, [x9, x8]
604 ; CHECK-NEXT: ld1b { z0.b }, p1/z, [sp]
605 ; CHECK-NEXT: ld1b { z1.b }, p1/z, [sp, #1, mul vl]
606 ; CHECK-NEXT: and z0.b, z0.b, #0x1
607 ; CHECK-NEXT: and z1.b, z1.b, #0x1
608 ; CHECK-NEXT: cmpne p0.b, p1/z, z0.b, #0
609 ; CHECK-NEXT: cmpne p1.b, p1/z, z1.b, #0
610 ; CHECK-NEXT: addvl sp, sp, #2
611 ; CHECK-NEXT: .cfi_def_cfa wsp, 16
612 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
613 ; CHECK-NEXT: .cfi_def_cfa_offset 0
614 ; CHECK-NEXT: .cfi_restore w29
616 %res = insertelement <vscale x 32 x i1> %val, i1 %elt, i32 %idx
617 ret <vscale x 32 x i1> %res