| 1 |
/* { dg-do run {target { riscv_zvfh } } } */ |
| 2 |
/* { dg-additional-options "-std=gnu99 -Wno-pedantic" } */ |
| 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) \ |
| 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 |
S res = vec_extract_##V##_##IDX (v); \ |
| 18 |
assert (res == v[IDX]); \ |
| 19 |
} |
| 20 |
|
| 21 |
#define CHECK_VAR(S, V) \ |
| 22 |
__attribute__ ((noipa)) \ |
| 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 |
S res = vec_extract_var_##V (v, idx); \ |
| 29 |
assert (res == v[idx]); \ |
| 30 |
} |
| 31 |
|
| 32 |
#define RUN(S, V, IDX) \ |
| 33 |
check_##V##_##IDX (); |
| 34 |
|
| 35 |
#define RUN_VAR(S, V) \ |
| 36 |
for (int i = 0; i < sizeof (V) / sizeof (S); i++) \ |
| 37 |
check_var_##V (i); \ |
| 38 |
|
| 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 |
|
| 63 |
#define RUN_ALL_VAR(T) \ |
| 64 |
T (_Float16, vnx8hf) \ |
| 65 |
T (_Float16, vnx16hf) \ |
| 66 |
T (_Float16, vnx32hf) \ |
| 67 |
T (_Float16, vnx64hf) \ |
| 68 |
|
| 69 |
RUN_ALL (CHECK) |
| 70 |
RUN_ALL_VAR (CHECK_VAR) |
| 71 |
|
| 72 |
int main () |
| 73 |
{ |
| 74 |
RUN_ALL (RUN); |
| 75 |
RUN_ALL_VAR (RUN_VAR) |
| 76 |
} |