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 i32 @promote_extract_2i32_idx(<vscale x 2 x i32> %a, i32 %idx) {
7 ; CHECK-LABEL: promote_extract_2i32_idx:
9 ; CHECK-NEXT: mov w8, w0
10 ; CHECK-NEXT: whilels p0.d, xzr, x8
11 ; CHECK-NEXT: lastb x0, p0, z0.d
12 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
14 %ext = extractelement <vscale x 2 x i32> %a, i32 %idx
18 define i8 @split_extract_32i8_idx(<vscale x 32 x i8> %a, i32 %idx) {
19 ; CHECK-LABEL: split_extract_32i8_idx:
21 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
22 ; CHECK-NEXT: addvl sp, sp, #-2
23 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
24 ; CHECK-NEXT: .cfi_offset w29, -16
25 ; CHECK-NEXT: rdvl x8, #2
26 ; CHECK-NEXT: ptrue p0.b
27 ; CHECK-NEXT: mov w9, w0
28 ; CHECK-NEXT: sub x8, x8, #1
29 ; CHECK-NEXT: cmp x9, x8
30 ; CHECK-NEXT: st1b { z1.b }, p0, [sp, #1, mul vl]
31 ; CHECK-NEXT: st1b { z0.b }, p0, [sp]
32 ; CHECK-NEXT: csel x8, x9, x8, lo
33 ; CHECK-NEXT: mov x9, sp
34 ; CHECK-NEXT: ldrb w0, [x9, x8]
35 ; CHECK-NEXT: addvl sp, sp, #2
36 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
38 %ext = extractelement <vscale x 32 x i8> %a, i32 %idx
42 define i16 @split_extract_16i16_idx(<vscale x 16 x i16> %a, i32 %idx) {
43 ; CHECK-LABEL: split_extract_16i16_idx:
45 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
46 ; CHECK-NEXT: addvl sp, sp, #-2
47 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
48 ; CHECK-NEXT: .cfi_offset w29, -16
49 ; CHECK-NEXT: rdvl x8, #1
50 ; CHECK-NEXT: ptrue p0.h
51 ; CHECK-NEXT: mov w9, w0
52 ; CHECK-NEXT: sub x8, x8, #1
53 ; CHECK-NEXT: cmp x9, x8
54 ; CHECK-NEXT: st1h { z1.h }, p0, [sp, #1, mul vl]
55 ; CHECK-NEXT: st1h { z0.h }, p0, [sp]
56 ; CHECK-NEXT: csel x8, x9, x8, lo
57 ; CHECK-NEXT: mov x9, sp
58 ; CHECK-NEXT: ldrh w0, [x9, x8, lsl #1]
59 ; CHECK-NEXT: addvl sp, sp, #2
60 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
62 %ext = extractelement <vscale x 16 x i16> %a, i32 %idx
66 define i32 @split_extract_8i32_idx(<vscale x 8 x i32> %a, i32 %idx) {
67 ; CHECK-LABEL: split_extract_8i32_idx:
69 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
70 ; CHECK-NEXT: addvl sp, sp, #-2
71 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
72 ; CHECK-NEXT: .cfi_offset w29, -16
74 ; CHECK-NEXT: ptrue p0.s
75 ; CHECK-NEXT: mov w9, w0
76 ; CHECK-NEXT: sub x8, x8, #1
77 ; CHECK-NEXT: cmp x9, x8
78 ; CHECK-NEXT: st1w { z1.s }, p0, [sp, #1, mul vl]
79 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
80 ; CHECK-NEXT: csel x8, x9, x8, lo
81 ; CHECK-NEXT: mov x9, sp
82 ; CHECK-NEXT: ldr w0, [x9, x8, lsl #2]
83 ; CHECK-NEXT: addvl sp, sp, #2
84 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
86 %ext = extractelement <vscale x 8 x i32> %a, i32 %idx
90 define i64 @split_extract_8i64_idx(<vscale x 8 x i64> %a, i32 %idx) {
91 ; CHECK-LABEL: split_extract_8i64_idx:
93 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
94 ; CHECK-NEXT: addvl sp, sp, #-4
95 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
96 ; CHECK-NEXT: .cfi_offset w29, -16
98 ; CHECK-NEXT: ptrue p0.d
99 ; CHECK-NEXT: mov w9, w0
100 ; CHECK-NEXT: sub x8, x8, #1
101 ; CHECK-NEXT: cmp x9, x8
102 ; CHECK-NEXT: st1d { z3.d }, p0, [sp, #3, mul vl]
103 ; CHECK-NEXT: st1d { z2.d }, p0, [sp, #2, mul vl]
104 ; CHECK-NEXT: csel x8, x9, x8, lo
105 ; CHECK-NEXT: mov x9, sp
106 ; CHECK-NEXT: st1d { z1.d }, p0, [sp, #1, mul vl]
107 ; CHECK-NEXT: st1d { z0.d }, p0, [sp]
108 ; CHECK-NEXT: ldr x0, [x9, x8, lsl #3]
109 ; CHECK-NEXT: addvl sp, sp, #4
110 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
112 %ext = extractelement <vscale x 8 x i64> %a, i32 %idx
116 ; EXTRACT VECTOR ELT, CONSTANT IDX
118 define i16 @promote_extract_4i16(<vscale x 4 x i16> %a) {
119 ; CHECK-LABEL: promote_extract_4i16:
121 ; CHECK-NEXT: mov w0, v0.s[1]
123 %ext = extractelement <vscale x 4 x i16> %a, i32 1
127 define i8 @split_extract_32i8(<vscale x 32 x i8> %a) {
128 ; CHECK-LABEL: split_extract_32i8:
130 ; CHECK-NEXT: umov w0, v0.b[3]
132 %ext = extractelement <vscale x 32 x i8> %a, i32 3
136 define i16 @split_extract_16i16(<vscale x 16 x i16> %a) {
137 ; CHECK-LABEL: split_extract_16i16:
139 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
140 ; CHECK-NEXT: addvl sp, sp, #-2
141 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
142 ; CHECK-NEXT: .cfi_offset w29, -16
143 ; CHECK-NEXT: rdvl x8, #1
144 ; CHECK-NEXT: ptrue p0.h
145 ; CHECK-NEXT: mov w9, #128 // =0x80
146 ; CHECK-NEXT: sub x8, x8, #1
147 ; CHECK-NEXT: cmp x8, #128
148 ; CHECK-NEXT: st1h { z1.h }, p0, [sp, #1, mul vl]
149 ; CHECK-NEXT: st1h { z0.h }, p0, [sp]
150 ; CHECK-NEXT: csel x8, x8, x9, lo
151 ; CHECK-NEXT: mov x9, sp
152 ; CHECK-NEXT: ldrh w0, [x9, x8, lsl #1]
153 ; CHECK-NEXT: addvl sp, sp, #2
154 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
156 %ext = extractelement <vscale x 16 x i16> %a, i32 128
160 define i32 @split_extract_16i32(<vscale x 16 x i32> %a) {
161 ; CHECK-LABEL: split_extract_16i32:
163 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
164 ; CHECK-NEXT: addvl sp, sp, #-4
165 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
166 ; CHECK-NEXT: .cfi_offset w29, -16
167 ; CHECK-NEXT: rdvl x8, #1
168 ; CHECK-NEXT: mov w9, #34464 // =0x86a0
169 ; CHECK-NEXT: ptrue p0.s
170 ; CHECK-NEXT: movk w9, #1, lsl #16
171 ; CHECK-NEXT: sub x8, x8, #1
172 ; CHECK-NEXT: cmp x8, x9
173 ; CHECK-NEXT: st1w { z3.s }, p0, [sp, #3, mul vl]
174 ; CHECK-NEXT: st1w { z2.s }, p0, [sp, #2, mul vl]
175 ; CHECK-NEXT: csel x8, x8, x9, lo
176 ; CHECK-NEXT: mov x9, sp
177 ; CHECK-NEXT: st1w { z1.s }, p0, [sp, #1, mul vl]
178 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
179 ; CHECK-NEXT: ldr w0, [x9, x8, lsl #2]
180 ; CHECK-NEXT: addvl sp, sp, #4
181 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
183 %ext = extractelement <vscale x 16 x i32> %a, i32 100000
187 define i64 @split_extract_4i64(<vscale x 4 x i64> %a) {
188 ; CHECK-LABEL: split_extract_4i64:
190 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
191 ; CHECK-NEXT: addvl sp, sp, #-2
192 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
193 ; CHECK-NEXT: .cfi_offset w29, -16
194 ; CHECK-NEXT: cntw x8
195 ; CHECK-NEXT: ptrue p0.d
196 ; CHECK-NEXT: mov w9, #10 // =0xa
197 ; CHECK-NEXT: sub x8, x8, #1
198 ; CHECK-NEXT: cmp x8, #10
199 ; CHECK-NEXT: st1d { z1.d }, p0, [sp, #1, mul vl]
200 ; CHECK-NEXT: st1d { z0.d }, p0, [sp]
201 ; CHECK-NEXT: csel x8, x8, x9, lo
202 ; CHECK-NEXT: mov x9, sp
203 ; CHECK-NEXT: ldr x0, [x9, x8, lsl #3]
204 ; CHECK-NEXT: addvl sp, sp, #2
205 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
207 %ext = extractelement <vscale x 4 x i64> %a, i32 10