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 i8> @promote_insert_8i8(<vscale x 8 x i8> %a, i8 %elt, i64 %idx) {
7 ; CHECK-LABEL: promote_insert_8i8:
9 ; CHECK-NEXT: index z1.h, #0, #1
10 ; CHECK-NEXT: mov z2.h, w1
11 ; CHECK-NEXT: ptrue p0.h
12 ; CHECK-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
13 ; CHECK-NEXT: mov z0.h, p0/m, w0
15 %ins = insertelement <vscale x 8 x i8> %a, i8 %elt, i64 %idx
16 ret <vscale x 8 x i8> %ins
19 define <vscale x 32 x i8> @split_insert_32i8_idx(<vscale x 32 x i8> %a, i8 %elt, i64 %idx) {
20 ; CHECK-LABEL: split_insert_32i8_idx:
22 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
23 ; CHECK-NEXT: addvl sp, sp, #-2
24 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
25 ; CHECK-NEXT: .cfi_offset w29, -16
26 ; CHECK-NEXT: rdvl x8, #2
27 ; CHECK-NEXT: ptrue p0.b
28 ; CHECK-NEXT: mov x9, sp
29 ; CHECK-NEXT: sub x8, x8, #1
30 ; CHECK-NEXT: cmp x1, x8
31 ; CHECK-NEXT: st1b { z1.b }, p0, [sp, #1, mul vl]
32 ; CHECK-NEXT: csel x8, x1, x8, lo
33 ; CHECK-NEXT: st1b { z0.b }, p0, [sp]
34 ; CHECK-NEXT: strb w0, [x9, x8]
35 ; CHECK-NEXT: ld1b { z0.b }, p0/z, [sp]
36 ; CHECK-NEXT: ld1b { z1.b }, p0/z, [sp, #1, mul vl]
37 ; CHECK-NEXT: addvl sp, sp, #2
38 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
40 %ins = insertelement <vscale x 32 x i8> %a, i8 %elt, i64 %idx
41 ret <vscale x 32 x i8> %ins
44 define <vscale x 8 x float> @split_insert_8f32_idx(<vscale x 8 x float> %a, float %elt, i64 %idx) {
45 ; CHECK-LABEL: split_insert_8f32_idx:
47 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
48 ; CHECK-NEXT: addvl sp, sp, #-2
49 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
50 ; CHECK-NEXT: .cfi_offset w29, -16
52 ; CHECK-NEXT: ptrue p0.s
53 ; CHECK-NEXT: mov x9, sp
54 ; CHECK-NEXT: sub x8, x8, #1
55 ; CHECK-NEXT: cmp x0, x8
56 ; CHECK-NEXT: st1w { z1.s }, p0, [sp, #1, mul vl]
57 ; CHECK-NEXT: csel x8, x0, x8, lo
58 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
59 ; CHECK-NEXT: str s2, [x9, x8, lsl #2]
60 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [sp]
61 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [sp, #1, mul vl]
62 ; CHECK-NEXT: addvl sp, sp, #2
63 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
65 %ins = insertelement <vscale x 8 x float> %a, float %elt, i64 %idx
66 ret <vscale x 8 x float> %ins
69 define <vscale x 8 x i64> @split_insert_8i64_idx(<vscale x 8 x i64> %a, i64 %elt, i64 %idx) {
70 ; CHECK-LABEL: split_insert_8i64_idx:
72 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
73 ; CHECK-NEXT: addvl sp, sp, #-4
74 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
75 ; CHECK-NEXT: .cfi_offset w29, -16
77 ; CHECK-NEXT: ptrue p0.d
78 ; CHECK-NEXT: mov x9, sp
79 ; CHECK-NEXT: sub x8, x8, #1
80 ; CHECK-NEXT: cmp x1, x8
81 ; CHECK-NEXT: st1d { z3.d }, p0, [sp, #3, mul vl]
82 ; CHECK-NEXT: csel x8, x1, x8, lo
83 ; CHECK-NEXT: st1d { z2.d }, p0, [sp, #2, mul vl]
84 ; CHECK-NEXT: st1d { z1.d }, p0, [sp, #1, mul vl]
85 ; CHECK-NEXT: st1d { z0.d }, p0, [sp]
86 ; CHECK-NEXT: str x0, [x9, x8, lsl #3]
87 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [sp]
88 ; CHECK-NEXT: ld1d { z1.d }, p0/z, [sp, #1, mul vl]
89 ; CHECK-NEXT: ld1d { z2.d }, p0/z, [sp, #2, mul vl]
90 ; CHECK-NEXT: ld1d { z3.d }, p0/z, [sp, #3, mul vl]
91 ; CHECK-NEXT: addvl sp, sp, #4
92 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
94 %ins = insertelement <vscale x 8 x i64> %a, i64 %elt, i64 %idx
95 ret <vscale x 8 x i64> %ins
98 ; INSERT VECTOR ELT, CONSTANT IDX
100 define <vscale x 4 x i16> @promote_insert_4i16(<vscale x 4 x i16> %a, i16 %elt) {
101 ; CHECK-LABEL: promote_insert_4i16:
103 ; CHECK-NEXT: mov w8, #5 // =0x5
104 ; CHECK-NEXT: index z1.s, #0, #1
105 ; CHECK-NEXT: ptrue p0.s
106 ; CHECK-NEXT: mov z2.s, w8
107 ; CHECK-NEXT: cmpeq p0.s, p0/z, z1.s, z2.s
108 ; CHECK-NEXT: mov z0.s, p0/m, w0
110 %ins = insertelement <vscale x 4 x i16> %a, i16 %elt, i64 5
111 ret <vscale x 4 x i16> %ins
114 ; In this test, the index is small enough that we know it will be in the
115 ; low half of the vector and there is no need to go through the stack as
116 ; done in the remaining tests
117 define <vscale x 32 x i8> @split_insert_32i8(<vscale x 32 x i8> %a, i8 %elt) {
118 ; CHECK-LABEL: split_insert_32i8:
120 ; CHECK-NEXT: mov w8, #3 // =0x3
121 ; CHECK-NEXT: index z2.b, #0, #1
122 ; CHECK-NEXT: ptrue p0.b
123 ; CHECK-NEXT: mov z3.b, w8
124 ; CHECK-NEXT: cmpeq p0.b, p0/z, z2.b, z3.b
125 ; CHECK-NEXT: mov z0.b, p0/m, w0
127 %ins = insertelement <vscale x 32 x i8> %a, i8 %elt, i64 3
128 ret <vscale x 32 x i8> %ins
131 define <vscale x 32 x i16> @split_insert_32i16(<vscale x 32 x i16> %a, i16 %elt) {
132 ; CHECK-LABEL: split_insert_32i16:
134 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
135 ; CHECK-NEXT: addvl sp, sp, #-4
136 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
137 ; CHECK-NEXT: .cfi_offset w29, -16
138 ; CHECK-NEXT: rdvl x8, #2
139 ; CHECK-NEXT: ptrue p0.h
140 ; CHECK-NEXT: mov w9, #128 // =0x80
141 ; CHECK-NEXT: sub x8, x8, #1
142 ; CHECK-NEXT: cmp x8, #128
143 ; CHECK-NEXT: st1h { z3.h }, p0, [sp, #3, mul vl]
144 ; CHECK-NEXT: csel x8, x8, x9, lo
145 ; CHECK-NEXT: mov x9, sp
146 ; CHECK-NEXT: st1h { z2.h }, p0, [sp, #2, mul vl]
147 ; CHECK-NEXT: st1h { z1.h }, p0, [sp, #1, mul vl]
148 ; CHECK-NEXT: st1h { z0.h }, p0, [sp]
149 ; CHECK-NEXT: strh w0, [x9, x8, lsl #1]
150 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [sp]
151 ; CHECK-NEXT: ld1h { z1.h }, p0/z, [sp, #1, mul vl]
152 ; CHECK-NEXT: ld1h { z2.h }, p0/z, [sp, #2, mul vl]
153 ; CHECK-NEXT: ld1h { z3.h }, p0/z, [sp, #3, mul vl]
154 ; CHECK-NEXT: addvl sp, sp, #4
155 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
157 %ins = insertelement <vscale x 32 x i16> %a, i16 %elt, i64 128
158 ret <vscale x 32 x i16> %ins
161 define <vscale x 8 x i32> @split_insert_8i32(<vscale x 8 x i32> %a, i32 %elt) {
162 ; CHECK-LABEL: split_insert_8i32:
164 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
165 ; CHECK-NEXT: addvl sp, sp, #-2
166 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
167 ; CHECK-NEXT: .cfi_offset w29, -16
168 ; CHECK-NEXT: cnth x8
169 ; CHECK-NEXT: mov w9, #16960 // =0x4240
170 ; CHECK-NEXT: ptrue p0.s
171 ; CHECK-NEXT: movk w9, #15, lsl #16
172 ; CHECK-NEXT: sub x8, x8, #1
173 ; CHECK-NEXT: cmp x8, x9
174 ; CHECK-NEXT: st1w { z1.s }, p0, [sp, #1, mul vl]
175 ; CHECK-NEXT: csel x8, x8, x9, lo
176 ; CHECK-NEXT: mov x9, sp
177 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
178 ; CHECK-NEXT: str w0, [x9, x8, lsl #2]
179 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [sp]
180 ; CHECK-NEXT: ld1w { z1.s }, p0/z, [sp, #1, mul vl]
181 ; CHECK-NEXT: addvl sp, sp, #2
182 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
184 %ins = insertelement <vscale x 8 x i32> %a, i32 %elt, i64 1000000
185 ret <vscale x 8 x i32> %ins