[PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / vect-abs.c
blob9e0ed99ca6a0e09bc9d96b04d3b46258e98dd49c
2 /* { dg-do run } */
3 /* { dg-options "-O3 -std=c99" } */
5 #include "limits.h"
7 extern void abort (void);
9 #define N 16
11 #include "vect-abs.x"
13 #define SET_VEC(size, type) void set_vector_##size (pRINT##size a) \
14 { \
15 int i; \
16 for (i=0; i<N; i++) \
17 a[i] = (type##_MIN) + (i + 1); \
20 #define SET_RVEC(size, type) void set_rvector_##size (pRINT##size a) \
21 { \
22 int i; \
23 for (i=0; i<N; i++) \
24 a[i] = type##_MAX - i; \
27 #define CHECK_VEC(size) void check_vector_##size (pRINT##size a, \
28 pRINT##size b) \
29 { \
30 int i; \
31 for (i=0; i<N; i++) \
32 if (a[i] != b[i]) \
33 abort (); \
37 SET_RVEC (8, SCHAR)
38 SET_RVEC (16, SHRT)
39 SET_RVEC (32, INT)
40 SET_RVEC (64, LLONG)
42 void
43 set_rvector_long (pRLONG a)
45 int i;
46 for (i=0; i<N; i++)
47 a[i] = (LONG_MAX) - i;
50 SET_VEC (8, SCHAR)
51 SET_VEC (16, SHRT)
52 SET_VEC (32, INT)
53 SET_VEC (64, LLONG)
55 void
56 set_vector_long (long *__restrict__ a)
58 long i;
59 for (i=0; i<N; i++)
60 a[i] = (LONG_MIN) + i + 1;
63 CHECK_VEC (8)
64 CHECK_VEC (16)
65 CHECK_VEC (32)
66 CHECK_VEC (64)
68 void
69 check_vector_long (long *__restrict__ a, long *__restrict__ b)
71 long i;
72 for (i=0; i<N; i++)
73 if (a[i] != b[i])
74 abort ();
77 int main (void)
80 signed char a8[N];
81 short a16[N];
82 int a32[N];
83 long long a64[N];
84 /* abs () from stdlib. */
85 int alib32[N];
86 long alibl[N];
89 signed char b8[N];
90 short b16[N];
91 int b32[N];
92 long long b64[N];
93 /* abs () from stdlib. */
94 long blibl[N];
96 signed char abs_vector_8[N];
97 short abs_vector_16[N];
98 int abs_vector_32[N];
99 long long abs_vector_64[N];
100 long abs_vector_long[N];
102 /* Set up result vectors. */
103 set_rvector_8 (abs_vector_8);
104 set_rvector_16 (abs_vector_16);
105 set_rvector_32 (abs_vector_32);
106 set_rvector_long (abs_vector_long);
107 set_rvector_64 (abs_vector_64);
109 /* Set up inputs. */
110 set_vector_8 (b8);
111 set_vector_16 (b16);
112 set_vector_32 (b32);
113 set_vector_64 (b64);
114 set_vector_long (blibl);
116 /* Calculate their absolute values. */
117 absolute_s8 (a8, b8);
118 absolute_s16 (a16, b16);
119 absolute_s32 (a32, b32);
120 absolute_s64 (a64, b64);
121 /* abs () from stdlib. */
122 absolute_s32_lib (alib32, b32);
123 absolute_l32_lib (alibl, blibl);
125 /* Check. */
126 check_vector_8 (a8, abs_vector_8);
127 check_vector_16 (a16, abs_vector_16);
128 check_vector_32 (a32, abs_vector_32);
129 check_vector_64 (a64, abs_vector_64);
130 check_vector_32 (alib32, abs_vector_32);
131 check_vector_long (alibl, abs_vector_long);
133 return 0;