[AArch64] Update target testcases for gnu11
[platform/upstream/gcc.git] / gcc / testsuite / gcc.target / aarch64 / vect-fmax-fmin.c
1 /* { dg-do run } */
2 /* { dg-options "-O3 -ffast-math" } */
3
4 extern void abort (void);
5
6 #include "vect-fmax-fmin.x"
7
8 #include "vect-fmaxv-fminv.x"
9
10 #define DEFN_SETV(type) \
11                 void set_vector_##type (pR##type a, type n)   \
12                 {                                             \
13                   int i;                                      \
14                   for (i=0; i<16; i++)                        \
15                     a[i] = n;                                 \
16                 }
17
18 #define DEFN_CHECKV(type) \
19                 void check_vector_##type (pR##type a, pR##type vec) \
20                 {                                                   \
21                   int i;                                            \
22                   for (i=0; i<16; i++)                              \
23                     if (a[i] != vec[i])                             \
24                       abort ();                                     \
25                 }
26
27 #define TEST2(fname, type) \
28                         set_vector_##type (c##type, 0.0);              \
29                         fname##_##type (a##type, b##type);             \
30                         check_vector_##type (c##type, fname##_##type##_vector);
31
32 #define TEST3(fname, type) \
33                         set_vector_##type (c##type, 0.0);              \
34                         fname##_##type (a##type, b##type, c##type);    \
35                         check_vector_##type (c##type, fname##_##type##_vector);
36
37 #define TEST(fname, N) \
38                 TEST##N (fname, F32); \
39                 TEST##N (fname, F64);
40
41 typedef float F32;
42 typedef double F64;
43
44 DEFN_SETV (F32)
45 DEFN_SETV (F64)
46
47 DEFN_CHECKV (F32)
48 DEFN_CHECKV (F64)
49
50 int main (void)
51 {
52
53   F32 aF32[16];
54   F32 bF32[16];
55   F32 cF32[16];
56
57   F64 aF64[16];
58   F64 bF64[16];
59   F64 cF64[16];
60   int i;
61
62   /* Golden vectors.  */
63   F32 max_F32_vector[] = { 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0,
64                            8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
65
66   F64 max_F64_vector[] = { 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0,
67                            8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
68
69   F32 min_F32_vector[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
70                            7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 };
71
72   F64 min_F64_vector[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
73                            7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 };
74
75   F32 minv_F32_value = 0.0f;
76   F32 maxv_F32_value = 15.0f;
77
78   F64 minv_F64_value = 0.0;
79   F64 maxv_F64_value = 15.0;
80
81   /* Setup input vectors.  */
82   for (i=0; i<16; i++)
83     {
84       aF32[i] = (float)(15-i);
85       bF32[i] = (float)i;
86       aF64[i] = (double)(15-i);
87       bF64[i] = (double)i;
88     }
89
90   TEST (max, 3);
91   TEST (min, 3);
92
93   /* Test across lanes ops.  */
94   if (maxv_f32 (max_F32_vector) != maxv_F32_value)
95     abort ();
96   if (minv_f32 (min_F32_vector) != minv_F32_value)
97     abort ();
98
99   if (maxv_f64 (max_F64_vector) != maxv_F64_value)
100     abort ();
101   if (minv_f64 (min_F64_vector) != minv_F64_value)
102     abort ();
103
104   return 0;
105 }