Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr112776.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-mrvv-vector-bits=scalable -march=rv64gcv -mabi=lp64d -O3" } */
3
4 #include "riscv_vector.h"
5
6 void
7 foo (float *r, const float *x)
8 {
9 int i, k;
10
11 vfloat32m4_t x_vec;
12 vfloat32m4_t x_forward_vec;
13 vfloat32m4_t temp_vec;
14 vfloat32m1_t dst_vec;
15 vfloat32m1_t src_vec;
16
17 float result = 0.0f;
18 float shift_prev = 0.0f;
19
20 size_t n = 64;
21 for (size_t vl; n > 0; n -= vl)
22 {
23 vl = __riscv_vsetvl_e32m4 (n);
24 x_vec = __riscv_vle32_v_f32m4 (&x[0], vl);
25 x_forward_vec = __riscv_vle32_v_f32m4 (&x[0], vl);
26 temp_vec = __riscv_vfmul_vv_f32m4 (x_vec, x_forward_vec, vl);
27 src_vec = __riscv_vfmv_s_tu (src_vec, 0.0f, vl);
28 dst_vec = __riscv_vfmv_s_tu (dst_vec, 0.0f, vl);
29 dst_vec = __riscv_vfredosum_tu (dst_vec, temp_vec, src_vec, vl);
30 r[0] = __riscv_vfmv_f_s_f32m1_f32 (dst_vec);
31 }
32 }
33
34 /* { dg-final { scan-assembler-times {vsetvli} 1 } } */
35 /* { dg-final { scan-assembler-not {vsetivli} } } */
36 /* { dg-final { scan-assembler-times {vsetvli\t[a-x0-9]+,\s*[a-x0-9]+,\s*e32,\s*m4,\s*tu,\s*m[au]} 1 } } */