[ARM/AArch64][testsuite] Add vmul_lane tests.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vmul_lane.c
blob978cd9b477daba1cb96f31c8ae8c829d302569ab
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,16,4) [] = { 0xffc0, 0xffc4, 0xffc8, 0xffcc };
7 VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffde0, 0xfffffe02 };
8 VECT_VAR_DECL(expected,uint,16,4) [] = { 0xbbc0, 0xc004, 0xc448, 0xc88c };
9 VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffface0, 0xffffb212 };
10 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0xc3b66666, 0xc3ab0000 };
11 VECT_VAR_DECL(expected,int,16,8) [] = { 0xffc0, 0xffc4, 0xffc8, 0xffcc,
12 0xffd0, 0xffd4, 0xffd8, 0xffdc };
13 VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffde0, 0xfffffe02,
14 0xfffffe24, 0xfffffe46 };
15 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xbbc0, 0xc004, 0xc448, 0xc88c,
16 0xccd0, 0xd114, 0xd558, 0xd99c };
17 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffface0, 0xffffb212,
18 0xffffb744, 0xffffbc76 };
19 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc3b66666, 0xc3ab0000,
20 0xc39f9999, 0xc3943333 };
22 #define TEST_MSG "VMUL_LANE"
23 void exec_vmul_lane (void)
25 #define DECL_VMUL(VAR) \
26 DECL_VARIABLE(VAR, int, 16, 4); \
27 DECL_VARIABLE(VAR, int, 32, 2); \
28 DECL_VARIABLE(VAR, uint, 16, 4); \
29 DECL_VARIABLE(VAR, uint, 32, 2); \
30 DECL_VARIABLE(VAR, float, 32, 2); \
31 DECL_VARIABLE(VAR, int, 16, 8); \
32 DECL_VARIABLE(VAR, int, 32, 4); \
33 DECL_VARIABLE(VAR, uint, 16, 8); \
34 DECL_VARIABLE(VAR, uint, 32, 4); \
35 DECL_VARIABLE(VAR, float, 32, 4)
37 /* vector_res = vmul_lane(vector,vector2,lane), then store the result. */
38 #define TEST_VMUL_LANE(Q, T1, T2, W, N, N2, L) \
39 VECT_VAR(vector_res, T1, W, N) = \
40 vmul##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), \
41 VECT_VAR(vector2, T1, W, N2), \
42 L); \
43 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
44 VECT_VAR(vector_res, T1, W, N))
46 DECL_VMUL(vector);
47 DECL_VMUL(vector_res);
49 DECL_VARIABLE(vector2, int, 16, 4);
50 DECL_VARIABLE(vector2, int, 32, 2);
51 DECL_VARIABLE(vector2, uint, 16, 4);
52 DECL_VARIABLE(vector2, uint, 32, 2);
53 DECL_VARIABLE(vector2, float, 32, 2);
55 clean_results ();
57 /* Initialize vector from pre-initialized values. */
58 VLOAD(vector, buffer, , int, s, 16, 4);
59 VLOAD(vector, buffer, , int, s, 32, 2);
60 VLOAD(vector, buffer, , uint, u, 16, 4);
61 VLOAD(vector, buffer, , uint, u, 32, 2);
62 VLOAD(vector, buffer, , float, f, 32, 2);
63 VLOAD(vector, buffer, q, int, s, 16, 8);
64 VLOAD(vector, buffer, q, int, s, 32, 4);
65 VLOAD(vector, buffer, q, uint, u, 16, 8);
66 VLOAD(vector, buffer, q, uint, u, 32, 4);
67 VLOAD(vector, buffer, q, float, f, 32, 4);
69 /* Initialize vector2. */
70 VDUP(vector2, , int, s, 16, 4, 0x4);
71 VDUP(vector2, , int, s, 32, 2, 0x22);
72 VDUP(vector2, , uint, u, 16, 4, 0x444);
73 VDUP(vector2, , uint, u, 32, 2, 0x532);
74 VDUP(vector2, , float, f, 32, 2, 22.8f);
76 /* Choose lane arbitrarily. */
77 TEST_VMUL_LANE(, int, s, 16, 4, 4, 2);
78 TEST_VMUL_LANE(, int, s, 32, 2, 2, 1);
79 TEST_VMUL_LANE(, uint, u, 16, 4, 4, 2);
80 TEST_VMUL_LANE(, uint, u, 32, 2, 2, 1);
81 TEST_VMUL_LANE(, float, f, 32, 2, 2, 1);
82 TEST_VMUL_LANE(q, int, s, 16, 8, 4, 2);
83 TEST_VMUL_LANE(q, int, s, 32, 4, 2, 0);
84 TEST_VMUL_LANE(q, uint, u, 16, 8, 4, 2);
85 TEST_VMUL_LANE(q, uint, u, 32, 4, 2, 1);
86 TEST_VMUL_LANE(q, float, f, 32, 4, 2, 0);
88 CHECK(TEST_MSG, int, 16, 4, PRIx64, expected, "");
89 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
90 CHECK(TEST_MSG, uint, 16, 4, PRIx64, expected, "");
91 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
92 CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, "");
93 CHECK(TEST_MSG, int, 16, 8, PRIx64, expected, "");
94 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
95 CHECK(TEST_MSG, uint, 16, 8, PRIx64, expected, "");
96 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
97 CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, "");
100 int main (void)
102 exec_vmul_lane ();
103 return 0;