Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-17.c

raw
1 /* { dg-do run { target { riscv_v } } } */
2 /* { dg-additional-options "-mrvv-vector-bits=scalable" } */
3
4 #include "slp-17.c"
5
6 #define LIMIT 256
7 void __attribute__ ((optimize (0)))
8 f_golden (uint8_t *restrict a, uint8_t *restrict b, uint8_t *restrict c,
9 uint8_t *restrict d, int n)
10 {
11 for (int i = 0; i < n; ++i)
12 {
13 a[i * 8] = c[i * 8] + d[i * 8];
14 a[i * 8 + 1] = c[i * 8] + d[i * 8 + 1];
15 a[i * 8 + 2] = c[i * 8 + 2] + d[i * 8 + 2];
16 a[i * 8 + 3] = c[i * 8 + 2] + d[i * 8 + 3];
17 a[i * 8 + 4] = c[i * 8 + 4] + d[i * 8 + 4];
18 a[i * 8 + 5] = c[i * 8 + 4] + d[i * 8 + 5];
19 a[i * 8 + 6] = c[i * 8 + 6] + d[i * 8 + 6];
20 a[i * 8 + 7] = c[i * 8 + 6] + d[i * 8 + 7];
21 b[i * 8] = c[i * 8 + 1] + d[i * 8];
22 b[i * 8 + 1] = c[i * 8 + 1] + d[i * 8 + 1];
23 b[i * 8 + 2] = c[i * 8 + 3] + d[i * 8 + 2];
24 b[i * 8 + 3] = c[i * 8 + 3] + d[i * 8 + 3];
25 b[i * 8 + 4] = c[i * 8 + 5] + d[i * 8 + 4];
26 b[i * 8 + 5] = c[i * 8 + 5] + d[i * 8 + 5];
27 b[i * 8 + 6] = c[i * 8 + 7] + d[i * 8 + 6];
28 b[i * 8 + 7] = c[i * 8 + 7] + d[i * 8 + 7];
29 }
30 }
31
32 int
33 main (void)
34 {
35 #define RUN(NUM) \
36 uint8_t a_##NUM[NUM * 8 + 8] = {0}; \
37 uint8_t a_golden_##NUM[NUM * 8 + 8] = {0}; \
38 uint8_t b_##NUM[NUM * 8 + 8] = {0}; \
39 uint8_t b_golden_##NUM[NUM * 8 + 8] = {0}; \
40 uint8_t c_##NUM[NUM * 8 + 8] = {0}; \
41 uint8_t d_##NUM[NUM * 8 + 8] = {0}; \
42 for (int i = 0; i < NUM * 8 + 8; i++) \
43 { \
44 if (i % NUM == 0) \
45 c_##NUM[i] = (i + NUM) % LIMIT; \
46 else \
47 c_##NUM[i] = (i * 3) % LIMIT; \
48 if (i % 2 == 0) \
49 d_##NUM[i] = i % LIMIT; \
50 else \
51 d_##NUM[i] = (i * 7) % LIMIT; \
52 } \
53 f (a_##NUM, b_##NUM, c_##NUM, d_##NUM, NUM); \
54 f_golden (a_golden_##NUM, b_golden_##NUM, c_##NUM, d_##NUM, NUM); \
55 for (int i = 0; i < NUM * 8 + 8; i++) \
56 { \
57 if (a_##NUM[i] != a_golden_##NUM[i]) \
58 __builtin_abort (); \
59 if (b_##NUM[i] != b_golden_##NUM[i]) \
60 __builtin_abort (); \
61 }
62
63 RUN (3);
64 RUN (5);
65 RUN (15);
66 RUN (16);
67 RUN (17);
68 RUN (31);
69 RUN (32);
70 RUN (33);
71 RUN (63);
72 RUN (64);
73 RUN (65);
74 RUN (127);
75 RUN (128);
76 RUN (129);
77 RUN (239);
78 RUN (359);
79 RUN (498);
80 RUN (799);
81 RUN (977);
82 RUN (5789);
83 return 0;
84 }