Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c

raw
1 /* { dg-do run { target { riscv_v } } } */
2 /* { dg-additional-options "-mrvv-vector-bits=scalable -fno-vect-cost-model" } */
3
4 #include "reduc_strict-1.c"
5
6 #define TEST_REDUC_PLUS(TYPE) \
7 { \
8 TYPE a[NUM_ELEMS (TYPE)]; \
9 TYPE b[NUM_ELEMS (TYPE)]; \
10 TYPE r = 0, q = 3; \
11 for (int i = 0; i < NUM_ELEMS (TYPE); i++) \
12 { \
13 a[i] = (i * 0.1) * (i & 1 ? 1 : -1); \
14 b[i] = (i * 0.3) * (i & 1 ? 1 : -1); \
15 r += a[i]; \
16 q -= b[i]; \
17 asm volatile ("" ::: "memory"); \
18 } \
19 TYPE res = reduc_plus_##TYPE (a, b); \
20 TYPE ref = r * q; \
21 if (res != ref) \
22 __builtin_abort (); \
23 }
24
25 int __attribute__ ((optimize (1)))
26 main ()
27 {
28 TEST_ALL (TEST_REDUC_PLUS);
29 return 0;
30 }