1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
5 define i1 @extractelt_nxv1i1(<vscale x 1 x i8>* %x, i64 %idx) nounwind {
6 ; CHECK-LABEL: extractelt_nxv1i1:
8 ; CHECK-NEXT: vsetvli a2, zero, e8, mf8, ta, ma
9 ; CHECK-NEXT: vle8.v v8, (a0)
10 ; CHECK-NEXT: vmseq.vi v0, v8, 0
11 ; CHECK-NEXT: vmv.v.i v8, 0
12 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
13 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
14 ; CHECK-NEXT: vmv.x.s a0, v8
16 %a = load <vscale x 1 x i8>, <vscale x 1 x i8>* %x
17 %b = icmp eq <vscale x 1 x i8> %a, zeroinitializer
18 %c = extractelement <vscale x 1 x i1> %b, i64 %idx
22 define i1 @extractelt_nxv2i1(<vscale x 2 x i8>* %x, i64 %idx) nounwind {
23 ; CHECK-LABEL: extractelt_nxv2i1:
25 ; CHECK-NEXT: vsetvli a2, zero, e8, mf4, ta, ma
26 ; CHECK-NEXT: vle8.v v8, (a0)
27 ; CHECK-NEXT: vmseq.vi v0, v8, 0
28 ; CHECK-NEXT: vmv.v.i v8, 0
29 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
30 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
31 ; CHECK-NEXT: vmv.x.s a0, v8
33 %a = load <vscale x 2 x i8>, <vscale x 2 x i8>* %x
34 %b = icmp eq <vscale x 2 x i8> %a, zeroinitializer
35 %c = extractelement <vscale x 2 x i1> %b, i64 %idx
39 define i1 @extractelt_nxv4i1(<vscale x 4 x i8>* %x, i64 %idx) nounwind {
40 ; CHECK-LABEL: extractelt_nxv4i1:
42 ; CHECK-NEXT: vsetvli a2, zero, e8, mf2, ta, ma
43 ; CHECK-NEXT: vle8.v v8, (a0)
44 ; CHECK-NEXT: vmseq.vi v0, v8, 0
45 ; CHECK-NEXT: vmv.v.i v8, 0
46 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
47 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
48 ; CHECK-NEXT: vmv.x.s a0, v8
50 %a = load <vscale x 4 x i8>, <vscale x 4 x i8>* %x
51 %b = icmp eq <vscale x 4 x i8> %a, zeroinitializer
52 %c = extractelement <vscale x 4 x i1> %b, i64 %idx
56 define i1 @extractelt_nxv8i1(<vscale x 8 x i8>* %x, i64 %idx) nounwind {
57 ; CHECK-LABEL: extractelt_nxv8i1:
59 ; CHECK-NEXT: vl1r.v v8, (a0)
60 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
61 ; CHECK-NEXT: vmseq.vi v0, v8, 0
62 ; CHECK-NEXT: vmv.v.i v8, 0
63 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
64 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
65 ; CHECK-NEXT: vmv.x.s a0, v8
67 %a = load <vscale x 8 x i8>, <vscale x 8 x i8>* %x
68 %b = icmp eq <vscale x 8 x i8> %a, zeroinitializer
69 %c = extractelement <vscale x 8 x i1> %b, i64 %idx
73 define i1 @extractelt_nxv16i1(<vscale x 16 x i8>* %x, i64 %idx) nounwind {
74 ; CHECK-LABEL: extractelt_nxv16i1:
76 ; CHECK-NEXT: vl2r.v v8, (a0)
77 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
78 ; CHECK-NEXT: vmseq.vi v0, v8, 0
79 ; CHECK-NEXT: vmv.v.i v8, 0
80 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
81 ; CHECK-NEXT: vsetivli zero, 1, e8, m2, ta, ma
82 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
83 ; CHECK-NEXT: vmv.x.s a0, v8
85 %a = load <vscale x 16 x i8>, <vscale x 16 x i8>* %x
86 %b = icmp eq <vscale x 16 x i8> %a, zeroinitializer
87 %c = extractelement <vscale x 16 x i1> %b, i64 %idx
91 define i1 @extractelt_nxv32i1(<vscale x 32 x i8>* %x, i64 %idx) nounwind {
92 ; CHECK-LABEL: extractelt_nxv32i1:
94 ; CHECK-NEXT: vl4r.v v8, (a0)
95 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
96 ; CHECK-NEXT: vmseq.vi v0, v8, 0
97 ; CHECK-NEXT: vmv.v.i v8, 0
98 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
99 ; CHECK-NEXT: vsetivli zero, 1, e8, m4, ta, ma
100 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
101 ; CHECK-NEXT: vmv.x.s a0, v8
103 %a = load <vscale x 32 x i8>, <vscale x 32 x i8>* %x
104 %b = icmp eq <vscale x 32 x i8> %a, zeroinitializer
105 %c = extractelement <vscale x 32 x i1> %b, i64 %idx
109 define i1 @extractelt_nxv64i1(<vscale x 64 x i8>* %x, i64 %idx) nounwind {
110 ; CHECK-LABEL: extractelt_nxv64i1:
112 ; CHECK-NEXT: vl8r.v v8, (a0)
113 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
114 ; CHECK-NEXT: vmseq.vi v0, v8, 0
115 ; CHECK-NEXT: vmv.v.i v8, 0
116 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
117 ; CHECK-NEXT: vsetivli zero, 1, e8, m8, ta, ma
118 ; CHECK-NEXT: vslidedown.vx v8, v8, a1
119 ; CHECK-NEXT: vmv.x.s a0, v8
121 %a = load <vscale x 64 x i8>, <vscale x 64 x i8>* %x
122 %b = icmp eq <vscale x 64 x i8> %a, zeroinitializer
123 %c = extractelement <vscale x 64 x i1> %b, i64 %idx
127 define i1 @extractelt_nxv128i1(<vscale x 128 x i8>* %x, i64 %idx) nounwind {
128 ; RV32-LABEL: extractelt_nxv128i1:
130 ; RV32-NEXT: csrr a2, vlenb
131 ; RV32-NEXT: slli a3, a2, 4
132 ; RV32-NEXT: addi a3, a3, -1
133 ; RV32-NEXT: bltu a1, a3, .LBB7_2
134 ; RV32-NEXT: # %bb.1:
135 ; RV32-NEXT: mv a1, a3
136 ; RV32-NEXT: .LBB7_2:
137 ; RV32-NEXT: addi sp, sp, -80
138 ; RV32-NEXT: sw ra, 76(sp) # 4-byte Folded Spill
139 ; RV32-NEXT: sw s0, 72(sp) # 4-byte Folded Spill
140 ; RV32-NEXT: addi s0, sp, 80
141 ; RV32-NEXT: csrr a3, vlenb
142 ; RV32-NEXT: slli a3, a3, 4
143 ; RV32-NEXT: sub sp, sp, a3
144 ; RV32-NEXT: andi sp, sp, -64
145 ; RV32-NEXT: addi a3, sp, 64
146 ; RV32-NEXT: slli a2, a2, 3
147 ; RV32-NEXT: add a4, a0, a2
148 ; RV32-NEXT: vl8r.v v16, (a4)
149 ; RV32-NEXT: vl8r.v v24, (a0)
150 ; RV32-NEXT: add a1, a3, a1
151 ; RV32-NEXT: vsetvli a0, zero, e8, m8, ta, ma
152 ; RV32-NEXT: vmseq.vi v8, v16, 0
153 ; RV32-NEXT: vmseq.vi v0, v24, 0
154 ; RV32-NEXT: vmv.v.i v16, 0
155 ; RV32-NEXT: vmerge.vim v24, v16, 1, v0
156 ; RV32-NEXT: vs8r.v v24, (a3)
157 ; RV32-NEXT: add a2, a3, a2
158 ; RV32-NEXT: vmv1r.v v0, v8
159 ; RV32-NEXT: vmerge.vim v8, v16, 1, v0
160 ; RV32-NEXT: vs8r.v v8, (a2)
161 ; RV32-NEXT: lbu a0, 0(a1)
162 ; RV32-NEXT: addi sp, s0, -80
163 ; RV32-NEXT: lw ra, 76(sp) # 4-byte Folded Reload
164 ; RV32-NEXT: lw s0, 72(sp) # 4-byte Folded Reload
165 ; RV32-NEXT: addi sp, sp, 80
168 ; RV64-LABEL: extractelt_nxv128i1:
170 ; RV64-NEXT: csrr a2, vlenb
171 ; RV64-NEXT: slli a3, a2, 4
172 ; RV64-NEXT: addi a3, a3, -1
173 ; RV64-NEXT: bltu a1, a3, .LBB7_2
174 ; RV64-NEXT: # %bb.1:
175 ; RV64-NEXT: mv a1, a3
176 ; RV64-NEXT: .LBB7_2:
177 ; RV64-NEXT: addi sp, sp, -80
178 ; RV64-NEXT: sd ra, 72(sp) # 8-byte Folded Spill
179 ; RV64-NEXT: sd s0, 64(sp) # 8-byte Folded Spill
180 ; RV64-NEXT: addi s0, sp, 80
181 ; RV64-NEXT: csrr a3, vlenb
182 ; RV64-NEXT: slli a3, a3, 4
183 ; RV64-NEXT: sub sp, sp, a3
184 ; RV64-NEXT: andi sp, sp, -64
185 ; RV64-NEXT: addi a3, sp, 64
186 ; RV64-NEXT: slli a2, a2, 3
187 ; RV64-NEXT: add a4, a0, a2
188 ; RV64-NEXT: vl8r.v v16, (a4)
189 ; RV64-NEXT: vl8r.v v24, (a0)
190 ; RV64-NEXT: add a1, a3, a1
191 ; RV64-NEXT: vsetvli a0, zero, e8, m8, ta, ma
192 ; RV64-NEXT: vmseq.vi v8, v16, 0
193 ; RV64-NEXT: vmseq.vi v0, v24, 0
194 ; RV64-NEXT: vmv.v.i v16, 0
195 ; RV64-NEXT: vmerge.vim v24, v16, 1, v0
196 ; RV64-NEXT: vs8r.v v24, (a3)
197 ; RV64-NEXT: add a2, a3, a2
198 ; RV64-NEXT: vmv1r.v v0, v8
199 ; RV64-NEXT: vmerge.vim v8, v16, 1, v0
200 ; RV64-NEXT: vs8r.v v8, (a2)
201 ; RV64-NEXT: lbu a0, 0(a1)
202 ; RV64-NEXT: addi sp, s0, -80
203 ; RV64-NEXT: ld ra, 72(sp) # 8-byte Folded Reload
204 ; RV64-NEXT: ld s0, 64(sp) # 8-byte Folded Reload
205 ; RV64-NEXT: addi sp, sp, 80
207 %a = load <vscale x 128 x i8>, <vscale x 128 x i8>* %x
208 %b = icmp eq <vscale x 128 x i8> %a, zeroinitializer
209 %c = extractelement <vscale x 128 x i1> %b, i64 %idx
213 define i1 @extractelt_nxv1i1_idx0(<vscale x 1 x i8>* %x) nounwind {
214 ; CHECK-LABEL: extractelt_nxv1i1_idx0:
216 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
217 ; CHECK-NEXT: vle8.v v8, (a0)
218 ; CHECK-NEXT: vmseq.vi v8, v8, 0
219 ; CHECK-NEXT: vfirst.m a0, v8
220 ; CHECK-NEXT: seqz a0, a0
222 %a = load <vscale x 1 x i8>, <vscale x 1 x i8>* %x
223 %b = icmp eq <vscale x 1 x i8> %a, zeroinitializer
224 %c = extractelement <vscale x 1 x i1> %b, i64 0
228 define i1 @extractelt_nxv2i1_idx0(<vscale x 2 x i8>* %x) nounwind {
229 ; CHECK-LABEL: extractelt_nxv2i1_idx0:
231 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
232 ; CHECK-NEXT: vle8.v v8, (a0)
233 ; CHECK-NEXT: vmseq.vi v8, v8, 0
234 ; CHECK-NEXT: vfirst.m a0, v8
235 ; CHECK-NEXT: seqz a0, a0
237 %a = load <vscale x 2 x i8>, <vscale x 2 x i8>* %x
238 %b = icmp eq <vscale x 2 x i8> %a, zeroinitializer
239 %c = extractelement <vscale x 2 x i1> %b, i64 0
243 define i1 @extractelt_nxv4i1_idx0(<vscale x 4 x i8>* %x) nounwind {
244 ; CHECK-LABEL: extractelt_nxv4i1_idx0:
246 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
247 ; CHECK-NEXT: vle8.v v8, (a0)
248 ; CHECK-NEXT: vmseq.vi v8, v8, 0
249 ; CHECK-NEXT: vfirst.m a0, v8
250 ; CHECK-NEXT: seqz a0, a0
252 %a = load <vscale x 4 x i8>, <vscale x 4 x i8>* %x
253 %b = icmp eq <vscale x 4 x i8> %a, zeroinitializer
254 %c = extractelement <vscale x 4 x i1> %b, i64 0
258 define i1 @extractelt_nxv8i1_idx0(<vscale x 8 x i8>* %x) nounwind {
259 ; CHECK-LABEL: extractelt_nxv8i1_idx0:
261 ; CHECK-NEXT: vl1r.v v8, (a0)
262 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
263 ; CHECK-NEXT: vmseq.vi v8, v8, 0
264 ; CHECK-NEXT: vfirst.m a0, v8
265 ; CHECK-NEXT: seqz a0, a0
267 %a = load <vscale x 8 x i8>, <vscale x 8 x i8>* %x
268 %b = icmp eq <vscale x 8 x i8> %a, zeroinitializer
269 %c = extractelement <vscale x 8 x i1> %b, i64 0
273 define i1 @extractelt_nxv16i1_idx0(<vscale x 16 x i8>* %x) nounwind {
274 ; CHECK-LABEL: extractelt_nxv16i1_idx0:
276 ; CHECK-NEXT: vl2r.v v8, (a0)
277 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
278 ; CHECK-NEXT: vmseq.vi v10, v8, 0
279 ; CHECK-NEXT: vfirst.m a0, v10
280 ; CHECK-NEXT: seqz a0, a0
282 %a = load <vscale x 16 x i8>, <vscale x 16 x i8>* %x
283 %b = icmp eq <vscale x 16 x i8> %a, zeroinitializer
284 %c = extractelement <vscale x 16 x i1> %b, i64 0
288 define i1 @extractelt_nxv32i1_idx0(<vscale x 32 x i8>* %x) nounwind {
289 ; CHECK-LABEL: extractelt_nxv32i1_idx0:
291 ; CHECK-NEXT: vl4r.v v8, (a0)
292 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
293 ; CHECK-NEXT: vmseq.vi v12, v8, 0
294 ; CHECK-NEXT: vfirst.m a0, v12
295 ; CHECK-NEXT: seqz a0, a0
297 %a = load <vscale x 32 x i8>, <vscale x 32 x i8>* %x
298 %b = icmp eq <vscale x 32 x i8> %a, zeroinitializer
299 %c = extractelement <vscale x 32 x i1> %b, i64 0
303 define i1 @extractelt_nxv64i1_idx0(<vscale x 64 x i8>* %x) nounwind {
304 ; CHECK-LABEL: extractelt_nxv64i1_idx0:
306 ; CHECK-NEXT: vl8r.v v8, (a0)
307 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
308 ; CHECK-NEXT: vmseq.vi v16, v8, 0
309 ; CHECK-NEXT: vfirst.m a0, v16
310 ; CHECK-NEXT: seqz a0, a0
312 %a = load <vscale x 64 x i8>, <vscale x 64 x i8>* %x
313 %b = icmp eq <vscale x 64 x i8> %a, zeroinitializer
314 %c = extractelement <vscale x 64 x i1> %b, i64 0