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,16,4) [] = { 0xffe1, 0xffe5, 0xffe9, 0xffed };
7 VECT_VAR_DECL(expected,int,32,2) [] = { 0xffffffe1, 0xffffffe5 };
8 VECT_VAR_DECL(expected,int,64,1) [] = { 0xffffffffffffffe1 };
9 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x1e1, 0x1e5, 0x1e9, 0x1ed };
10 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x1ffe1, 0x1ffe5 };
11 VECT_VAR_DECL(expected,uint,64,1) [] = { 0x1ffffffe1 };
12 VECT_VAR_DECL(expected,int,16,8) [] = { 0xffe1, 0xffe5, 0xffe9, 0xffed,
13 0xfff1, 0xfff5, 0xfff9, 0xfffd };
14 VECT_VAR_DECL(expected,int,32,4) [] = { 0xffffffe1, 0xffffffe5,
15 0xffffffe9, 0xffffffed };
16 VECT_VAR_DECL(expected,int,64,2) [] = { 0xffffffffffffffe1,
17 0xffffffffffffffe5 };
18 VECT_VAR_DECL(expected,uint,16,8) [] = { 0x1e1, 0x1e5, 0x1e9, 0x1ed,
19 0x1f1, 0x1f5, 0x1f9, 0x1fd };
20 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x1ffe1, 0x1ffe5, 0x1ffe9, 0x1ffed };
21 VECT_VAR_DECL(expected,uint,64,2) [] = { 0x1ffffffe1, 0x1ffffffe5 };
22
23 #define INSN_NAME vpaddl
24 #define TEST_MSG "VPADDL/VPADDLQ"
25
26 #define FNNAME1(NAME) void exec_ ## NAME (void)
27 #define FNNAME(NAME) FNNAME1(NAME)
28
FNNAME(INSN_NAME)29 FNNAME (INSN_NAME)
30 {
31 /* Basic test: y=OP(x), then store the result. */
32 #define TEST_VPADDL1(INSN, Q, T1, T2, W, N, W2, N2) \
33 VECT_VAR(vector_res, T1, W2, N2) = \
34 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
35 vst1##Q##_##T2##W2(VECT_VAR(result, T1, W2, N2), \
36 VECT_VAR(vector_res, T1, W2, N2))
37
38 #define TEST_VPADDL(INSN, Q, T1, T2, W, N, W2, N2) \
39 TEST_VPADDL1(INSN, Q, T1, T2, W, N, W2, N2)
40
41 /* No need for 64 bits elements variants. */
42 DECL_VARIABLE(vector, int, 8, 8);
43 DECL_VARIABLE(vector, int, 16, 4);
44 DECL_VARIABLE(vector, int, 32, 2);
45 DECL_VARIABLE(vector, uint, 8, 8);
46 DECL_VARIABLE(vector, uint, 16, 4);
47 DECL_VARIABLE(vector, uint, 32, 2);
48 DECL_VARIABLE(vector, int, 8, 16);
49 DECL_VARIABLE(vector, int, 16, 8);
50 DECL_VARIABLE(vector, int, 32, 4);
51 DECL_VARIABLE(vector, uint, 8, 16);
52 DECL_VARIABLE(vector, uint, 16, 8);
53 DECL_VARIABLE(vector, uint, 32, 4);
54
55 DECL_VARIABLE(vector_res, int, 16, 4);
56 DECL_VARIABLE(vector_res, int, 32, 2);
57 DECL_VARIABLE(vector_res, int, 64, 1);
58 DECL_VARIABLE(vector_res, uint, 16, 4);
59 DECL_VARIABLE(vector_res, uint, 32, 2);
60 DECL_VARIABLE(vector_res, uint, 64, 1);
61 DECL_VARIABLE(vector_res, int, 16, 8);
62 DECL_VARIABLE(vector_res, int, 32, 4);
63 DECL_VARIABLE(vector_res, int, 64, 2);
64 DECL_VARIABLE(vector_res, uint, 16, 8);
65 DECL_VARIABLE(vector_res, uint, 32, 4);
66 DECL_VARIABLE(vector_res, uint, 64, 2);
67
68 clean_results ();
69
70 /* Initialize input "vector" from "buffer". */
71 VLOAD(vector, buffer, , int, s, 8, 8);
72 VLOAD(vector, buffer, , int, s, 16, 4);
73 VLOAD(vector, buffer, , int, s, 32, 2);
74 VLOAD(vector, buffer, , uint, u, 8, 8);
75 VLOAD(vector, buffer, , uint, u, 16, 4);
76 VLOAD(vector, buffer, , uint, u, 32, 2);
77 VLOAD(vector, buffer, q, int, s, 8, 16);
78 VLOAD(vector, buffer, q, int, s, 16, 8);
79 VLOAD(vector, buffer, q, int, s, 32, 4);
80 VLOAD(vector, buffer, q, uint, u, 8, 16);
81 VLOAD(vector, buffer, q, uint, u, 16, 8);
82 VLOAD(vector, buffer, q, uint, u, 32, 4);
83
84 /* Apply a unary operator named INSN_NAME. */
85 TEST_VPADDL(INSN_NAME, , int, s, 8, 8, 16, 4);
86 TEST_VPADDL(INSN_NAME, , int, s, 16, 4, 32, 2);
87 TEST_VPADDL(INSN_NAME, , int, s, 32, 2, 64, 1);
88 TEST_VPADDL(INSN_NAME, , uint, u, 8, 8, 16, 4);
89 TEST_VPADDL(INSN_NAME, , uint, u, 16, 4, 32, 2);
90 TEST_VPADDL(INSN_NAME, , uint, u, 32, 2, 64, 1);
91 TEST_VPADDL(INSN_NAME, q, int, s, 8, 16, 16, 8);
92 TEST_VPADDL(INSN_NAME, q, int, s, 16, 8, 32, 4);
93 TEST_VPADDL(INSN_NAME, q, int, s, 32, 4, 64, 2);
94 TEST_VPADDL(INSN_NAME, q, uint, u, 8, 16, 16, 8);
95 TEST_VPADDL(INSN_NAME, q, uint, u, 16, 8, 32, 4);
96 TEST_VPADDL(INSN_NAME, q, uint, u, 32, 4, 64, 2);
97
98 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
99 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
100 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, "");
101 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, "");
102 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
103 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, "");
104 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
105 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
106 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, "");
107 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, "");
108 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
109 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, "");
110 }
111
main(void)112 int main (void)
113 {
114 exec_vpaddl ();
115 return 0;
116 }
117