Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/vls-vlmax/vec_set-zvfh-run.c

raw
1 /* { dg-do run { target { riscv_zvfh } } } */
2 /* { dg-additional-options "-std=gnu99 -Wno-pedantic" } */
3
4 #include <assert.h>
5
6 #include "vec_set-1.c"
7 #include "vec_set-2.c"
8 #include "vec_set-3.c"
9 #include "vec_set-4.c"
10
11 #define CHECK(S, V, IDX) \
12 void check_##V##_##IDX () \
13 { \
14 V v; \
15 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
16 v[i] = i; \
17 V res = vec_set_##V##_##IDX (v, 77); \
18 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
19 assert (res[i] == (i == IDX ? 77 : i)); \
20 }
21
22 #define CHECK_VAR(S, V) \
23 void check_var_##V (int32_t idx) \
24 { \
25 V v; \
26 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
27 v[i] = i; \
28 V res = vec_set_var_##V (v, idx, 77); \
29 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
30 assert (res[i] == (i == idx ? 77 : i)); \
31 }
32
33 #define RUN(S, V, IDX) \
34 check_##V##_##IDX ();
35
36 #define RUN_VAR(S, V) \
37 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
38 check_var_##V (i); \
39
40 #define RUN_ALL(T) \
41 T (_Float16, vnx8hf, 0) \
42 T (_Float16, vnx8hf, 3) \
43 T (_Float16, vnx8hf, 7) \
44 T (_Float16, vnx16hf, 0) \
45 T (_Float16, vnx16hf, 3) \
46 T (_Float16, vnx16hf, 7) \
47 T (_Float16, vnx16hf, 8) \
48 T (_Float16, vnx16hf, 15) \
49 T (_Float16, vnx32hf, 0) \
50 T (_Float16, vnx32hf, 3) \
51 T (_Float16, vnx32hf, 7) \
52 T (_Float16, vnx32hf, 8) \
53 T (_Float16, vnx32hf, 16) \
54 T (_Float16, vnx32hf, 31) \
55 T (_Float16, vnx64hf, 0) \
56 T (_Float16, vnx64hf, 3) \
57 T (_Float16, vnx64hf, 7) \
58 T (_Float16, vnx64hf, 8) \
59 T (_Float16, vnx64hf, 16) \
60 T (_Float16, vnx64hf, 31) \
61 T (_Float16, vnx64hf, 42) \
62 T (_Float16, vnx64hf, 63) \
63
64 #define RUN_ALL_VAR(T) \
65 T (_Float16, vnx8hf) \
66 T (_Float16, vnx16hf) \
67 T (_Float16, vnx32hf) \
68 T (_Float16, vnx64hf) \
69
70 RUN_ALL (CHECK)
71 RUN_ALL_VAR (CHECK_VAR)
72
73 int main ()
74 {
75 RUN_ALL (RUN);
76 RUN_ALL_VAR (RUN_VAR);
77 }