2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected values of cumulative_saturation flag with negative input. */
6 int VECT_VAR(expected_cumulative_sat_neg
,int,16,8) = 1;
7 int VECT_VAR(expected_cumulative_sat_neg
,int,32,4) = 1;
8 int VECT_VAR(expected_cumulative_sat_neg
,int,64,2) = 1;
10 /* Expected results with negative input. */
11 VECT_VAR_DECL(expected_neg
,uint
,8,8) [] = { 0x0, 0x0, 0x0, 0x0,
13 VECT_VAR_DECL(expected_neg
,uint
,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
14 VECT_VAR_DECL(expected_neg
,uint
,32,2) [] = { 0x0, 0x0 };
16 /* Expected values of cumulative_saturation flag with max input value
18 int VECT_VAR(expected_cumulative_sat_max_sh1
,int,16,8) = 1;
19 int VECT_VAR(expected_cumulative_sat_max_sh1
,int,32,4) = 1;
20 int VECT_VAR(expected_cumulative_sat_max_sh1
,int,64,2) = 1;
22 /* Expected results with max input value shifted by 1. */
23 VECT_VAR_DECL(expected_max_sh1
,uint
,8,8) [] = { 0xff, 0xff, 0xff, 0xff,
24 0xff, 0xff, 0xff, 0xff };
25 VECT_VAR_DECL(expected_max_sh1
,uint
,16,4) [] = { 0xffff, 0xffff,
27 VECT_VAR_DECL(expected_max_sh1
,uint
,32,2) [] = { 0xffffffff, 0xffffffff };
28 VECT_VAR_DECL(expected_max_sh1
,uint
,64,1) [] = { 0x3333333333333333 };
30 /* Expected values of cumulative_saturation flag. */
31 int VECT_VAR(expected_cumulative_sat
,int,16,8) = 0;
32 int VECT_VAR(expected_cumulative_sat
,int,32,4) = 1;
33 int VECT_VAR(expected_cumulative_sat
,int,64,2) = 0;
35 /* Expected results. */
36 VECT_VAR_DECL(expected
,uint
,8,8) [] = { 0x48, 0x48, 0x48, 0x48,
37 0x48, 0x48, 0x48, 0x48 };
38 VECT_VAR_DECL(expected
,uint
,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
39 VECT_VAR_DECL(expected
,uint
,32,2) [] = { 0xdeadbe, 0xdeadbe };
42 #define INSN vqshrun_n
43 #define TEST_MSG "VQSHRUN_N"
45 #define FNNAME1(NAME) void exec_ ## NAME (void)
46 #define FNNAME(NAME) FNNAME1(NAME)
50 /* Basic test: y=vqshrun_n(x,v), then store the result. */
51 #define TEST_VQSHRUN_N2(INSN, T1, T2, W, W2, N, V, EXPECTED_CUMULATIVE_SAT, CMT) \
52 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, uint, W2, N)); \
53 VECT_VAR(vector_res, uint, W2, N) = \
54 INSN##_##T2##W(VECT_VAR(vector, T1, W, N), \
56 vst1_u##W2(VECT_VAR(result, uint, W2, N), \
57 VECT_VAR(vector_res, uint, W2, N)); \
58 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
60 /* Two auxliary macros are necessary to expand INSN */
61 #define TEST_VQSHRUN_N1(INSN, T1, T2, W, W2, N, V, EXPECTED_CUMULATIVE_SAT, CMT) \
62 TEST_VQSHRUN_N2(INSN, T1, T2, W, W2, N, V, EXPECTED_CUMULATIVE_SAT, CMT)
64 #define TEST_VQSHRUN_N(T1, T2, W, W2, N, V, EXPECTED_CUMULATIVE_SAT, CMT) \
65 TEST_VQSHRUN_N1(INSN, T1, T2, W, W2, N, V, EXPECTED_CUMULATIVE_SAT, CMT)
68 /* vector is twice as large as vector_res. */
69 DECL_VARIABLE(vector
, int, 16, 8);
70 DECL_VARIABLE(vector
, int, 32, 4);
71 DECL_VARIABLE(vector
, int, 64, 2);
73 DECL_VARIABLE(vector_res
, uint
, 8, 8);
74 DECL_VARIABLE(vector_res
, uint
, 16, 4);
75 DECL_VARIABLE(vector_res
, uint
, 32, 2);
79 /* Fill input vector with negative values, to check saturation on
81 VDUP(vector
, q
, int, s
, 16, 8, -2);
82 VDUP(vector
, q
, int, s
, 32, 4, -3);
83 VDUP(vector
, q
, int, s
, 64, 2, -4);
85 /* Choose shift amount arbitrarily. */
86 #define CMT " (negative input)"
87 TEST_VQSHRUN_N(int, s
, 16, 8, 8, 3, expected_cumulative_sat_neg
, CMT
);
88 TEST_VQSHRUN_N(int, s
, 32, 16, 4, 4, expected_cumulative_sat_neg
, CMT
);
89 TEST_VQSHRUN_N(int, s
, 64, 32, 2, 2, expected_cumulative_sat_neg
, CMT
);
91 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_neg
, CMT
);
92 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected_neg
, CMT
);
93 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected_neg
, CMT
);
96 /* Fill input vector with max value, to check saturation on
98 VDUP(vector
, q
, int, s
, 16, 8, 0x7FFF);
99 VDUP(vector
, q
, int, s
, 32, 4, 0x7FFFFFFF);
100 VDUP(vector
, q
, int, s
, 64, 2, 0x7FFFFFFFFFFFFFFFLL
);
103 #define CMT " (check cumulative saturation)"
104 TEST_VQSHRUN_N(int, s
, 16, 8, 8, 1, expected_cumulative_sat_max_sh1
, CMT
);
105 TEST_VQSHRUN_N(int, s
, 32, 16, 4, 1, expected_cumulative_sat_max_sh1
, CMT
);
106 TEST_VQSHRUN_N(int, s
, 64, 32, 2, 1, expected_cumulative_sat_max_sh1
, CMT
);
108 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_max_sh1
, CMT
);
109 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected_max_sh1
, CMT
);
110 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected_max_sh1
, CMT
);
113 /* Fill input vector with positive values, to check normal case. */
114 VDUP(vector
, q
, int, s
, 16, 8, 0x1234);
115 VDUP(vector
, q
, int, s
, 32, 4, 0x87654321);
116 VDUP(vector
, q
, int, s
, 64, 2, 0xDEADBEEF);
120 TEST_VQSHRUN_N(int, s
, 16, 8, 8, 6, expected_cumulative_sat
, CMT
);
121 TEST_VQSHRUN_N(int, s
, 32, 16, 4, 7, expected_cumulative_sat
, CMT
);
122 TEST_VQSHRUN_N(int, s
, 64, 32, 2, 8, expected_cumulative_sat
, CMT
);
124 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected
, CMT
);
125 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected
, CMT
);
126 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected
, CMT
);