Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-10.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, double sum4,
8 double sum5, double sum6, double sum7, double sum8, double sum9,
9 double sum10, double sum11, double sum12, double sum13, double sum14,
10 double sum15)
11 {
12 return sum0 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9
13 + sum10 + sum11 + sum12 + sum13 + sum14 + sum15;
14 }
15
16 double
17 foo (char const *buf, size_t len)
18 {
19 double sum = 0;
20 size_t vl = __riscv_vsetvlmax_e8m8 ();
21 size_t step = vl * 4;
22 const char *it = buf, *end = buf + len;
23 for (; it + step <= end;)
24 {
25 vint32m1_t v0 = __riscv_vle32_v_i32m1 ((void *) it, vl);
26 it += vl;
27 vint32m1_t v1 = __riscv_vle32_v_i32m1 ((void *) it, vl);
28 it += vl;
29 vint32m1_t v2 = __riscv_vle32_v_i32m1 ((void *) it, vl);
30 it += vl;
31 vint32m1_t v3 = __riscv_vle32_v_i32m1 ((void *) it, vl);
32 it += vl;
33 vint32m1_t v4 = __riscv_vle32_v_i32m1 ((void *) it, vl);
34 it += vl;
35 vint32m1_t v5 = __riscv_vle32_v_i32m1 ((void *) it, vl);
36 it += vl;
37 vint32m1_t v6 = __riscv_vle32_v_i32m1 ((void *) it, vl);
38 it += vl;
39 vint32m1_t v7 = __riscv_vle32_v_i32m1 ((void *) it, vl);
40 it += vl;
41 vint32m1_t v8 = __riscv_vle32_v_i32m1 ((void *) it, vl);
42 it += vl;
43 vint32m1_t v9 = __riscv_vle32_v_i32m1 ((void *) it, vl);
44 it += vl;
45 vint32m1_t v10 = __riscv_vle32_v_i32m1 ((void *) it, vl);
46 it += vl;
47 vint32m1_t v11 = __riscv_vle32_v_i32m1 ((void *) it, vl);
48 it += vl;
49 vint32m1_t v12 = __riscv_vle32_v_i32m1 ((void *) it, vl);
50 it += vl;
51 vint32m1_t v13 = __riscv_vle32_v_i32m1 ((void *) it, vl);
52 it += vl;
53 vint32m1_t v14 = __riscv_vle32_v_i32m1 ((void *) it, vl);
54 it += vl;
55 vint32m1_t v15 = __riscv_vle32_v_i32m1 ((void *) it, vl);
56 it += vl;
57
58 asm volatile("nop" ::: "memory");
59 vfloat64m2_t vw0 = __riscv_vfwcvt_f_x_v_f64m2 (v0, vl);
60 vfloat64m2_t vw1 = __riscv_vfwcvt_f_x_v_f64m2 (v1, vl);
61 vfloat64m2_t vw2 = __riscv_vfwcvt_f_x_v_f64m2 (v2, vl);
62 vfloat64m2_t vw3 = __riscv_vfwcvt_f_x_v_f64m2 (v3, vl);
63 vfloat64m2_t vw4 = __riscv_vfwcvt_f_x_v_f64m2 (v4, vl);
64 vfloat64m2_t vw5 = __riscv_vfwcvt_f_x_v_f64m2 (v5, vl);
65 vfloat64m2_t vw6 = __riscv_vfwcvt_f_x_v_f64m2 (v6, vl);
66 vfloat64m2_t vw7 = __riscv_vfwcvt_f_x_v_f64m2 (v7, vl);
67 vfloat64m2_t vw8 = __riscv_vfwcvt_f_x_v_f64m2 (v8, vl);
68 vfloat64m2_t vw9 = __riscv_vfwcvt_f_x_v_f64m2 (v9, vl);
69 vfloat64m2_t vw10 = __riscv_vfwcvt_f_x_v_f64m2 (v10, vl);
70 vfloat64m2_t vw11 = __riscv_vfwcvt_f_x_v_f64m2 (v11, vl);
71 vfloat64m2_t vw12 = __riscv_vfwcvt_f_x_v_f64m2 (v12, vl);
72 vfloat64m2_t vw13 = __riscv_vfwcvt_f_x_v_f64m2 (v13, vl);
73 vfloat64m2_t vw14 = __riscv_vfwcvt_f_x_v_f64m2 (v14, vl);
74 vfloat64m2_t vw15 = __riscv_vfwcvt_f_x_v_f64m2 (v15, vl);
75
76 asm volatile("nop" ::: "memory");
77 double sum0 = __riscv_vfmv_f_s_f64m2_f64 (vw0);
78 double sum1 = __riscv_vfmv_f_s_f64m2_f64 (vw1);
79 double sum2 = __riscv_vfmv_f_s_f64m2_f64 (vw2);
80 double sum3 = __riscv_vfmv_f_s_f64m2_f64 (vw3);
81 double sum4 = __riscv_vfmv_f_s_f64m2_f64 (vw4);
82 double sum5 = __riscv_vfmv_f_s_f64m2_f64 (vw5);
83 double sum6 = __riscv_vfmv_f_s_f64m2_f64 (vw6);
84 double sum7 = __riscv_vfmv_f_s_f64m2_f64 (vw7);
85 double sum8 = __riscv_vfmv_f_s_f64m2_f64 (vw8);
86 double sum9 = __riscv_vfmv_f_s_f64m2_f64 (vw9);
87 double sum10 = __riscv_vfmv_f_s_f64m2_f64 (vw10);
88 double sum11 = __riscv_vfmv_f_s_f64m2_f64 (vw11);
89 double sum12 = __riscv_vfmv_f_s_f64m2_f64 (vw12);
90 double sum13 = __riscv_vfmv_f_s_f64m2_f64 (vw13);
91 double sum14 = __riscv_vfmv_f_s_f64m2_f64 (vw14);
92 double sum15 = __riscv_vfmv_f_s_f64m2_f64 (vw15);
93
94 sum += sumation (sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7, sum8,
95 sum9, sum10, sum11, sum12, sum13, sum14, sum15);
96 }
97 return sum;
98 }
99
100 /* { dg-final { scan-assembler-not {vmv1r} } } */
101 /* { dg-final { scan-assembler-not {vmv2r} } } */
102 /* { dg-final { scan-assembler-not {vmv4r} } } */
103 /* { dg-final { scan-assembler-not {vmv8r} } } */
104 /* { dg-final { scan-assembler-not {csrr} { xfail riscv*-*-* } } } */