1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
7 define half @extractelt_nxv1f16_0(<vscale x 1 x half> %v) {
8 ; CHECK-LABEL: extractelt_nxv1f16_0:
10 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
11 ; CHECK-NEXT: vfmv.f.s fa0, v8
13 %r = extractelement <vscale x 1 x half> %v, i32 0
17 define half @extractelt_nxv1f16_imm(<vscale x 1 x half> %v) {
18 ; CHECK-LABEL: extractelt_nxv1f16_imm:
20 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
21 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
22 ; CHECK-NEXT: vfmv.f.s fa0, v8
24 %r = extractelement <vscale x 1 x half> %v, i32 2
28 define half @extractelt_nxv1f16_idx(<vscale x 1 x half> %v, i32 zeroext %idx) {
29 ; CHECK-LABEL: extractelt_nxv1f16_idx:
31 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
32 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
33 ; CHECK-NEXT: vfmv.f.s fa0, v8
35 %r = extractelement <vscale x 1 x half> %v, i32 %idx
39 define half @extractelt_nxv2f16_0(<vscale x 2 x half> %v) {
40 ; CHECK-LABEL: extractelt_nxv2f16_0:
42 ; CHECK-NEXT: vsetivli zero, 1, e16, mf2, ta, ma
43 ; CHECK-NEXT: vfmv.f.s fa0, v8
45 %r = extractelement <vscale x 2 x half> %v, i32 0
49 define half @extractelt_nxv2f16_imm(<vscale x 2 x half> %v) {
50 ; CHECK-LABEL: extractelt_nxv2f16_imm:
52 ; CHECK-NEXT: vsetivli zero, 1, e16, mf2, ta, ma
53 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
54 ; CHECK-NEXT: vfmv.f.s fa0, v8
56 %r = extractelement <vscale x 2 x half> %v, i32 2
60 define half @extractelt_nxv2f16_idx(<vscale x 2 x half> %v, i32 zeroext %idx) {
61 ; CHECK-LABEL: extractelt_nxv2f16_idx:
63 ; CHECK-NEXT: vsetivli zero, 1, e16, mf2, ta, ma
64 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
65 ; CHECK-NEXT: vfmv.f.s fa0, v8
67 %r = extractelement <vscale x 2 x half> %v, i32 %idx
71 define half @extractelt_nxv4f16_0(<vscale x 4 x half> %v) {
72 ; CHECK-LABEL: extractelt_nxv4f16_0:
74 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
75 ; CHECK-NEXT: vfmv.f.s fa0, v8
77 %r = extractelement <vscale x 4 x half> %v, i32 0
81 define half @extractelt_nxv4f16_imm(<vscale x 4 x half> %v) {
82 ; CHECK-LABEL: extractelt_nxv4f16_imm:
84 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
85 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
86 ; CHECK-NEXT: vfmv.f.s fa0, v8
88 %r = extractelement <vscale x 4 x half> %v, i32 2
92 define half @extractelt_nxv4f16_idx(<vscale x 4 x half> %v, i32 zeroext %idx) {
93 ; CHECK-LABEL: extractelt_nxv4f16_idx:
95 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
96 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
97 ; CHECK-NEXT: vfmv.f.s fa0, v8
99 %r = extractelement <vscale x 4 x half> %v, i32 %idx
103 define half @extractelt_nxv8f16_0(<vscale x 8 x half> %v) {
104 ; CHECK-LABEL: extractelt_nxv8f16_0:
106 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
107 ; CHECK-NEXT: vfmv.f.s fa0, v8
109 %r = extractelement <vscale x 8 x half> %v, i32 0
113 define half @extractelt_nxv8f16_imm(<vscale x 8 x half> %v) {
114 ; CHECK-LABEL: extractelt_nxv8f16_imm:
116 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
117 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
118 ; CHECK-NEXT: vfmv.f.s fa0, v8
120 %r = extractelement <vscale x 8 x half> %v, i32 2
124 define half @extractelt_nxv8f16_idx(<vscale x 8 x half> %v, i32 zeroext %idx) {
125 ; CHECK-LABEL: extractelt_nxv8f16_idx:
127 ; CHECK-NEXT: vsetivli zero, 1, e16, m2, ta, ma
128 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
129 ; CHECK-NEXT: vfmv.f.s fa0, v8
131 %r = extractelement <vscale x 8 x half> %v, i32 %idx
135 define half @extractelt_nxv16f16_0(<vscale x 16 x half> %v) {
136 ; CHECK-LABEL: extractelt_nxv16f16_0:
138 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
139 ; CHECK-NEXT: vfmv.f.s fa0, v8
141 %r = extractelement <vscale x 16 x half> %v, i32 0
145 define half @extractelt_nxv16f16_imm(<vscale x 16 x half> %v) {
146 ; CHECK-LABEL: extractelt_nxv16f16_imm:
148 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
149 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
150 ; CHECK-NEXT: vfmv.f.s fa0, v8
152 %r = extractelement <vscale x 16 x half> %v, i32 2
156 define half @extractelt_nxv16f16_idx(<vscale x 16 x half> %v, i32 zeroext %idx) {
157 ; CHECK-LABEL: extractelt_nxv16f16_idx:
159 ; CHECK-NEXT: vsetivli zero, 1, e16, m4, ta, ma
160 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
161 ; CHECK-NEXT: vfmv.f.s fa0, v8
163 %r = extractelement <vscale x 16 x half> %v, i32 %idx
167 define half @extractelt_nxv32f16_0(<vscale x 32 x half> %v) {
168 ; CHECK-LABEL: extractelt_nxv32f16_0:
170 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
171 ; CHECK-NEXT: vfmv.f.s fa0, v8
173 %r = extractelement <vscale x 32 x half> %v, i32 0
177 define half @extractelt_nxv32f16_imm(<vscale x 32 x half> %v) {
178 ; CHECK-LABEL: extractelt_nxv32f16_imm:
180 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
181 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
182 ; CHECK-NEXT: vfmv.f.s fa0, v8
184 %r = extractelement <vscale x 32 x half> %v, i32 2
188 define half @extractelt_nxv32f16_idx(<vscale x 32 x half> %v, i32 zeroext %idx) {
189 ; CHECK-LABEL: extractelt_nxv32f16_idx:
191 ; CHECK-NEXT: vsetivli zero, 1, e16, m8, ta, ma
192 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
193 ; CHECK-NEXT: vfmv.f.s fa0, v8
195 %r = extractelement <vscale x 32 x half> %v, i32 %idx
199 define float @extractelt_nxv1f32_0(<vscale x 1 x float> %v) {
200 ; CHECK-LABEL: extractelt_nxv1f32_0:
202 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
203 ; CHECK-NEXT: vfmv.f.s fa0, v8
205 %r = extractelement <vscale x 1 x float> %v, i32 0
209 define float @extractelt_nxv1f32_imm(<vscale x 1 x float> %v) {
210 ; CHECK-LABEL: extractelt_nxv1f32_imm:
212 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
213 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
214 ; CHECK-NEXT: vfmv.f.s fa0, v8
216 %r = extractelement <vscale x 1 x float> %v, i32 2
220 define float @extractelt_nxv1f32_idx(<vscale x 1 x float> %v, i32 zeroext %idx) {
221 ; CHECK-LABEL: extractelt_nxv1f32_idx:
223 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
224 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
225 ; CHECK-NEXT: vfmv.f.s fa0, v8
227 %r = extractelement <vscale x 1 x float> %v, i32 %idx
231 define float @extractelt_nxv2f32_0(<vscale x 2 x float> %v) {
232 ; CHECK-LABEL: extractelt_nxv2f32_0:
234 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
235 ; CHECK-NEXT: vfmv.f.s fa0, v8
237 %r = extractelement <vscale x 2 x float> %v, i32 0
241 define float @extractelt_nxv2f32_imm(<vscale x 2 x float> %v) {
242 ; CHECK-LABEL: extractelt_nxv2f32_imm:
244 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
245 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
246 ; CHECK-NEXT: vfmv.f.s fa0, v8
248 %r = extractelement <vscale x 2 x float> %v, i32 2
252 define float @extractelt_nxv2f32_idx(<vscale x 2 x float> %v, i32 zeroext %idx) {
253 ; CHECK-LABEL: extractelt_nxv2f32_idx:
255 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
256 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
257 ; CHECK-NEXT: vfmv.f.s fa0, v8
259 %r = extractelement <vscale x 2 x float> %v, i32 %idx
263 define float @extractelt_nxv4f32_0(<vscale x 4 x float> %v) {
264 ; CHECK-LABEL: extractelt_nxv4f32_0:
266 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
267 ; CHECK-NEXT: vfmv.f.s fa0, v8
269 %r = extractelement <vscale x 4 x float> %v, i32 0
273 define float @extractelt_nxv4f32_imm(<vscale x 4 x float> %v) {
274 ; CHECK-LABEL: extractelt_nxv4f32_imm:
276 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
277 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
278 ; CHECK-NEXT: vfmv.f.s fa0, v8
280 %r = extractelement <vscale x 4 x float> %v, i32 2
284 define float @extractelt_nxv4f32_idx(<vscale x 4 x float> %v, i32 zeroext %idx) {
285 ; CHECK-LABEL: extractelt_nxv4f32_idx:
287 ; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
288 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
289 ; CHECK-NEXT: vfmv.f.s fa0, v8
291 %r = extractelement <vscale x 4 x float> %v, i32 %idx
295 define float @extractelt_nxv8f32_0(<vscale x 8 x float> %v) {
296 ; CHECK-LABEL: extractelt_nxv8f32_0:
298 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
299 ; CHECK-NEXT: vfmv.f.s fa0, v8
301 %r = extractelement <vscale x 8 x float> %v, i32 0
305 define float @extractelt_nxv8f32_imm(<vscale x 8 x float> %v) {
306 ; CHECK-LABEL: extractelt_nxv8f32_imm:
308 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
309 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
310 ; CHECK-NEXT: vfmv.f.s fa0, v8
312 %r = extractelement <vscale x 8 x float> %v, i32 2
316 define float @extractelt_nxv8f32_idx(<vscale x 8 x float> %v, i32 zeroext %idx) {
317 ; CHECK-LABEL: extractelt_nxv8f32_idx:
319 ; CHECK-NEXT: vsetivli zero, 1, e32, m4, ta, ma
320 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
321 ; CHECK-NEXT: vfmv.f.s fa0, v8
323 %r = extractelement <vscale x 8 x float> %v, i32 %idx
327 define float @extractelt_nxv16f32_0(<vscale x 16 x float> %v) {
328 ; CHECK-LABEL: extractelt_nxv16f32_0:
330 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
331 ; CHECK-NEXT: vfmv.f.s fa0, v8
333 %r = extractelement <vscale x 16 x float> %v, i32 0
337 define float @extractelt_nxv16f32_imm(<vscale x 16 x float> %v) {
338 ; CHECK-LABEL: extractelt_nxv16f32_imm:
340 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
341 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
342 ; CHECK-NEXT: vfmv.f.s fa0, v8
344 %r = extractelement <vscale x 16 x float> %v, i32 2
348 define float @extractelt_nxv16f32_idx(<vscale x 16 x float> %v, i32 zeroext %idx) {
349 ; CHECK-LABEL: extractelt_nxv16f32_idx:
351 ; CHECK-NEXT: vsetivli zero, 1, e32, m8, ta, ma
352 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
353 ; CHECK-NEXT: vfmv.f.s fa0, v8
355 %r = extractelement <vscale x 16 x float> %v, i32 %idx
359 define double @extractelt_nxv1f64_0(<vscale x 1 x double> %v) {
360 ; CHECK-LABEL: extractelt_nxv1f64_0:
362 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
363 ; CHECK-NEXT: vfmv.f.s fa0, v8
365 %r = extractelement <vscale x 1 x double> %v, i32 0
369 define double @extractelt_nxv1f64_imm(<vscale x 1 x double> %v) {
370 ; CHECK-LABEL: extractelt_nxv1f64_imm:
372 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
373 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
374 ; CHECK-NEXT: vfmv.f.s fa0, v8
376 %r = extractelement <vscale x 1 x double> %v, i32 2
380 define double @extractelt_nxv1f64_idx(<vscale x 1 x double> %v, i32 zeroext %idx) {
381 ; CHECK-LABEL: extractelt_nxv1f64_idx:
383 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
384 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
385 ; CHECK-NEXT: vfmv.f.s fa0, v8
387 %r = extractelement <vscale x 1 x double> %v, i32 %idx
391 define double @extractelt_nxv2f64_0(<vscale x 2 x double> %v) {
392 ; CHECK-LABEL: extractelt_nxv2f64_0:
394 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
395 ; CHECK-NEXT: vfmv.f.s fa0, v8
397 %r = extractelement <vscale x 2 x double> %v, i32 0
401 define double @extractelt_nxv2f64_imm(<vscale x 2 x double> %v) {
402 ; CHECK-LABEL: extractelt_nxv2f64_imm:
404 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
405 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
406 ; CHECK-NEXT: vfmv.f.s fa0, v8
408 %r = extractelement <vscale x 2 x double> %v, i32 2
412 define double @extractelt_nxv2f64_idx(<vscale x 2 x double> %v, i32 zeroext %idx) {
413 ; CHECK-LABEL: extractelt_nxv2f64_idx:
415 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
416 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
417 ; CHECK-NEXT: vfmv.f.s fa0, v8
419 %r = extractelement <vscale x 2 x double> %v, i32 %idx
423 define double @extractelt_nxv4f64_0(<vscale x 4 x double> %v) {
424 ; CHECK-LABEL: extractelt_nxv4f64_0:
426 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
427 ; CHECK-NEXT: vfmv.f.s fa0, v8
429 %r = extractelement <vscale x 4 x double> %v, i32 0
433 define double @extractelt_nxv4f64_imm(<vscale x 4 x double> %v) {
434 ; CHECK-LABEL: extractelt_nxv4f64_imm:
436 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
437 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
438 ; CHECK-NEXT: vfmv.f.s fa0, v8
440 %r = extractelement <vscale x 4 x double> %v, i32 2
444 define double @extractelt_nxv4f64_idx(<vscale x 4 x double> %v, i32 zeroext %idx) {
445 ; CHECK-LABEL: extractelt_nxv4f64_idx:
447 ; CHECK-NEXT: vsetivli zero, 1, e64, m4, ta, ma
448 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
449 ; CHECK-NEXT: vfmv.f.s fa0, v8
451 %r = extractelement <vscale x 4 x double> %v, i32 %idx
455 define double @extractelt_nxv8f64_0(<vscale x 8 x double> %v) {
456 ; CHECK-LABEL: extractelt_nxv8f64_0:
458 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
459 ; CHECK-NEXT: vfmv.f.s fa0, v8
461 %r = extractelement <vscale x 8 x double> %v, i32 0
465 define double @extractelt_nxv8f64_imm(<vscale x 8 x double> %v) {
466 ; CHECK-LABEL: extractelt_nxv8f64_imm:
468 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
469 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
470 ; CHECK-NEXT: vfmv.f.s fa0, v8
472 %r = extractelement <vscale x 8 x double> %v, i32 2
476 define double @extractelt_nxv8f64_idx(<vscale x 8 x double> %v, i32 zeroext %idx) {
477 ; CHECK-LABEL: extractelt_nxv8f64_idx:
479 ; CHECK-NEXT: vsetivli zero, 1, e64, m8, ta, ma
480 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
481 ; CHECK-NEXT: vfmv.f.s fa0, v8
483 %r = extractelement <vscale x 8 x double> %v, i32 %idx
487 define void @store_extractelt_nxv8f64(<vscale x 8 x double>* %x, double* %p) {
488 ; CHECK-LABEL: store_extractelt_nxv8f64:
490 ; CHECK-NEXT: vl8re64.v v8, (a0)
491 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
492 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
493 ; CHECK-NEXT: vse64.v v8, (a1)
495 %a = load <vscale x 8 x double>, <vscale x 8 x double>* %x
496 %b = extractelement <vscale x 8 x double> %a, i64 1
497 store double %b, double* %p
501 define void @store_vfmv_f_s_nxv8f64(<vscale x 8 x double>* %x, double* %p) {
502 ; CHECK-LABEL: store_vfmv_f_s_nxv8f64:
504 ; CHECK-NEXT: vl8re64.v v8, (a0)
505 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
506 ; CHECK-NEXT: vse64.v v8, (a1)
508 %a = load <vscale x 8 x double>, <vscale x 8 x double>* %x
509 %b = call double @llvm.riscv.vfmv.f.s.nxv8f64(<vscale x 8 x double> %a)
510 store double %b, double* %p
514 declare double @llvm.riscv.vfmv.f.s.nxv8f64(<vscale x 8 x double>)
516 define float @extractelt_fadd_nxv4f32_splat(<vscale x 4 x float> %x) {
517 ; CHECK-LABEL: extractelt_fadd_nxv4f32_splat:
519 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
520 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
521 ; CHECK-NEXT: vfmv.f.s fa5, v8
522 ; CHECK-NEXT: lui a0, 263168
523 ; CHECK-NEXT: fmv.w.x fa4, a0
524 ; CHECK-NEXT: fadd.s fa0, fa5, fa4
526 %head = insertelement <vscale x 4 x float> poison, float 3.0, i32 0
527 %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
528 %bo = fadd <vscale x 4 x float> %x, %splat
529 %ext = extractelement <vscale x 4 x float> %bo, i32 2
533 define float @extractelt_fsub_nxv4f32_splat(<vscale x 4 x float> %x) {
534 ; CHECK-LABEL: extractelt_fsub_nxv4f32_splat:
536 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
537 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
538 ; CHECK-NEXT: vfmv.f.s fa5, v8
539 ; CHECK-NEXT: lui a0, 263168
540 ; CHECK-NEXT: fmv.w.x fa4, a0
541 ; CHECK-NEXT: fsub.s fa0, fa4, fa5
543 %head = insertelement <vscale x 4 x float> poison, float 3.0, i32 0
544 %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
545 %bo = fsub <vscale x 4 x float> %splat, %x
546 %ext = extractelement <vscale x 4 x float> %bo, i32 1
550 define float @extractelt_fmul_nxv4f32_splat(<vscale x 4 x float> %x) {
551 ; CHECK-LABEL: extractelt_fmul_nxv4f32_splat:
553 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
554 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
555 ; CHECK-NEXT: vfmv.f.s fa5, v8
556 ; CHECK-NEXT: lui a0, 263168
557 ; CHECK-NEXT: fmv.w.x fa4, a0
558 ; CHECK-NEXT: fmul.s fa0, fa5, fa4
560 %head = insertelement <vscale x 4 x float> poison, float 3.0, i32 0
561 %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
562 %bo = fmul <vscale x 4 x float> %x, %splat
563 %ext = extractelement <vscale x 4 x float> %bo, i32 3
567 define float @extractelt_fdiv_nxv4f32_splat(<vscale x 4 x float> %x) {
568 ; CHECK-LABEL: extractelt_fdiv_nxv4f32_splat:
570 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
571 ; CHECK-NEXT: vfmv.f.s fa5, v8
572 ; CHECK-NEXT: lui a0, 263168
573 ; CHECK-NEXT: fmv.w.x fa4, a0
574 ; CHECK-NEXT: fdiv.s fa0, fa5, fa4
576 %head = insertelement <vscale x 4 x float> poison, float 3.0, i32 0
577 %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
578 %bo = fdiv <vscale x 4 x float> %x, %splat
579 %ext = extractelement <vscale x 4 x float> %bo, i32 0
583 define double @extractelt_nxv16f64_0(<vscale x 16 x double> %v) {
584 ; CHECK-LABEL: extractelt_nxv16f64_0:
586 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
587 ; CHECK-NEXT: vfmv.f.s fa0, v8
589 %r = extractelement <vscale x 16 x double> %v, i32 0
593 define double @extractelt_nxv16f64_neg1(<vscale x 16 x double> %v) {
594 ; RV32-LABEL: extractelt_nxv16f64_neg1:
596 ; RV32-NEXT: addi sp, sp, -80
597 ; RV32-NEXT: .cfi_def_cfa_offset 80
598 ; RV32-NEXT: sw ra, 76(sp) # 4-byte Folded Spill
599 ; RV32-NEXT: sw s0, 72(sp) # 4-byte Folded Spill
600 ; RV32-NEXT: .cfi_offset ra, -4
601 ; RV32-NEXT: .cfi_offset s0, -8
602 ; RV32-NEXT: addi s0, sp, 80
603 ; RV32-NEXT: .cfi_def_cfa s0, 0
604 ; RV32-NEXT: csrr a0, vlenb
605 ; RV32-NEXT: slli a0, a0, 4
606 ; RV32-NEXT: sub sp, sp, a0
607 ; RV32-NEXT: andi sp, sp, -64
608 ; RV32-NEXT: addi a0, sp, 64
609 ; RV32-NEXT: vs8r.v v8, (a0)
610 ; RV32-NEXT: csrr a1, vlenb
611 ; RV32-NEXT: slli a2, a1, 3
612 ; RV32-NEXT: add a2, a0, a2
613 ; RV32-NEXT: vs8r.v v16, (a2)
614 ; RV32-NEXT: slli a1, a1, 4
615 ; RV32-NEXT: add a0, a1, a0
616 ; RV32-NEXT: fld fa0, -8(a0)
617 ; RV32-NEXT: addi sp, s0, -80
618 ; RV32-NEXT: lw ra, 76(sp) # 4-byte Folded Reload
619 ; RV32-NEXT: lw s0, 72(sp) # 4-byte Folded Reload
620 ; RV32-NEXT: addi sp, sp, 80
623 ; RV64-LABEL: extractelt_nxv16f64_neg1:
625 ; RV64-NEXT: addi sp, sp, -80
626 ; RV64-NEXT: .cfi_def_cfa_offset 80
627 ; RV64-NEXT: sd ra, 72(sp) # 8-byte Folded Spill
628 ; RV64-NEXT: sd s0, 64(sp) # 8-byte Folded Spill
629 ; RV64-NEXT: .cfi_offset ra, -8
630 ; RV64-NEXT: .cfi_offset s0, -16
631 ; RV64-NEXT: addi s0, sp, 80
632 ; RV64-NEXT: .cfi_def_cfa s0, 0
633 ; RV64-NEXT: csrr a0, vlenb
634 ; RV64-NEXT: slli a0, a0, 4
635 ; RV64-NEXT: sub sp, sp, a0
636 ; RV64-NEXT: andi sp, sp, -64
637 ; RV64-NEXT: addi a0, sp, 64
638 ; RV64-NEXT: vs8r.v v8, (a0)
639 ; RV64-NEXT: csrr a2, vlenb
640 ; RV64-NEXT: slli a1, a2, 3
641 ; RV64-NEXT: add a3, a0, a1
642 ; RV64-NEXT: li a1, -1
643 ; RV64-NEXT: srli a1, a1, 32
644 ; RV64-NEXT: slli a2, a2, 1
645 ; RV64-NEXT: addi a2, a2, -1
646 ; RV64-NEXT: vs8r.v v16, (a3)
647 ; RV64-NEXT: bltu a2, a1, .LBB52_2
648 ; RV64-NEXT: # %bb.1:
649 ; RV64-NEXT: mv a2, a1
650 ; RV64-NEXT: .LBB52_2:
651 ; RV64-NEXT: slli a2, a2, 3
652 ; RV64-NEXT: add a0, a0, a2
653 ; RV64-NEXT: fld fa0, 0(a0)
654 ; RV64-NEXT: addi sp, s0, -80
655 ; RV64-NEXT: ld ra, 72(sp) # 8-byte Folded Reload
656 ; RV64-NEXT: ld s0, 64(sp) # 8-byte Folded Reload
657 ; RV64-NEXT: addi sp, sp, 80
659 %r = extractelement <vscale x 16 x double> %v, i32 -1
663 define double @extractelt_nxv16f64_imm(<vscale x 16 x double> %v) {
664 ; CHECK-LABEL: extractelt_nxv16f64_imm:
666 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
667 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
668 ; CHECK-NEXT: vfmv.f.s fa0, v8
670 %r = extractelement <vscale x 16 x double> %v, i32 2
674 define double @extractelt_nxv16f64_idx(<vscale x 16 x double> %v, i32 zeroext %idx) {
675 ; RV32-LABEL: extractelt_nxv16f64_idx:
677 ; RV32-NEXT: csrr a1, vlenb
678 ; RV32-NEXT: slli a2, a1, 1
679 ; RV32-NEXT: addi a2, a2, -1
680 ; RV32-NEXT: bltu a0, a2, .LBB54_2
681 ; RV32-NEXT: # %bb.1:
682 ; RV32-NEXT: mv a0, a2
683 ; RV32-NEXT: .LBB54_2:
684 ; RV32-NEXT: addi sp, sp, -80
685 ; RV32-NEXT: .cfi_def_cfa_offset 80
686 ; RV32-NEXT: sw ra, 76(sp) # 4-byte Folded Spill
687 ; RV32-NEXT: sw s0, 72(sp) # 4-byte Folded Spill
688 ; RV32-NEXT: .cfi_offset ra, -4
689 ; RV32-NEXT: .cfi_offset s0, -8
690 ; RV32-NEXT: addi s0, sp, 80
691 ; RV32-NEXT: .cfi_def_cfa s0, 0
692 ; RV32-NEXT: csrr a2, vlenb
693 ; RV32-NEXT: slli a2, a2, 4
694 ; RV32-NEXT: sub sp, sp, a2
695 ; RV32-NEXT: andi sp, sp, -64
696 ; RV32-NEXT: slli a0, a0, 3
697 ; RV32-NEXT: addi a2, sp, 64
698 ; RV32-NEXT: add a0, a2, a0
699 ; RV32-NEXT: vs8r.v v8, (a2)
700 ; RV32-NEXT: slli a1, a1, 3
701 ; RV32-NEXT: add a1, a2, a1
702 ; RV32-NEXT: vs8r.v v16, (a1)
703 ; RV32-NEXT: fld fa0, 0(a0)
704 ; RV32-NEXT: addi sp, s0, -80
705 ; RV32-NEXT: lw ra, 76(sp) # 4-byte Folded Reload
706 ; RV32-NEXT: lw s0, 72(sp) # 4-byte Folded Reload
707 ; RV32-NEXT: addi sp, sp, 80
710 ; RV64-LABEL: extractelt_nxv16f64_idx:
712 ; RV64-NEXT: csrr a1, vlenb
713 ; RV64-NEXT: slli a2, a1, 1
714 ; RV64-NEXT: addi a2, a2, -1
715 ; RV64-NEXT: bltu a0, a2, .LBB54_2
716 ; RV64-NEXT: # %bb.1:
717 ; RV64-NEXT: mv a0, a2
718 ; RV64-NEXT: .LBB54_2:
719 ; RV64-NEXT: addi sp, sp, -80
720 ; RV64-NEXT: .cfi_def_cfa_offset 80
721 ; RV64-NEXT: sd ra, 72(sp) # 8-byte Folded Spill
722 ; RV64-NEXT: sd s0, 64(sp) # 8-byte Folded Spill
723 ; RV64-NEXT: .cfi_offset ra, -8
724 ; RV64-NEXT: .cfi_offset s0, -16
725 ; RV64-NEXT: addi s0, sp, 80
726 ; RV64-NEXT: .cfi_def_cfa s0, 0
727 ; RV64-NEXT: csrr a2, vlenb
728 ; RV64-NEXT: slli a2, a2, 4
729 ; RV64-NEXT: sub sp, sp, a2
730 ; RV64-NEXT: andi sp, sp, -64
731 ; RV64-NEXT: slli a0, a0, 3
732 ; RV64-NEXT: addi a2, sp, 64
733 ; RV64-NEXT: add a0, a2, a0
734 ; RV64-NEXT: vs8r.v v8, (a2)
735 ; RV64-NEXT: slli a1, a1, 3
736 ; RV64-NEXT: add a1, a2, a1
737 ; RV64-NEXT: vs8r.v v16, (a1)
738 ; RV64-NEXT: fld fa0, 0(a0)
739 ; RV64-NEXT: addi sp, s0, -80
740 ; RV64-NEXT: ld ra, 72(sp) # 8-byte Folded Reload
741 ; RV64-NEXT: ld s0, 64(sp) # 8-byte Folded Reload
742 ; RV64-NEXT: addi sp, sp, 80
744 %r = extractelement <vscale x 16 x double> %v, i32 %idx