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) [] = { 0xffff, 0xffff, 0xffff, 0xffff };
13 VECT_VAR_DECL(expected
,int,32,2) [] = { 0xffffffff, 0xffffffff };
14 VECT_VAR_DECL(expected
,int,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
15 0xffff, 0xffff, 0xffff, 0xffff };
16 VECT_VAR_DECL(expected
,int,32,4) [] = { 0xffffffff, 0xffffffff,
17 0xffffffff, 0xffffffff };
19 /* Expected values of cumulative_saturation flag when saturation
21 int VECT_VAR(expected_cumulative_sat2
,int,16,4) = 1;
22 int VECT_VAR(expected_cumulative_sat2
,int,32,2) = 1;
23 int VECT_VAR(expected_cumulative_sat2
,int,16,8) = 1;
24 int VECT_VAR(expected_cumulative_sat2
,int,32,4) = 1;
26 /* Expected results when saturation occurs. */
27 VECT_VAR_DECL(expected2
,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
28 VECT_VAR_DECL(expected2
,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
29 VECT_VAR_DECL(expected2
,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
30 0x7fff, 0x7fff, 0x7fff, 0x7fff };
31 VECT_VAR_DECL(expected2
,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
32 0x7fffffff, 0x7fffffff };
34 #define INSN_NAME vqdmulh
35 #define TEST_MSG "VQDMULH_LANE"
36 #define FNNAME1(NAME) exec_ ## NAME ## _lane
37 #define FNNAME(NAME) FNNAME1(NAME)
39 void FNNAME (INSN_NAME
) (void)
41 /* vector_res = vqdmulh_lane(vector,vector2,lane), then store the result. */
42 #define TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L, EXPECTED_CUMULATIVE_SAT, CMT) \
43 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
44 VECT_VAR(vector_res, T1, W, N) = \
45 INSN##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), \
46 VECT_VAR(vector2, T1, W, N2), \
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_LANE1(INSN, Q, T1, T2, W, N, N2, L, EXPECTED_CUMULATIVE_SAT, CMT) \
54 TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L, EXPECTED_CUMULATIVE_SAT, CMT)
56 #define TEST_VQDMULH_LANE(Q, T1, T2, W, N, N2, L, EXPECTED_CUMULATIVE_SAT, CMT) \
57 TEST_VQDMULH_LANE1(INSN_NAME, Q, T1, T2, W, N, N2, 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 /* vector2: vqdmulh_lane and vqdmulhq_lane have a 2nd argument with
70 the same number of elements, so we need only one variable of each
72 DECL_VARIABLE(vector2
, int, 16, 4);
73 DECL_VARIABLE(vector2
, int, 32, 2);
77 VLOAD(vector
, buffer
, , int, s
, 16, 4);
78 VLOAD(vector
, buffer
, , int, s
, 32, 2);
79 VLOAD(vector
, buffer
, q
, int, s
, 16, 8);
80 VLOAD(vector
, buffer
, q
, int, s
, 32, 4);
82 /* Initialize vector2. */
83 VDUP(vector2
, , int, s
, 16, 4, 0x55);
84 VDUP(vector2
, , int, s
, 32, 2, 0xBB);
86 /* Choose lane arbitrarily. */
87 TEST_VQDMULH_LANE(, int, s
, 16, 4, 4, 2, expected_cumulative_sat
, "");
88 TEST_VQDMULH_LANE(, int, s
, 32, 2, 2, 1, expected_cumulative_sat
, "");
89 TEST_VQDMULH_LANE(q
, int, s
, 16, 8, 4, 3, expected_cumulative_sat
, "");
90 TEST_VQDMULH_LANE(q
, int, s
, 32, 4, 2, 0, expected_cumulative_sat
, "");
92 CHECK (TEST_MSG
, int, 16, 4, PRIx16
, expected
, "");
93 CHECK (TEST_MSG
, int, 32, 2, PRIx32
, expected
, "");
94 CHECK (TEST_MSG
, int, 16, 8, PRIx16
, expected
, "");
95 CHECK (TEST_MSG
, int, 32, 4, PRIx32
, expected
, "");
97 /* Choose input values to trigger saturation. */
98 VDUP(vector
, , int, s
, 16, 4, 0x8000);
99 VDUP(vector
, , int, s
, 32, 2, 0x80000000);
100 VDUP(vector
, q
, int, s
, 16, 8, 0x8000);
101 VDUP(vector
, q
, int, s
, 32, 4, 0x80000000);
102 VDUP(vector2
, , int, s
, 16, 4, 0x8000);
103 VDUP(vector2
, , int, s
, 32, 2, 0x80000000);
105 #define TEST_MSG2 " (check mul cumulative saturation)"
106 TEST_VQDMULH_LANE(, int, s
, 16, 4, 4, 3, expected_cumulative_sat2
, TEST_MSG2
);
107 TEST_VQDMULH_LANE(, int, s
, 32, 2, 2, 1, expected_cumulative_sat2
, TEST_MSG2
);
108 TEST_VQDMULH_LANE(q
, int, s
, 16, 8, 4, 2, expected_cumulative_sat2
, TEST_MSG2
);
109 TEST_VQDMULH_LANE(q
, int, s
, 32, 4, 2, 1, expected_cumulative_sat2
, TEST_MSG2
);
111 CHECK (TEST_MSG
, int, 16, 4, PRIx16
, expected2
, TEST_MSG2
);
112 CHECK (TEST_MSG
, int, 32, 2, PRIx32
, expected2
, TEST_MSG2
);
113 CHECK (TEST_MSG
, int, 16, 8, PRIx16
, expected2
, TEST_MSG2
);
114 CHECK (TEST_MSG
, int, 32, 4, PRIx32
, expected2
, TEST_MSG2
);
119 FNNAME (INSN_NAME
) ();