[AArch64] SVE tests
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / scalar-vca.c
blob40a359725eb2c5125a1bef911084cf5249152df0
1 /* { dg-do run } */
2 /* { dg-options "-O3 --save-temps" } */
4 #include <arm_neon.h>
6 extern void abort (void);
7 extern float fabsf (float);
8 extern double fabs (double);
10 #define NUM_TESTS 8
12 float input_s1[] = {0.1f, -0.1f, 0.4f, 10.3f, 200.0f, -800.0f, -13.0f, -0.5f};
13 float input_s2[] = {-0.2f, 0.4f, 0.04f, -100.3f, 2.0f, -80.0f, 13.0f, -0.5f};
14 double input_d1[] = {0.1, -0.1, 0.4, 10.3, 200.0, -800.0, -13.0, -0.5};
15 double input_d2[] = {-0.2, 0.4, 0.04, -100.3, 2.0, -80.0, 13.0, -0.5};
17 #define TEST(TEST, CMP, SUFFIX, WIDTH, F) \
18 int \
19 test_fca##TEST##SUFFIX##_float##WIDTH##_t (void) \
20 { \
21 int ret = 0; \
22 int i = 0; \
23 uint##WIDTH##_t output[NUM_TESTS]; \
25 for (i = 0; i < NUM_TESTS; i++) \
26 { \
27 float##WIDTH##_t f1 = fabs##F (input_##SUFFIX##1[i]); \
28 float##WIDTH##_t f2 = fabs##F (input_##SUFFIX##2[i]); \
29 /* Inhibit optimization of our linear test loop. */ \
30 asm volatile ("" : : : "memory"); \
31 output[i] = f1 CMP f2 ? -1 : 0; \
32 } \
34 for (i = 0; i < NUM_TESTS; i++) \
35 { \
36 output[i] = vca##TEST##SUFFIX##_f##WIDTH (input_##SUFFIX##1[i], \
37 input_##SUFFIX##2[i]) \
38 ^ output[i]; \
39 /* Inhibit autovectorization of our scalar test loop. */ \
40 asm volatile ("" : : : "memory"); \
41 } \
43 for (i = 0; i < NUM_TESTS; i++) \
44 ret |= output[i]; \
46 return ret; \
49 TEST (ge, >=, s, 32, f)
50 /* { dg-final { scan-assembler "facge\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
51 TEST (ge, >=, d, 64, )
52 /* { dg-final { scan-assembler "facge\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
53 TEST (gt, >, s, 32, f)
54 /* { dg-final { scan-assembler "facgt\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */
55 TEST (gt, >, d, 64, )
56 /* { dg-final { scan-assembler "facgt\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */
58 int
59 main (int argc, char **argv)
61 if (test_fcages_float32_t ())
62 abort ();
63 if (test_fcaged_float64_t ())
64 abort ();
65 if (test_fcagts_float32_t ())
66 abort ();
67 if (test_fcagtd_float64_t ())
68 abort ();
69 return 0;