1 /* { dg-do run { target aarch64_sve_hw } } */
2 /* { dg-options "-O2 -ftree-vectorize" } */
3 /* { dg-require-effective-target fenv_exceptions } */
4
5 #include <fenv.h>
6
7 #include "vcond_17.c"
8
9 #define N 401
10
11 #define TEST_LOOP(CMP, EXPECT_INVALID) \
12 { \
13 __fp16 dest1[N], dest2[N], dest3[N], src[N]; \
14 __fp16 a[N], b[N]; \
15 for (int i = 0; i < N; ++i) \
16 { \
17 src[i] = i * i; \
18 if (i % 5 == 0) \
19 a[i] = 0; \
20 else if (i % 3) \
21 a[i] = i * 0.1; \
22 else \
23 a[i] = i; \
24 if (i % 7 == 0) \
25 b[i] = __builtin_nan (""); \
26 else if (i % 6) \
27 b[i] = i * 0.1; \
28 else \
29 b[i] = i; \
30 asm volatile ("" ::: "memory"); \
31 } \
32 feclearexcept (FE_ALL_EXCEPT); \
33 test_##CMP##_var (dest1, src, 11, a, b, N); \
34 test_##CMP##_zero (dest2, src, 22, a, N); \
35 test_##CMP##_sel (dest3, 33, 44, a, 9, N); \
36 if (!fetestexcept (FE_INVALID) != !(EXPECT_INVALID)) \
37 __builtin_abort (); \
38 for (int i = 0; i < N; ++i) \
39 { \
40 if (dest1[i] != (CMP (a[i], b[i]) ? src[i] : 11)) \
41 __builtin_abort (); \
42 if (dest2[i] != (CMP (a[i], 0) ? src[i] : 22)) \
43 __builtin_abort (); \
44 if (dest3[i] != (CMP (a[i], 9) ? 33 : 44)) \
45 __builtin_abort (); \
46 } \
47 }
48
49 int __attribute__ ((optimize (1)))
main(void)50 main (void)
51 {
52 TEST_ALL (TEST_LOOP)
53 return 0;
54 }
55