Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-9.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
3
4 #include "riscv_vector.h"
5
6 double __attribute__ ((noinline))
7 sumation (double sum0, double sum1, double sum2, double sum3)
8 {
9 return sum0 + sum1 + sum2 + sum3;
10 }
11
12 double
13 foo (char const *buf, size_t len)
14 {
15 double sum = 0;
16 size_t vl = __riscv_vsetvlmax_e8m8 ();
17 size_t step = vl * 4;
18 const char *it = buf, *end = buf + len;
19 for (; it + step <= end;)
20 {
21 vfloat32m4_t v0 = __riscv_vle32_v_f32m4 ((void *) it, vl);
22 it += vl;
23 vfloat32m4_t v1 = __riscv_vle32_v_f32m4 ((void *) it, vl);
24 it += vl;
25 vfloat32m4_t v2 = __riscv_vle32_v_f32m4 ((void *) it, vl);
26 it += vl;
27 vfloat32m4_t v3 = __riscv_vle32_v_f32m4 ((void *) it, vl);
28 it += vl;
29
30 asm volatile("nop" ::: "memory");
31 vfloat64m8_t vw0 = __riscv_vfwcvt_f_f_v_f64m8 (v0, vl);
32 vfloat64m8_t vw1 = __riscv_vfwcvt_f_f_v_f64m8 (v1, vl);
33 vfloat64m8_t vw2 = __riscv_vfwcvt_f_f_v_f64m8 (v2, vl);
34 vfloat64m8_t vw3 = __riscv_vfwcvt_f_f_v_f64m8 (v3, vl);
35
36 asm volatile("nop" ::: "memory");
37 double sum0 = __riscv_vfmv_f_s_f64m8_f64 (vw0);
38 double sum1 = __riscv_vfmv_f_s_f64m8_f64 (vw1);
39 double sum2 = __riscv_vfmv_f_s_f64m8_f64 (vw2);
40 double sum3 = __riscv_vfmv_f_s_f64m8_f64 (vw3);
41
42 sum += sumation (sum0, sum1, sum2, sum3);
43 }
44 return sum;
45 }
46
47 /* { dg-final { scan-assembler-not {vmv1r} } } */
48 /* { dg-final { scan-assembler-not {vmv2r} } } */
49 /* { dg-final { scan-assembler-not {vmv4r} } } */
50 /* { dg-final { scan-assembler-not {vmv8r} } } */
51 /* { dg-final { scan-assembler-not {csrr} { xfail riscv*-*-* } } } */