[AArch64] SVE tests
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / sve / vcond_1_run.C
blob2df33710d8fa89e7f0810dd8bf23551921c9d9b7
1 /* { dg-do run { target aarch64_sve_hw } } */
2 /* { dg-options "-O" } */
3 /* { dg-options "-O -msve-vector-bits=256" { target aarch64_sve256_hw } } */
5 #include "vcond_1.C"
7 #define NUM_ELEMS(X) (sizeof (X) / sizeof (X[0]))
9 #define TEST_VCOND_VAR(TYPE, COND, SUFFIX)              \
10 {                                                       \
11   TYPE x, y, a, b;                                      \
12   for (int i = 0; i < NUM_ELEMS (x); ++i)               \
13     {                                                   \
14       a[i] = i - 2;                                     \
15       b[i] = NUM_ELEMS (x) - 2 - i;                     \
16       x[i] = i * 2;                                     \
17       y[i] = -i * 3;                                    \
18     }                                                   \
19   TYPE r = vcond_##TYPE##_##SUFFIX (x, y, a, b);        \
20   for (int i = 0; i < NUM_ELEMS (x); ++i)               \
21     if (r[i] != (a[i] COND b[i] ? x[i] : y[i]))         \
22       __builtin_abort ();                               \
25 #define TEST_VCOND_IMM(TYPE, COND, IMM, SUFFIX)         \
26 {                                                       \
27   TYPE x, y, a;                                         \
28   for (int i = 0; i < NUM_ELEMS (x); ++i)               \
29     {                                                   \
30       a[i] = IMM - 2 + i;                               \
31       x[i] = i * 2;                                     \
32       y[i] = -i * 3;                                    \
33     }                                                   \
34   TYPE r = vcond_imm_##TYPE##_##SUFFIX (x, y, a);       \
35   for (int i = 0; i < NUM_ELEMS (x); ++i)               \
36     if (r[i] != (a[i] COND IMM ? x[i] : y[i]))          \
37       __builtin_abort ();                               \
41 int main (int argc, char **argv)
43   TEST_VAR_ALL (TEST_VCOND_VAR)
44   TEST_IMM_ALL (TEST_VCOND_IMM)
45   return 0;