Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-14.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)
9 {
10 return sum0 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7;
11 }
12
13 double
14 foo (char const *buf, size_t len)
15 {
16 double sum = 0;
17 size_t vl = __riscv_vsetvlmax_e8m8 ();
18 size_t step = vl * 4;
19 const char *it = buf, *end = buf + len;
20 for (; it + step <= end;)
21 {
22 vfloat32m1_t v0 = __riscv_vle32_v_f32m1 ((void *) it, vl);
23 it += vl;
24 vfloat32m1_t v1 = __riscv_vle32_v_f32m1 ((void *) it, vl);
25 it += vl;
26 vfloat32m1_t v2 = __riscv_vle32_v_f32m1 ((void *) it, vl);
27 it += vl;
28 vfloat32m1_t v3 = __riscv_vle32_v_f32m1 ((void *) it, vl);
29 it += vl;
30 vfloat32m1_t v4 = __riscv_vle32_v_f32m1 ((void *) it, vl);
31 it += vl;
32 vfloat32m1_t v5 = __riscv_vle32_v_f32m1 ((void *) it, vl);
33 it += vl;
34 vfloat32m1_t v6 = __riscv_vle32_v_f32m1 ((void *) it, vl);
35 it += vl;
36 vfloat32m1_t v7 = __riscv_vle32_v_f32m1 ((void *) it, vl);
37 it += vl;
38
39 asm volatile("nop" ::: "memory");
40 vint64m2_t vw0 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v0, vl);
41 vint64m2_t vw1 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v1, vl);
42 vint64m2_t vw2 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v2, vl);
43 vint64m2_t vw3 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v3, vl);
44 vint64m2_t vw4 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v4, vl);
45 vint64m2_t vw5 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v5, vl);
46 vint64m2_t vw6 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v6, vl);
47 vint64m2_t vw7 = __riscv_vfwcvt_rtz_x_f_v_i64m2 (v7, vl);
48
49 asm volatile("nop" ::: "memory");
50 double sum0 = __riscv_vmv_x_s_i64m2_i64 (vw0);
51 double sum1 = __riscv_vmv_x_s_i64m2_i64 (vw1);
52 double sum2 = __riscv_vmv_x_s_i64m2_i64 (vw2);
53 double sum3 = __riscv_vmv_x_s_i64m2_i64 (vw3);
54 double sum4 = __riscv_vmv_x_s_i64m2_i64 (vw4);
55 double sum5 = __riscv_vmv_x_s_i64m2_i64 (vw5);
56 double sum6 = __riscv_vmv_x_s_i64m2_i64 (vw6);
57 double sum7 = __riscv_vmv_x_s_i64m2_i64 (vw7);
58
59 sum += sumation (sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7);
60 }
61 return sum;
62 }
63
64 double
65 foo2 (char const *buf, size_t len)
66 {
67 double sum = 0;
68 size_t vl = __riscv_vsetvlmax_e8m8 ();
69 size_t step = vl * 4;
70 const char *it = buf, *end = buf + len;
71 for (; it + step <= end;)
72 {
73 vfloat32m1_t v0 = __riscv_vle32_v_f32m1 ((void *) it, vl);
74 it += vl;
75 vfloat32m1_t v1 = __riscv_vle32_v_f32m1 ((void *) it, vl);
76 it += vl;
77 vfloat32m1_t v2 = __riscv_vle32_v_f32m1 ((void *) it, vl);
78 it += vl;
79 vfloat32m1_t v3 = __riscv_vle32_v_f32m1 ((void *) it, vl);
80 it += vl;
81 vfloat32m1_t v4 = __riscv_vle32_v_f32m1 ((void *) it, vl);
82 it += vl;
83 vfloat32m1_t v5 = __riscv_vle32_v_f32m1 ((void *) it, vl);
84 it += vl;
85 vfloat32m1_t v6 = __riscv_vle32_v_f32m1 ((void *) it, vl);
86 it += vl;
87 vfloat32m1_t v7 = __riscv_vle32_v_f32m1 ((void *) it, vl);
88 it += vl;
89
90 asm volatile("nop" ::: "memory");
91 vint64m2_t vw0 = __riscv_vfwcvt_x_f_v_i64m2 (v0, vl);
92 vint64m2_t vw1 = __riscv_vfwcvt_x_f_v_i64m2 (v1, vl);
93 vint64m2_t vw2 = __riscv_vfwcvt_x_f_v_i64m2 (v2, vl);
94 vint64m2_t vw3 = __riscv_vfwcvt_x_f_v_i64m2 (v3, vl);
95 vint64m2_t vw4 = __riscv_vfwcvt_x_f_v_i64m2 (v4, vl);
96 vint64m2_t vw5 = __riscv_vfwcvt_x_f_v_i64m2 (v5, vl);
97 vint64m2_t vw6 = __riscv_vfwcvt_x_f_v_i64m2 (v6, vl);
98 vint64m2_t vw7 = __riscv_vfwcvt_x_f_v_i64m2 (v7, vl);
99
100 asm volatile("nop" ::: "memory");
101 double sum0 = __riscv_vmv_x_s_i64m2_i64 (vw0);
102 double sum1 = __riscv_vmv_x_s_i64m2_i64 (vw1);
103 double sum2 = __riscv_vmv_x_s_i64m2_i64 (vw2);
104 double sum3 = __riscv_vmv_x_s_i64m2_i64 (vw3);
105 double sum4 = __riscv_vmv_x_s_i64m2_i64 (vw4);
106 double sum5 = __riscv_vmv_x_s_i64m2_i64 (vw5);
107 double sum6 = __riscv_vmv_x_s_i64m2_i64 (vw6);
108 double sum7 = __riscv_vmv_x_s_i64m2_i64 (vw7);
109
110 sum += sumation (sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7);
111 }
112 return sum;
113 }
114
115 /* { dg-final { scan-assembler-not {vmv1r} } } */
116 /* { dg-final { scan-assembler-not {vmv2r} } } */
117 /* { dg-final { scan-assembler-not {vmv4r} } } */
118 /* { dg-final { scan-assembler-not {vmv8r} } } */
119 /* { dg-final { scan-assembler-not {csrr} } } */