Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vcls.c

raw
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
4
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,8,16) [] = { 0x7, 0x7, 0x7, 0x7,
10 0x7, 0x7, 0x7, 0x7,
11 0x7, 0x7, 0x7, 0x7,
12 0x7, 0x7, 0x7, 0x7 };
13 VECT_VAR_DECL(expected,int,16,8) [] = { 0x2, 0x2, 0x2, 0x2,
14 0x2, 0x2, 0x2, 0x2 };
15 VECT_VAR_DECL(expected,int,32,4) [] = { 0x14, 0x14, 0x14, 0x14 };
16
17 /* Expected results with negative input. */
18 VECT_VAR_DECL(expected_with_negative,int,8,8) [] = { 0x7, 0x7, 0x7, 0x7,
19 0x7, 0x7, 0x7, 0x7 };
20 VECT_VAR_DECL(expected_with_negative,int,16,4) [] = { 0x1, 0x1, 0x1, 0x1 };
21 VECT_VAR_DECL(expected_with_negative,int,32,2) [] = { 0x1, 0x1 };
22 VECT_VAR_DECL(expected_with_negative,int,8,16) [] = { 0x0, 0x0, 0x0, 0x0,
23 0x0, 0x0, 0x0, 0x0,
24 0x0, 0x0, 0x0, 0x0,
25 0x0, 0x0, 0x0, 0x0 };
26 VECT_VAR_DECL(expected_with_negative,int,16,8) [] = { 0x2, 0x2, 0x2, 0x2,
27 0x2, 0x2, 0x2, 0x2 };
28 VECT_VAR_DECL(expected_with_negative,int,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
29
30 #define INSN_NAME vcls
31 #define TEST_MSG "VCLS/VCLSQ"
32
33 #define FNNAME1(NAME) void exec_ ## NAME (void)
34 #define FNNAME(NAME) FNNAME1(NAME)
35
36 FNNAME (INSN_NAME)
37 {
38 /* Basic test: y=vcls(x), then store the result. */
39 #define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
40 VECT_VAR(vector_res, T1, W, N) = \
41 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
42 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
43
44 #define TEST_UNARY_OP(INSN, Q, T1, T2, W, N) \
45 TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
46
47 /* No need for 64 bits variants. */
48 DECL_VARIABLE(vector, int, 8, 8);
49 DECL_VARIABLE(vector, int, 16, 4);
50 DECL_VARIABLE(vector, int, 32, 2);
51 DECL_VARIABLE(vector, int, 8, 16);
52 DECL_VARIABLE(vector, int, 16, 8);
53 DECL_VARIABLE(vector, int, 32, 4);
54
55 DECL_VARIABLE(vector_res, int, 8, 8);
56 DECL_VARIABLE(vector_res, int, 16, 4);
57 DECL_VARIABLE(vector_res, int, 32, 2);
58 DECL_VARIABLE(vector_res, int, 8, 16);
59 DECL_VARIABLE(vector_res, int, 16, 8);
60 DECL_VARIABLE(vector_res, int, 32, 4);
61
62 clean_results ();
63
64 /* Fill input vector with arbitrary values. */
65 VDUP(vector, , int, s, 8, 8, 0x1);
66 VDUP(vector, , int, s, 16, 4, 0x1234);
67 VDUP(vector, , int, s, 32, 2, 0x34);
68 VDUP(vector, q, int, s, 8, 16, 0);
69 VDUP(vector, q, int, s, 16, 8, 0x1234);
70 VDUP(vector, q, int, s, 32, 4, 0x678);
71
72 /* Apply a unary operator named INSN_NAME. */
73 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
74 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
75 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
76 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
77 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
78 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
79
80 #define MSG_POSITIVE " (positive input)"
81 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, MSG_POSITIVE);
82 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, MSG_POSITIVE);
83 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, MSG_POSITIVE);
84 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, MSG_POSITIVE);
85 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, MSG_POSITIVE);
86 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, MSG_POSITIVE);
87
88 /* Fill input vector with arbitrary values (negative). */
89 VDUP(vector, , int, s, 8, 8, 0xFF);
90 VDUP(vector, , int, s, 16, 4, 0xC234);
91 VDUP(vector, , int, s, 32, 2, 0xDEAD0034);
92 VDUP(vector, q, int, s, 8, 16, 0x80);
93 VDUP(vector, q, int, s, 16, 8, 0xE234);
94 VDUP(vector, q, int, s, 32, 4, 0xBEEF0678);
95
96 /* Apply a unary operator named INSN_NAME */
97 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
98 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
99 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
100 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
101 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
102 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
103
104 #define MSG_NEGATIVE " (negative input)"
105 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_with_negative, MSG_NEGATIVE);
106 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_with_negative, MSG_NEGATIVE);
107 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_with_negative, MSG_NEGATIVE);
108 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_with_negative, MSG_NEGATIVE);
109 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_with_negative, MSG_NEGATIVE);
110 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_with_negative, MSG_NEGATIVE);
111 }
112
113 int main (void)
114 {
115 exec_vcls ();
116 return 0;
117 }