New Advanced SIMD intrinsics tests.
[platform/upstream/gcc49.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vabdl.c
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) [] = { 0x33, 0x33, 0x33, 0x33,
7                                        0x33, 0x33, 0x33, 0x33 };
8 VECT_VAR_DECL(expected,int,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
9 VECT_VAR_DECL(expected,int,32,2) [] = { 0x33333333, 0x33333333 };
10 VECT_VAR_DECL(expected,int,64,1) [] = { 0x3333333333333333 };
11 VECT_VAR_DECL(expected,uint,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
12                                         0x33, 0x33, 0x33, 0x33 };
13 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
14 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x33333333, 0x33333333 };
15 VECT_VAR_DECL(expected,uint,64,1) [] = { 0x3333333333333333 };
16 VECT_VAR_DECL(expected,poly,8,8) [] = { 0x33, 0x33, 0x33, 0x33,
17                                         0x33, 0x33, 0x33, 0x33 };
18 VECT_VAR_DECL(expected,poly,16,4) [] = { 0x3333, 0x3333, 0x3333, 0x3333 };
19 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x33333333, 0x33333333 };
20 VECT_VAR_DECL(expected,int,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
21                                         0x33, 0x33, 0x33, 0x33,
22                                         0x33, 0x33, 0x33, 0x33,
23                                         0x33, 0x33, 0x33, 0x33 };
24 VECT_VAR_DECL(expected,int,16,8) [] = { 0x11, 0x10, 0xf, 0xe,
25                                         0xd, 0xc, 0xb, 0xa };
26 VECT_VAR_DECL(expected,int,32,4) [] = { 0x3, 0x2, 0x1, 0x0 };
27 VECT_VAR_DECL(expected,int,64,2) [] = { 0x18, 0x17 };
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) [] = { 0xef, 0xf0, 0xf1, 0xf2,
33                                          0xf3, 0xf4, 0xf5, 0xf6 };
34 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xffe3, 0xffe4, 0xffe5, 0xffe6 };
35 VECT_VAR_DECL(expected,uint,64,2) [] = { 0xffffffe8,
36                                          0xffffffe9 };
37 VECT_VAR_DECL(expected,poly,8,16) [] = { 0x33, 0x33, 0x33, 0x33,
38                                          0x33, 0x33, 0x33, 0x33,
39                                          0x33, 0x33, 0x33, 0x33,
40                                          0x33, 0x33, 0x33, 0x33 };
41 VECT_VAR_DECL(expected,poly,16,8) [] = { 0x3333, 0x3333, 0x3333, 0x3333,
42                                          0x3333, 0x3333, 0x3333, 0x3333 };
43 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0x33333333, 0x33333333,
44                                            0x33333333, 0x33333333 };
45
46 #define TEST_MSG "VABDL"
47 void exec_vabdl (void)
48 {
49   /* Basic test: v4=vabdl(v1,v2), then store the result.  */
50 #define TEST_VABDL(T1, T2, W, W2, N)                                    \
51   VECT_VAR(vector_res, T1, W2, N) =                                     \
52     vabdl_##T2##W(VECT_VAR(vector1, T1, W, N),                          \
53                   VECT_VAR(vector2, T1, W, N));                         \
54   vst1q_##T2##W2(VECT_VAR(result, T1, W2, N), VECT_VAR(vector_res, T1, W2, N))
55
56 #define DECL_VABDL_VAR_LONG(VAR)                \
57   DECL_VARIABLE(VAR, int, 16, 8);               \
58   DECL_VARIABLE(VAR, int, 32, 4);               \
59   DECL_VARIABLE(VAR, int, 64, 2);               \
60   DECL_VARIABLE(VAR, uint, 16, 8);              \
61   DECL_VARIABLE(VAR, uint, 32, 4);              \
62   DECL_VARIABLE(VAR, uint, 64, 2)
63
64 #define DECL_VABDL_VAR_SHORT(VAR)               \
65   DECL_VARIABLE(VAR, int, 8, 8);                \
66   DECL_VARIABLE(VAR, int, 16, 4);               \
67   DECL_VARIABLE(VAR, int, 32, 2);               \
68   DECL_VARIABLE(VAR, uint, 8, 8);               \
69   DECL_VARIABLE(VAR, uint, 16, 4);              \
70   DECL_VARIABLE(VAR, uint, 32, 2)
71
72   DECL_VABDL_VAR_SHORT(vector1);
73   DECL_VABDL_VAR_SHORT(vector2);
74   DECL_VABDL_VAR_LONG(vector_res);
75
76   clean_results ();
77
78   /* Initialize input "vector1" from "buffer".  */
79   VLOAD(vector1, buffer, , int, s, 8, 8);
80   VLOAD(vector1, buffer, , int, s, 16, 4);
81   VLOAD(vector1, buffer, , int, s, 32, 2);
82   VLOAD(vector1, buffer, , uint, u, 8, 8);
83   VLOAD(vector1, buffer, , uint, u, 16, 4);
84   VLOAD(vector1, buffer, , uint, u, 32, 2);
85
86   /* Choose init value arbitrarily.  */
87   VDUP(vector2, , int, s, 8, 8, 1);
88   VDUP(vector2, , int, s, 16, 4, -13);
89   VDUP(vector2, , int, s, 32, 2, 8);
90   VDUP(vector2, , uint, u, 8, 8, 1);
91   VDUP(vector2, , uint, u, 16, 4, 13);
92   VDUP(vector2, , uint, u, 32, 2, 8);
93
94   /* Execute the tests.  */
95   TEST_VABDL(int, s, 8, 16, 8);
96   TEST_VABDL(int, s, 16, 32, 4);
97   TEST_VABDL(int, s, 32, 64, 2);
98   TEST_VABDL(uint, u, 8, 16, 8);
99   TEST_VABDL(uint, u, 16, 32, 4);
100   TEST_VABDL(uint, u, 32, 64, 2);
101
102   CHECK_RESULTS (TEST_MSG, "");
103 }
104
105 int main (void)
106 {
107   exec_vabdl ();
108   return 0;
109 }