[ARM/AArch64][testsuite] Add vqdmulh_n tests.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vqdmulh_n.c
blobab66e2d05d60410a5837b23f559b904e4d651b96
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected values of cumulative_saturation flag. */
6 int VECT_VAR(expected_cumulative_sat,int,16,4) = 0;
7 int VECT_VAR(expected_cumulative_sat,int,32,2) = 0;
8 int VECT_VAR(expected_cumulative_sat,int,16,8) = 0;
9 int VECT_VAR(expected_cumulative_sat,int,32,4) = 0;
11 /* Expected results. */
12 VECT_VAR_DECL(expected,int,16,4) [] = { 0x19, 0x19, 0x19, 0x19 };
13 VECT_VAR_DECL(expected,int,32,2) [] = { 0x4, 0x4 };
14 VECT_VAR_DECL(expected,int,16,8) [] = { 0x10, 0x10, 0x10, 0x10,
15 0x10, 0x10, 0x10, 0x10 };
16 VECT_VAR_DECL(expected,int,32,4) [] = { 0xa, 0xa, 0xa, 0xa };
18 /* Expected values of cumulative_saturation flag when saturation
19 occurs. */
20 int VECT_VAR(expected_cumulative_sat2,int,16,4) = 1;
21 int VECT_VAR(expected_cumulative_sat2,int,32,2) = 1;
22 int VECT_VAR(expected_cumulative_sat2,int,16,8) = 1;
23 int VECT_VAR(expected_cumulative_sat2,int,32,4) = 1;
25 /* Expected results when saturation occurs. */
26 VECT_VAR_DECL(expected2,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
27 VECT_VAR_DECL(expected2,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
28 VECT_VAR_DECL(expected2,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
29 0x7fff, 0x7fff, 0x7fff, 0x7fff };
30 VECT_VAR_DECL(expected2,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
31 0x7fffffff, 0x7fffffff };
33 #define INSN_NAME vqdmulh
34 #define TEST_MSG "VQDMULH_N"
35 #define FNNAME1(NAME) exec_ ## NAME ## _n
36 #define FNNAME(NAME) FNNAME1(NAME)
38 void FNNAME (INSN_NAME) (void)
40 int i;
42 /* vector_res = vqdmulh_n(vector,val), then store the result. */
43 #define TEST_VQDMULH_N2(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \
44 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
45 VECT_VAR(vector_res, T1, W, N) = \
46 INSN##Q##_n_##T2##W(VECT_VAR(vector, T1, W, N), \
47 L); \
48 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
49 VECT_VAR(vector_res, T1, W, N)); \
50 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
52 /* Two auxliary macros are necessary to expand INSN. */
53 #define TEST_VQDMULH_N1(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \
54 TEST_VQDMULH_N2(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT)
56 #define TEST_VQDMULH_N(Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \
57 TEST_VQDMULH_N1(INSN_NAME, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT)
59 DECL_VARIABLE(vector, int, 16, 4);
60 DECL_VARIABLE(vector, int, 32, 2);
61 DECL_VARIABLE(vector, int, 16, 8);
62 DECL_VARIABLE(vector, int, 32, 4);
64 DECL_VARIABLE(vector_res, int, 16, 4);
65 DECL_VARIABLE(vector_res, int, 32, 2);
66 DECL_VARIABLE(vector_res, int, 16, 8);
67 DECL_VARIABLE(vector_res, int, 32, 4);
69 clean_results ();
71 /* Initialize vector. */
72 VDUP(vector, , int, s, 16, 4, 0x1000);
73 VDUP(vector, , int, s, 32, 2, 0x100023);
74 VDUP(vector, q, int, s, 16, 8, 0x1000);
75 VDUP(vector, q, int, s, 32, 4, 0x100045);
77 /* Choose multiplier arbitrarily. */
78 TEST_VQDMULH_N(, int, s, 16, 4, 0xCF, expected_cumulative_sat, "");
79 TEST_VQDMULH_N(, int, s, 32, 2, 0x2344, expected_cumulative_sat, "");
80 TEST_VQDMULH_N(q, int, s, 16, 8, 0x80, expected_cumulative_sat, "");
81 TEST_VQDMULH_N(q, int, s, 32, 4, 0x5422, expected_cumulative_sat, "");
83 CHECK (TEST_MSG, int, 16, 4, PRIx16, expected, "");
84 CHECK (TEST_MSG, int, 32, 2, PRIx32, expected, "");
85 CHECK (TEST_MSG, int, 16, 8, PRIx16, expected, "");
86 CHECK (TEST_MSG, int, 32, 4, PRIx32, expected, "");
88 /* Choose input values to trigger saturation. */
89 VDUP(vector, , int, s, 16, 4, 0x8000);
90 VDUP(vector, , int, s, 32, 2, 0x80000000);
91 VDUP(vector, q, int, s, 16, 8, 0x8000);
92 VDUP(vector, q, int, s, 32, 4, 0x80000000);
94 #define TEST_MSG2 " (check mul cumulative saturation)"
95 TEST_VQDMULH_N(, int, s, 16, 4, 0x8000, expected_cumulative_sat2, TEST_MSG2);
96 TEST_VQDMULH_N(, int, s, 32, 2, 0x80000000, expected_cumulative_sat2, TEST_MSG2);
97 TEST_VQDMULH_N(q, int, s, 16, 8, 0x8000, expected_cumulative_sat2, TEST_MSG2);
98 TEST_VQDMULH_N(q, int, s, 32, 4, 0x80000000, expected_cumulative_sat2, TEST_MSG2);
100 CHECK (TEST_MSG, int, 16, 4, PRIx16, expected2, TEST_MSG2);
101 CHECK (TEST_MSG, int, 32, 2, PRIx32, expected2, TEST_MSG2);
102 CHECK (TEST_MSG, int, 16, 8, PRIx16, expected2, TEST_MSG2);
103 CHECK (TEST_MSG, int, 32, 4, PRIx32, expected2, TEST_MSG2);
106 int main (void)
108 FNNAME (INSN_NAME) ();
109 return 0;