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: ptrue p0.b
26 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
27 ; CHECK-NEXT: mov w9, w0
28 ; CHECK-NEXT: addvl x8, x8, #2
29 ; CHECK-NEXT: cmp x9, x8
30 ; CHECK-NEXT: csel x8, x9, x8, lo
31 ; CHECK-NEXT: mov x9, sp
32 ; CHECK-NEXT: st1b { z1.b }, p0, [sp, #1, mul vl]
33 ; CHECK-NEXT: st1b { z0.b }, p0, [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: ptrue p0.h
50 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
51 ; CHECK-NEXT: mov w9, w0
52 ; CHECK-NEXT: addvl x8, x8, #1
53 ; CHECK-NEXT: cmp x9, x8
54 ; CHECK-NEXT: csel x8, x9, x8, lo
55 ; CHECK-NEXT: mov x9, sp
56 ; CHECK-NEXT: st1h { z1.h }, p0, [sp, #1, mul vl]
57 ; CHECK-NEXT: st1h { z0.h }, p0, [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
73 ; 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: csel x8, x9, x8, lo
79 ; CHECK-NEXT: mov x9, sp
80 ; CHECK-NEXT: st1w { z1.s }, p0, [sp, #1, mul vl]
81 ; CHECK-NEXT: st1w { z0.s }, p0, [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
97 ; 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: csel x8, x9, x8, lo
103 ; CHECK-NEXT: mov x9, sp
104 ; CHECK-NEXT: st1d { z3.d }, p0, [sp, #3, mul vl]
105 ; CHECK-NEXT: st1d { z2.d }, p0, [sp, #2, mul vl]
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: ptrue p0.h
144 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
145 ; CHECK-NEXT: mov w9, #128 // =0x80
146 ; CHECK-NEXT: addvl x8, x8, #1
147 ; CHECK-NEXT: cmp x8, #128
148 ; CHECK-NEXT: csel x8, x8, x9, lo
149 ; CHECK-NEXT: mov x9, sp
150 ; CHECK-NEXT: st1h { z1.h }, p0, [sp, #1, mul vl]
151 ; CHECK-NEXT: st1h { z0.h }, p0, [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: ptrue p0.s
168 ; CHECK-NEXT: mov x8, #-1 // =0xffffffffffffffff
169 ; CHECK-NEXT: mov w9, #34464 // =0x86a0
170 ; CHECK-NEXT: movk w9, #1, lsl #16
171 ; CHECK-NEXT: addvl x8, x8, #1
172 ; CHECK-NEXT: cmp x8, x9
173 ; CHECK-NEXT: csel x8, x8, x9, lo
174 ; CHECK-NEXT: mov x9, sp
175 ; CHECK-NEXT: st1w { z3.s }, p0, [sp, #3, mul vl]
176 ; CHECK-NEXT: st1w { z2.s }, p0, [sp, #2, mul vl]
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: ptrue p0.d
195 ; CHECK-NEXT: cntw x8
196 ; CHECK-NEXT: mov w9, #10 // =0xa
197 ; CHECK-NEXT: sub x8, x8, #1
198 ; CHECK-NEXT: cmp x8, #10
199 ; CHECK-NEXT: csel x8, x8, x9, lo
200 ; CHECK-NEXT: mov x9, sp
201 ; CHECK-NEXT: st1d { z1.d }, p0, [sp, #1, mul vl]
202 ; CHECK-NEXT: st1d { z0.d }, p0, [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