]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.target/riscv/rvv/autovec/vls-vlmax/vec_extract-zvfh-run.c
RISC-V: Support variable index in vec_extract.
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / riscv / rvv / autovec / vls-vlmax / vec_extract-zvfh-run.c
CommitLineData
51795b91 1/* { dg-do run {target { riscv_zvfh_hw } } } */
62514099 2/* { dg-additional-options "-Wno-pedantic" } */
51795b91
RD
3
4#include <assert.h>
5
6#include "vec_extract-1.c"
7#include "vec_extract-2.c"
8#include "vec_extract-3.c"
9#include "vec_extract-4.c"
10
11#define CHECK(S, V, IDX) \
12void check_##V##_##IDX () \
13 { \
14 V v; \
15 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
16 v[i] = i; \
17 S res = vec_extract_##V##_##IDX (v); \
18 assert (res == v[IDX]); \
19 }
20
573bb719
RD
21#define CHECK_VAR(S, V) \
22__attribute__ ((noipa)) \
23void 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 S res = vec_extract_var_##V (v, idx); \
29 assert (res == v[idx]); \
30 }
51795b91
RD
31
32#define RUN(S, V, IDX) \
33 check_##V##_##IDX ();
34
573bb719
RD
35#define RUN_VAR(S, V) \
36 for (int i = 0; i < sizeof (V) / sizeof (S); i++) \
37 check_var_##V (i); \
38
51795b91
RD
39#define RUN_ALL(T) \
40 T (_Float16, vnx8hf, 0) \
41 T (_Float16, vnx8hf, 3) \
42 T (_Float16, vnx8hf, 7) \
43 T (_Float16, vnx16hf, 0) \
44 T (_Float16, vnx16hf, 3) \
45 T (_Float16, vnx16hf, 7) \
46 T (_Float16, vnx16hf, 8) \
47 T (_Float16, vnx16hf, 15) \
48 T (_Float16, vnx32hf, 0) \
49 T (_Float16, vnx32hf, 3) \
50 T (_Float16, vnx32hf, 7) \
51 T (_Float16, vnx32hf, 8) \
52 T (_Float16, vnx32hf, 16) \
53 T (_Float16, vnx32hf, 31) \
54 T (_Float16, vnx64hf, 0) \
55 T (_Float16, vnx64hf, 3) \
56 T (_Float16, vnx64hf, 7) \
57 T (_Float16, vnx64hf, 8) \
58 T (_Float16, vnx64hf, 16) \
59 T (_Float16, vnx64hf, 31) \
60 T (_Float16, vnx64hf, 42) \
61 T (_Float16, vnx64hf, 63) \
62
573bb719
RD
63#define RUN_ALL_VAR(T) \
64 T (_Float16, vnx8hf) \
65 T (_Float16, vnx16hf) \
66 T (_Float16, vnx32hf) \
67 T (_Float16, vnx64hf) \
68
69RUN_ALL (CHECK)
70RUN_ALL_VAR (CHECK_VAR)
71
51795b91
RD
72int main ()
73{
74 RUN_ALL (RUN);
573bb719 75 RUN_ALL_VAR (RUN_VAR)
51795b91 76}