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: // kill: def $w0 killed $w0 def $x0
10 ; CHECK-NEXT: sxtw x8, w0
11 ; CHECK-NEXT: whilels p0.d, xzr, x8
12 ; CHECK-NEXT: lastb x0, p0, z0.d
13 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
15 %ext = extractelement <vscale x 2 x i32> %a, i32 %idx
19 define i8 @split_extract_32i8_idx(<vscale x 32 x i8> %a, i32 %idx) {
20 ; CHECK-LABEL: split_extract_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 x10, #2
27 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
28 ; CHECK-NEXT: sxtw x9, w0
29 ; CHECK-NEXT: sub x10, x10, #1
30 ; CHECK-NEXT: ptrue p0.b
31 ; CHECK-NEXT: mov x8, sp
32 ; CHECK-NEXT: cmp x9, x10
33 ; CHECK-NEXT: st1b { z1.b }, p0, [x8, #1, mul vl]
34 ; CHECK-NEXT: st1b { z0.b }, p0, [sp]
35 ; CHECK-NEXT: csel x9, x9, x10, lo
36 ; CHECK-NEXT: ldrb w0, [x8, x9]
37 ; CHECK-NEXT: addvl sp, sp, #2
38 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
40 %ext = extractelement <vscale x 32 x i8> %a, i32 %idx
44 define i16 @split_extract_16i16_idx(<vscale x 16 x i16> %a, i32 %idx) {
45 ; CHECK-LABEL: split_extract_16i16_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
51 ; CHECK-NEXT: rdvl x10, #1
52 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
53 ; CHECK-NEXT: sxtw x9, w0
54 ; CHECK-NEXT: sub x10, x10, #1
55 ; CHECK-NEXT: ptrue p0.h
56 ; CHECK-NEXT: mov x8, sp
57 ; CHECK-NEXT: cmp x9, x10
58 ; CHECK-NEXT: st1h { z1.h }, p0, [x8, #1, mul vl]
59 ; CHECK-NEXT: st1h { z0.h }, p0, [sp]
60 ; CHECK-NEXT: csel x9, x9, x10, lo
61 ; CHECK-NEXT: ldrh w0, [x8, x9, lsl #1]
62 ; CHECK-NEXT: addvl sp, sp, #2
63 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
65 %ext = extractelement <vscale x 16 x i16> %a, i32 %idx
69 define i32 @split_extract_8i32_idx(<vscale x 8 x i32> %a, i32 %idx) {
70 ; CHECK-LABEL: split_extract_8i32_idx:
72 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
73 ; CHECK-NEXT: addvl sp, sp, #-2
74 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
75 ; CHECK-NEXT: .cfi_offset w29, -16
76 ; CHECK-NEXT: cnth x10
77 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
78 ; CHECK-NEXT: sxtw x9, w0
79 ; CHECK-NEXT: sub x10, x10, #1
80 ; CHECK-NEXT: ptrue p0.s
81 ; CHECK-NEXT: mov x8, sp
82 ; CHECK-NEXT: cmp x9, x10
83 ; CHECK-NEXT: st1w { z1.s }, p0, [x8, #1, mul vl]
84 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
85 ; CHECK-NEXT: csel x9, x9, x10, lo
86 ; CHECK-NEXT: ldr w0, [x8, x9, lsl #2]
87 ; CHECK-NEXT: addvl sp, sp, #2
88 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
90 %ext = extractelement <vscale x 8 x i32> %a, i32 %idx
94 define i64 @split_extract_8i64_idx(<vscale x 8 x i64> %a, i32 %idx) {
95 ; CHECK-LABEL: split_extract_8i64_idx:
97 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
98 ; CHECK-NEXT: addvl sp, sp, #-4
99 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
100 ; CHECK-NEXT: .cfi_offset w29, -16
101 ; CHECK-NEXT: cnth x10
102 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
103 ; CHECK-NEXT: sxtw x9, w0
104 ; CHECK-NEXT: sub x10, x10, #1
105 ; CHECK-NEXT: ptrue p0.d
106 ; CHECK-NEXT: mov x8, sp
107 ; CHECK-NEXT: cmp x9, x10
108 ; CHECK-NEXT: st1d { z3.d }, p0, [x8, #3, mul vl]
109 ; CHECK-NEXT: st1d { z2.d }, p0, [x8, #2, mul vl]
110 ; CHECK-NEXT: st1d { z1.d }, p0, [x8, #1, mul vl]
111 ; CHECK-NEXT: st1d { z0.d }, p0, [sp]
112 ; CHECK-NEXT: csel x9, x9, x10, lo
113 ; CHECK-NEXT: ldr x0, [x8, x9, lsl #3]
114 ; CHECK-NEXT: addvl sp, sp, #4
115 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
117 %ext = extractelement <vscale x 8 x i64> %a, i32 %idx
121 ; EXTRACT VECTOR ELT, CONSTANT IDX
123 define i16 @promote_extract_4i16(<vscale x 4 x i16> %a) {
124 ; CHECK-LABEL: promote_extract_4i16:
126 ; CHECK-NEXT: mov w0, v0.s[1]
128 %ext = extractelement <vscale x 4 x i16> %a, i32 1
132 define i8 @split_extract_32i8(<vscale x 32 x i8> %a) {
133 ; CHECK-LABEL: split_extract_32i8:
135 ; CHECK-NEXT: umov w0, v0.b[3]
137 %ext = extractelement <vscale x 32 x i8> %a, i32 3
141 define i16 @split_extract_16i16(<vscale x 16 x i16> %a) {
142 ; CHECK-LABEL: split_extract_16i16:
144 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
145 ; CHECK-NEXT: addvl sp, sp, #-2
146 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
147 ; CHECK-NEXT: .cfi_offset w29, -16
148 ; CHECK-NEXT: rdvl x10, #1
149 ; CHECK-NEXT: sub x10, x10, #1
150 ; CHECK-NEXT: ptrue p0.h
151 ; CHECK-NEXT: mov x8, sp
152 ; CHECK-NEXT: mov w9, #128
153 ; CHECK-NEXT: cmp x10, #128
154 ; CHECK-NEXT: st1h { z1.h }, p0, [x8, #1, mul vl]
155 ; CHECK-NEXT: st1h { z0.h }, p0, [sp]
156 ; CHECK-NEXT: csel x9, x10, x9, lo
157 ; CHECK-NEXT: ldrh w0, [x8, x9, lsl #1]
158 ; CHECK-NEXT: addvl sp, sp, #2
159 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
161 %ext = extractelement <vscale x 16 x i16> %a, i32 128
165 define i32 @split_extract_16i32(<vscale x 16 x i32> %a) {
166 ; CHECK-LABEL: split_extract_16i32:
168 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
169 ; CHECK-NEXT: addvl sp, sp, #-4
170 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x20, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 32 * VG
171 ; CHECK-NEXT: .cfi_offset w29, -16
172 ; CHECK-NEXT: mov w9, #34464
173 ; CHECK-NEXT: rdvl x10, #1
174 ; CHECK-NEXT: movk w9, #1, lsl #16
175 ; CHECK-NEXT: sub x10, x10, #1
176 ; CHECK-NEXT: ptrue p0.s
177 ; CHECK-NEXT: mov x8, sp
178 ; CHECK-NEXT: cmp x10, x9
179 ; CHECK-NEXT: st1w { z3.s }, p0, [x8, #3, mul vl]
180 ; CHECK-NEXT: st1w { z2.s }, p0, [x8, #2, mul vl]
181 ; CHECK-NEXT: st1w { z1.s }, p0, [x8, #1, mul vl]
182 ; CHECK-NEXT: st1w { z0.s }, p0, [sp]
183 ; CHECK-NEXT: csel x9, x10, x9, lo
184 ; CHECK-NEXT: ldr w0, [x8, x9, lsl #2]
185 ; CHECK-NEXT: addvl sp, sp, #4
186 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
188 %ext = extractelement <vscale x 16 x i32> %a, i32 100000
192 define i64 @split_extract_4i64(<vscale x 4 x i64> %a) {
193 ; CHECK-LABEL: split_extract_4i64:
195 ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
196 ; CHECK-NEXT: addvl sp, sp, #-2
197 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x10, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 16 * VG
198 ; CHECK-NEXT: .cfi_offset w29, -16
199 ; CHECK-NEXT: cntw x10
200 ; CHECK-NEXT: sub x10, x10, #1
201 ; CHECK-NEXT: ptrue p0.d
202 ; CHECK-NEXT: mov x8, sp
203 ; CHECK-NEXT: mov w9, #10
204 ; CHECK-NEXT: cmp x10, #10
205 ; CHECK-NEXT: st1d { z1.d }, p0, [x8, #1, mul vl]
206 ; CHECK-NEXT: st1d { z0.d }, p0, [sp]
207 ; CHECK-NEXT: csel x9, x10, x9, lo
208 ; CHECK-NEXT: ldr x0, [x8, x9, lsl #3]
209 ; CHECK-NEXT: addvl sp, sp, #2
210 ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
212 %ext = extractelement <vscale x 4 x i64> %a, i32 10