2014-11-18 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vcls.c
blob1d56c126f2205df765acd9462443daf746514507
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected results. */
6 VECT_VAR_DECL(expected,int,8,8) [] = { 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6 };
7 VECT_VAR_DECL(expected,int,16,4) [] = { 0x2, 0x2, 0x2, 0x2 };
8 VECT_VAR_DECL(expected,int,32,2) [] = { 0x19, 0x19 };
9 VECT_VAR_DECL(expected,int,64,1) [] = { 0x3333333333333333 };
10 VECT_VAR_DECL(expected,uint,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
11 0x33, 0x33, 0x33, 0x33 };
12 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
13 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x33333333, 0x33333333 };
14 VECT_VAR_DECL(expected,uint,64,1) [] = { 0x3333333333333333 };
15 VECT_VAR_DECL(expected,poly,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
16 0x33, 0x33, 0x33, 0x33 };
17 VECT_VAR_DECL(expected,poly,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
18 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x33333333, 0x33333333 };
19 VECT_VAR_DECL(expected,int,8,16) [] = { 0x7, 0x7, 0x7, 0x7,
20 0x7, 0x7, 0x7, 0x7,
21 0x7, 0x7, 0x7, 0x7,
22 0x7, 0x7, 0x7, 0x7 };
23 VECT_VAR_DECL(expected,int,16,8) [] = { 0x2, 0x2, 0x2, 0x2,
24 0x2, 0x2, 0x2, 0x2 };
25 VECT_VAR_DECL(expected,int,32,4) [] = { 0x14, 0x14, 0x14, 0x14 };
26 VECT_VAR_DECL(expected,int,64,2) [] = { 0x3333333333333333,
27 0x3333333333333333 };
28 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
29 0x33, 0x33, 0x33, 0x33,
30 0x33, 0x33, 0x33, 0x33,
31 0x33, 0x33, 0x33, 0x33 };
32 VECT_VAR_DECL(expected,uint,16,8) [] = { 0x3333, 0x3333, 0x3333, 0x3333,
33 0x3333, 0x3333, 0x3333, 0x3333 };
34 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x33333333, 0x33333333,
35 0x33333333, 0x33333333 };
36 VECT_VAR_DECL(expected,uint,64,2) [] = { 0x3333333333333333,
37 0x3333333333333333 };
38 VECT_VAR_DECL(expected,poly,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
39 0x33, 0x33, 0x33, 0x33,
40 0x33, 0x33, 0x33, 0x33,
41 0x33, 0x33, 0x33, 0x33 };
42 VECT_VAR_DECL(expected,poly,16,8) [] = { 0x3333, 0x3333, 0x3333, 0x3333,
43 0x3333, 0x3333, 0x3333, 0x3333 };
44 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0x33333333, 0x33333333,
45 0x33333333, 0x33333333 };
47 /* Expected results with negative input. */
48 VECT_VAR_DECL(expected_with_negative,int,8,8) [] = { 0x7, 0x7, 0x7, 0x7,
49 0x7, 0x7, 0x7, 0x7 };
50 VECT_VAR_DECL(expected_with_negative,int,16,4) [] = { 0x1, 0x1, 0x1, 0x1 };
51 VECT_VAR_DECL(expected_with_negative,int,32,2) [] = { 0x1, 0x1 };
52 VECT_VAR_DECL(expected_with_negative,int,64,1) [] = { 0x3333333333333333 };
53 VECT_VAR_DECL(expected_with_negative,uint,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
54 0x33, 0x33, 0x33, 0x33 };
55 VECT_VAR_DECL(expected_with_negative,uint,16,4) [] = { 0x3333, 0x3333,
56 0x3333, 0x3333 };
57 VECT_VAR_DECL(expected_with_negative,uint,32,2) [] = { 0x33333333, 0x33333333 };
58 VECT_VAR_DECL(expected_with_negative,uint,64,1) [] = { 0x3333333333333333 };
59 VECT_VAR_DECL(expected_with_negative,poly,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
60 0x33, 0x33, 0x33, 0x33 };
61 VECT_VAR_DECL(expected_with_negative,poly,16,4) [] = { 0x3333, 0x3333,
62 0x3333, 0x3333 };
63 VECT_VAR_DECL(expected_with_negative,hfloat,32,2) [] = { 0x33333333,
64 0x33333333 };
65 VECT_VAR_DECL(expected_with_negative,int,8,16) [] = { 0x0, 0x0, 0x0, 0x0,
66 0x0, 0x0, 0x0, 0x0,
67 0x0, 0x0, 0x0, 0x0,
68 0x0, 0x0, 0x0, 0x0 };
69 VECT_VAR_DECL(expected_with_negative,int,16,8) [] = { 0x2, 0x2, 0x2, 0x2,
70 0x2, 0x2, 0x2, 0x2 };
71 VECT_VAR_DECL(expected_with_negative,int,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
72 VECT_VAR_DECL(expected_with_negative,int,64,2) [] = { 0x3333333333333333,
73 0x3333333333333333 };
74 VECT_VAR_DECL(expected_with_negative,uint,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
75 0x33, 0x33, 0x33, 0x33,
76 0x33, 0x33, 0x33, 0x33,
77 0x33, 0x33, 0x33, 0x33 };
78 VECT_VAR_DECL(expected_with_negative,uint,16,8) [] = { 0x3333, 0x3333,
79 0x3333, 0x3333,
80 0x3333, 0x3333,
81 0x3333, 0x3333 };
82 VECT_VAR_DECL(expected_with_negative,uint,32,4) [] = { 0x33333333, 0x33333333,
83 0x33333333, 0x33333333 };
84 VECT_VAR_DECL(expected_with_negative,uint,64,2) [] = { 0x3333333333333333,
85 0x3333333333333333 };
86 VECT_VAR_DECL(expected_with_negative,poly,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
87 0x33, 0x33, 0x33, 0x33,
88 0x33, 0x33, 0x33, 0x33,
89 0x33, 0x33, 0x33, 0x33 };
90 VECT_VAR_DECL(expected_with_negative,poly,16,8) [] = { 0x3333, 0x3333,
91 0x3333, 0x3333,
92 0x3333, 0x3333,
93 0x3333, 0x3333 };
94 VECT_VAR_DECL(expected_with_negative,hfloat,32,4) [] = { 0x33333333,
95 0x33333333,
96 0x33333333,
97 0x33333333 };
99 #define INSN_NAME vcls
100 #define TEST_MSG "VCLS/VCLSQ"
102 #define FNNAME1(NAME) void exec_ ## NAME (void)
103 #define FNNAME(NAME) FNNAME1(NAME)
105 FNNAME (INSN_NAME)
107 /* Basic test: y=vcls(x), then store the result. */
108 #define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
109 VECT_VAR(vector_res, T1, W, N) = \
110 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
111 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
113 #define TEST_UNARY_OP(INSN, Q, T1, T2, W, N) \
114 TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
116 /* No need for 64 bits variants. */
117 DECL_VARIABLE(vector, int, 8, 8);
118 DECL_VARIABLE(vector, int, 16, 4);
119 DECL_VARIABLE(vector, int, 32, 2);
120 DECL_VARIABLE(vector, int, 8, 16);
121 DECL_VARIABLE(vector, int, 16, 8);
122 DECL_VARIABLE(vector, int, 32, 4);
124 DECL_VARIABLE(vector_res, int, 8, 8);
125 DECL_VARIABLE(vector_res, int, 16, 4);
126 DECL_VARIABLE(vector_res, int, 32, 2);
127 DECL_VARIABLE(vector_res, int, 8, 16);
128 DECL_VARIABLE(vector_res, int, 16, 8);
129 DECL_VARIABLE(vector_res, int, 32, 4);
131 clean_results ();
133 /* Fill input vector with arbitrary values. */
134 VDUP(vector, , int, s, 8, 8, 0x1);
135 VDUP(vector, , int, s, 16, 4, 0x1234);
136 VDUP(vector, , int, s, 32, 2, 0x34);
137 VDUP(vector, q, int, s, 8, 16, 0);
138 VDUP(vector, q, int, s, 16, 8, 0x1234);
139 VDUP(vector, q, int, s, 32, 4, 0x678);
141 /* Apply a unary operator named INSN_NAME. */
142 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
143 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
144 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
145 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
146 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
147 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
149 CHECK_RESULTS (TEST_MSG, " (positive input)");
151 /* Fill input vector with arbitrary values (negative). */
152 VDUP(vector, , int, s, 8, 8, 0xFF);
153 VDUP(vector, , int, s, 16, 4, 0xC234);
154 VDUP(vector, , int, s, 32, 2, 0xDEAD0034);
155 VDUP(vector, q, int, s, 8, 16, 0x80);
156 VDUP(vector, q, int, s, 16, 8, 0xE234);
157 VDUP(vector, q, int, s, 32, 4, 0xBEEF0678);
159 /* Apply a unary operator named INSN_NAME */
160 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
161 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
162 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
163 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
164 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
165 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
167 CHECK_RESULTS_NAMED (TEST_MSG, expected_with_negative, " (negative input)");
170 int main (void)
172 exec_vcls ();
173 return 0;