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(ptr %x, ptr %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>, ptr %x
496 %b = extractelement <vscale x 8 x double> %a, i64 1
497 store double %b, ptr %p
501 define void @store_vfmv_f_s_nxv8f64(ptr %x, ptr %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>, ptr %x
509 %b = call double @llvm.riscv.vfmv.f.s.nxv8f64(<vscale x 8 x double> %a)
510 store double %b, ptr %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 %bo = fadd <vscale x 4 x float> %x, splat (float 3.0)
527 %ext = extractelement <vscale x 4 x float> %bo, i32 2
531 define float @extractelt_fsub_nxv4f32_splat(<vscale x 4 x float> %x) {
532 ; CHECK-LABEL: extractelt_fsub_nxv4f32_splat:
534 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
535 ; CHECK-NEXT: vslidedown.vi v8, v8, 1
536 ; CHECK-NEXT: vfmv.f.s fa5, v8
537 ; CHECK-NEXT: lui a0, 263168
538 ; CHECK-NEXT: fmv.w.x fa4, a0
539 ; CHECK-NEXT: fsub.s fa0, fa4, fa5
541 %bo = fsub <vscale x 4 x float> splat (float 3.0), %x
542 %ext = extractelement <vscale x 4 x float> %bo, i32 1
546 define float @extractelt_fmul_nxv4f32_splat(<vscale x 4 x float> %x) {
547 ; CHECK-LABEL: extractelt_fmul_nxv4f32_splat:
549 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
550 ; CHECK-NEXT: vslidedown.vi v8, v8, 3
551 ; CHECK-NEXT: vfmv.f.s fa5, v8
552 ; CHECK-NEXT: lui a0, 263168
553 ; CHECK-NEXT: fmv.w.x fa4, a0
554 ; CHECK-NEXT: fmul.s fa0, fa5, fa4
556 %bo = fmul <vscale x 4 x float> %x, splat (float 3.0)
557 %ext = extractelement <vscale x 4 x float> %bo, i32 3
561 define float @extractelt_fdiv_nxv4f32_splat(<vscale x 4 x float> %x) {
562 ; CHECK-LABEL: extractelt_fdiv_nxv4f32_splat:
564 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
565 ; CHECK-NEXT: vfmv.f.s fa5, v8
566 ; CHECK-NEXT: lui a0, 263168
567 ; CHECK-NEXT: fmv.w.x fa4, a0
568 ; CHECK-NEXT: fdiv.s fa0, fa5, fa4
570 %bo = fdiv <vscale x 4 x float> %x, splat (float 3.0)
571 %ext = extractelement <vscale x 4 x float> %bo, i32 0
575 define double @extractelt_nxv16f64_0(<vscale x 16 x double> %v) {
576 ; CHECK-LABEL: extractelt_nxv16f64_0:
578 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
579 ; CHECK-NEXT: vfmv.f.s fa0, v8
581 %r = extractelement <vscale x 16 x double> %v, i32 0
585 define double @extractelt_nxv16f64_neg1(<vscale x 16 x double> %v) {
586 ; RV32-LABEL: extractelt_nxv16f64_neg1:
588 ; RV32-NEXT: addi sp, sp, -80
589 ; RV32-NEXT: .cfi_def_cfa_offset 80
590 ; RV32-NEXT: sw ra, 76(sp) # 4-byte Folded Spill
591 ; RV32-NEXT: sw s0, 72(sp) # 4-byte Folded Spill
592 ; RV32-NEXT: .cfi_offset ra, -4
593 ; RV32-NEXT: .cfi_offset s0, -8
594 ; RV32-NEXT: addi s0, sp, 80
595 ; RV32-NEXT: .cfi_def_cfa s0, 0
596 ; RV32-NEXT: csrr a0, vlenb
597 ; RV32-NEXT: slli a0, a0, 4
598 ; RV32-NEXT: sub sp, sp, a0
599 ; RV32-NEXT: andi sp, sp, -64
600 ; RV32-NEXT: addi a0, sp, 64
601 ; RV32-NEXT: vs8r.v v8, (a0)
602 ; RV32-NEXT: csrr a1, vlenb
603 ; RV32-NEXT: slli a2, a1, 3
604 ; RV32-NEXT: add a2, a0, a2
605 ; RV32-NEXT: vs8r.v v16, (a2)
606 ; RV32-NEXT: slli a1, a1, 4
607 ; RV32-NEXT: add a0, a1, a0
608 ; RV32-NEXT: fld fa0, -8(a0)
609 ; RV32-NEXT: addi sp, s0, -80
610 ; RV32-NEXT: lw ra, 76(sp) # 4-byte Folded Reload
611 ; RV32-NEXT: lw s0, 72(sp) # 4-byte Folded Reload
612 ; RV32-NEXT: addi sp, sp, 80
615 ; RV64-LABEL: extractelt_nxv16f64_neg1:
617 ; RV64-NEXT: addi sp, sp, -80
618 ; RV64-NEXT: .cfi_def_cfa_offset 80
619 ; RV64-NEXT: sd ra, 72(sp) # 8-byte Folded Spill
620 ; RV64-NEXT: sd s0, 64(sp) # 8-byte Folded Spill
621 ; RV64-NEXT: .cfi_offset ra, -8
622 ; RV64-NEXT: .cfi_offset s0, -16
623 ; RV64-NEXT: addi s0, sp, 80
624 ; RV64-NEXT: .cfi_def_cfa s0, 0
625 ; RV64-NEXT: csrr a0, vlenb
626 ; RV64-NEXT: slli a0, a0, 4
627 ; RV64-NEXT: sub sp, sp, a0
628 ; RV64-NEXT: andi sp, sp, -64
629 ; RV64-NEXT: addi a0, sp, 64
630 ; RV64-NEXT: vs8r.v v8, (a0)
631 ; RV64-NEXT: csrr a2, vlenb
632 ; RV64-NEXT: slli a1, a2, 3
633 ; RV64-NEXT: add a3, a0, a1
634 ; RV64-NEXT: li a1, -1
635 ; RV64-NEXT: srli a1, a1, 32
636 ; RV64-NEXT: slli a2, a2, 1
637 ; RV64-NEXT: addi a2, a2, -1
638 ; RV64-NEXT: vs8r.v v16, (a3)
639 ; RV64-NEXT: bltu a2, a1, .LBB52_2
640 ; RV64-NEXT: # %bb.1:
641 ; RV64-NEXT: mv a2, a1
642 ; RV64-NEXT: .LBB52_2:
643 ; RV64-NEXT: slli a2, a2, 3
644 ; RV64-NEXT: add a0, a0, a2
645 ; RV64-NEXT: fld fa0, 0(a0)
646 ; RV64-NEXT: addi sp, s0, -80
647 ; RV64-NEXT: ld ra, 72(sp) # 8-byte Folded Reload
648 ; RV64-NEXT: ld s0, 64(sp) # 8-byte Folded Reload
649 ; RV64-NEXT: addi sp, sp, 80
651 %r = extractelement <vscale x 16 x double> %v, i32 -1
655 define double @extractelt_nxv16f64_imm(<vscale x 16 x double> %v) {
656 ; CHECK-LABEL: extractelt_nxv16f64_imm:
658 ; CHECK-NEXT: vsetivli zero, 1, e64, m2, ta, ma
659 ; CHECK-NEXT: vslidedown.vi v8, v8, 2
660 ; CHECK-NEXT: vfmv.f.s fa0, v8
662 %r = extractelement <vscale x 16 x double> %v, i32 2
666 define double @extractelt_nxv16f64_idx(<vscale x 16 x double> %v, i32 zeroext %idx) {
667 ; RV32-LABEL: extractelt_nxv16f64_idx:
669 ; RV32-NEXT: csrr a1, vlenb
670 ; RV32-NEXT: slli a2, a1, 1
671 ; RV32-NEXT: addi a2, a2, -1
672 ; RV32-NEXT: bltu a0, a2, .LBB54_2
673 ; RV32-NEXT: # %bb.1:
674 ; RV32-NEXT: mv a0, a2
675 ; RV32-NEXT: .LBB54_2:
676 ; RV32-NEXT: addi sp, sp, -80
677 ; RV32-NEXT: .cfi_def_cfa_offset 80
678 ; RV32-NEXT: sw ra, 76(sp) # 4-byte Folded Spill
679 ; RV32-NEXT: sw s0, 72(sp) # 4-byte Folded Spill
680 ; RV32-NEXT: .cfi_offset ra, -4
681 ; RV32-NEXT: .cfi_offset s0, -8
682 ; RV32-NEXT: addi s0, sp, 80
683 ; RV32-NEXT: .cfi_def_cfa s0, 0
684 ; RV32-NEXT: csrr a2, vlenb
685 ; RV32-NEXT: slli a2, a2, 4
686 ; RV32-NEXT: sub sp, sp, a2
687 ; RV32-NEXT: andi sp, sp, -64
688 ; RV32-NEXT: slli a0, a0, 3
689 ; RV32-NEXT: addi a2, sp, 64
690 ; RV32-NEXT: add a0, a2, a0
691 ; RV32-NEXT: vs8r.v v8, (a2)
692 ; RV32-NEXT: slli a1, a1, 3
693 ; RV32-NEXT: add a1, a2, a1
694 ; RV32-NEXT: vs8r.v v16, (a1)
695 ; RV32-NEXT: fld fa0, 0(a0)
696 ; RV32-NEXT: addi sp, s0, -80
697 ; RV32-NEXT: lw ra, 76(sp) # 4-byte Folded Reload
698 ; RV32-NEXT: lw s0, 72(sp) # 4-byte Folded Reload
699 ; RV32-NEXT: addi sp, sp, 80
702 ; RV64-LABEL: extractelt_nxv16f64_idx:
704 ; RV64-NEXT: csrr a1, vlenb
705 ; RV64-NEXT: slli a2, a1, 1
706 ; RV64-NEXT: addi a2, a2, -1
707 ; RV64-NEXT: bltu a0, a2, .LBB54_2
708 ; RV64-NEXT: # %bb.1:
709 ; RV64-NEXT: mv a0, a2
710 ; RV64-NEXT: .LBB54_2:
711 ; RV64-NEXT: addi sp, sp, -80
712 ; RV64-NEXT: .cfi_def_cfa_offset 80
713 ; RV64-NEXT: sd ra, 72(sp) # 8-byte Folded Spill
714 ; RV64-NEXT: sd s0, 64(sp) # 8-byte Folded Spill
715 ; RV64-NEXT: .cfi_offset ra, -8
716 ; RV64-NEXT: .cfi_offset s0, -16
717 ; RV64-NEXT: addi s0, sp, 80
718 ; RV64-NEXT: .cfi_def_cfa s0, 0
719 ; RV64-NEXT: csrr a2, vlenb
720 ; RV64-NEXT: slli a2, a2, 4
721 ; RV64-NEXT: sub sp, sp, a2
722 ; RV64-NEXT: andi sp, sp, -64
723 ; RV64-NEXT: slli a0, a0, 3
724 ; RV64-NEXT: addi a2, sp, 64
725 ; RV64-NEXT: add a0, a2, a0
726 ; RV64-NEXT: vs8r.v v8, (a2)
727 ; RV64-NEXT: slli a1, a1, 3
728 ; RV64-NEXT: add a1, a2, a1
729 ; RV64-NEXT: vs8r.v v16, (a1)
730 ; RV64-NEXT: fld fa0, 0(a0)
731 ; RV64-NEXT: addi sp, s0, -80
732 ; RV64-NEXT: ld ra, 72(sp) # 8-byte Folded Reload
733 ; RV64-NEXT: ld s0, 64(sp) # 8-byte Folded Reload
734 ; RV64-NEXT: addi sp, sp, 80
736 %r = extractelement <vscale x 16 x double> %v, i32 %idx