Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c

raw
1 /* { dg-do run { target { riscv_v } } } */
2 /* { dg-additional-options "-mcmodel=medany" } */
3
4 #include "strided_load-1.c"
5 #include <assert.h>
6
7 int
8 main (void)
9 {
10 /* FIXME: The purpose of this assembly is to ensure that the vtype register is
11 initialized befor instructions such as vmv1r.v are executed. Otherwise you
12 will get illegal instruction errors when running with spike+pk. This is an
13 interim solution for reduce unnecessary failures and a unified solution
14 will come later. */
15 asm volatile("vsetivli x0, 0, e8, m1, ta, ma");
16 #define RUN_LOOP(DATA_TYPE, BITS) \
17 DATA_TYPE dest_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)]; \
18 DATA_TYPE dest2_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)]; \
19 DATA_TYPE src_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)]; \
20 INDEX##BITS stride_##DATA_TYPE##_##BITS = (BITS - 3); \
21 INDEX##BITS n_##DATA_TYPE##_##BITS = (BITS + 13); \
22 for (INDEX##BITS i = 0; \
23 i < stride_##DATA_TYPE##_##BITS * n_##DATA_TYPE##_##BITS; i++) \
24 { \
25 dest_##DATA_TYPE##_##BITS[i] \
26 = (DATA_TYPE) ((i * 81 + 735) & (BITS - 1)); \
27 dest2_##DATA_TYPE##_##BITS[i] \
28 = (DATA_TYPE) ((i * 81 + 735) & (BITS - 1)); \
29 src_##DATA_TYPE##_##BITS[i] \
30 = (DATA_TYPE) ((i * 13 + 9107) & (BITS - 1)); \
31 } \
32 f_##DATA_TYPE##_##BITS (dest_##DATA_TYPE##_##BITS, src_##DATA_TYPE##_##BITS, \
33 stride_##DATA_TYPE##_##BITS, \
34 n_##DATA_TYPE##_##BITS); \
35 for (int i = 0; i < n_##DATA_TYPE##_##BITS; i++) \
36 { \
37 assert ( \
38 dest_##DATA_TYPE##_##BITS[i] \
39 == (dest2_##DATA_TYPE##_##BITS[i] \
40 + src_##DATA_TYPE##_##BITS[i * stride_##DATA_TYPE##_##BITS])); \
41 }
42
43 RUN_LOOP (int8_t, 8)
44 RUN_LOOP (uint8_t, 8)
45 RUN_LOOP (int16_t, 8)
46 RUN_LOOP (uint16_t, 8)
47 RUN_LOOP (_Float16, 8)
48 RUN_LOOP (int32_t, 8)
49 RUN_LOOP (uint32_t, 8)
50 RUN_LOOP (float, 8)
51 RUN_LOOP (int64_t, 8)
52 RUN_LOOP (uint64_t, 8)
53 RUN_LOOP (double, 8)
54
55 RUN_LOOP (int8_t, 16)
56 RUN_LOOP (uint8_t, 16)
57 RUN_LOOP (int16_t, 16)
58 RUN_LOOP (uint16_t, 16)
59 RUN_LOOP (_Float16, 16)
60 RUN_LOOP (int32_t, 16)
61 RUN_LOOP (uint32_t, 16)
62 RUN_LOOP (float, 16)
63 RUN_LOOP (int64_t, 16)
64 RUN_LOOP (uint64_t, 16)
65 RUN_LOOP (double, 16)
66
67 RUN_LOOP (int8_t, 32)
68 RUN_LOOP (uint8_t, 32)
69 RUN_LOOP (int16_t, 32)
70 RUN_LOOP (uint16_t, 32)
71 RUN_LOOP (_Float16, 32)
72 RUN_LOOP (int32_t, 32)
73 RUN_LOOP (uint32_t, 32)
74 RUN_LOOP (float, 32)
75 RUN_LOOP (int64_t, 32)
76 RUN_LOOP (uint64_t, 32)
77 RUN_LOOP (double, 32)
78
79 RUN_LOOP (int8_t, 64)
80 RUN_LOOP (uint8_t, 64)
81 RUN_LOOP (int16_t, 64)
82 RUN_LOOP (uint16_t, 64)
83 RUN_LOOP (_Float16, 64)
84 RUN_LOOP (int32_t, 64)
85 RUN_LOOP (uint32_t, 64)
86 RUN_LOOP (float, 64)
87 RUN_LOOP (int64_t, 64)
88 RUN_LOOP (uint64_t, 64)
89 RUN_LOOP (double, 64)
90 return 0;
91 }