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,8,8) = 0;
7 int VECT_VAR(expected_cumulative_sat
,int,16,4) = 0;
8 int VECT_VAR(expected_cumulative_sat
,int,32,2) = 0;
9 int VECT_VAR(expected_cumulative_sat
,uint
,8,8) = 0;
10 int VECT_VAR(expected_cumulative_sat
,uint
,16,4) = 0;
11 int VECT_VAR(expected_cumulative_sat
,uint
,32,2) = 0;
13 /* Expected results. */
14 VECT_VAR_DECL(expected
,int,8,8) [] = { 0x12, 0x12, 0x12, 0x12,
15 0x12, 0x12, 0x12, 0x12 };
16 VECT_VAR_DECL(expected
,int,16,4) [] = { 0x1278, 0x1278, 0x1278, 0x1278 };
17 VECT_VAR_DECL(expected
,int,32,2) [] = { 0x12345678, 0x12345678 };
18 VECT_VAR_DECL(expected
,uint
,8,8) [] = { 0x82, 0x82, 0x82, 0x82,
19 0x82, 0x82, 0x82, 0x82 };
20 VECT_VAR_DECL(expected
,uint
,16,4) [] = { 0x8765, 0x8765, 0x8765, 0x8765 };
21 VECT_VAR_DECL(expected
,uint
,32,2) [] = { 0x87654321, 0x87654321 };
23 /* Expected values of cumulative_saturation flag when saturation occurs. */
24 int VECT_VAR(expected_cumulative_sat1
,int,8,8) = 1;
25 int VECT_VAR(expected_cumulative_sat1
,int,16,4) = 1;
26 int VECT_VAR(expected_cumulative_sat1
,int,32,2) = 1;
27 int VECT_VAR(expected_cumulative_sat1
,uint
,8,8) = 1;
28 int VECT_VAR(expected_cumulative_sat1
,uint
,16,4) = 1;
29 int VECT_VAR(expected_cumulative_sat1
,uint
,32,2) = 1;
31 /* Expected results when saturation occurs. */
32 VECT_VAR_DECL(expected1
,int,8,8) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
33 0x7f, 0x7f, 0x7f, 0x7f };
34 VECT_VAR_DECL(expected1
,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
35 VECT_VAR_DECL(expected1
,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
36 VECT_VAR_DECL(expected1
,uint
,8,8) [] = { 0xff, 0xff, 0xff, 0xff,
37 0xff, 0xff, 0xff, 0xff };
38 VECT_VAR_DECL(expected1
,uint
,16,4) [] = { 0xffff, 0xffff, 0xffff, 0xffff };
39 VECT_VAR_DECL(expected1
,uint
,32,2) [] = { 0xffffffff, 0xffffffff };
41 #define INSN_NAME vqmovn
42 #define TEST_MSG "VQMOVN"
44 #define FNNAME1(NAME) void exec_ ## NAME (void)
45 #define FNNAME(NAME) FNNAME1(NAME)
49 /* Basic test: y=OP(x), then store the result. */
50 #define TEST_UNARY_OP1(INSN, T1, T2, W, W2, N, EXPECTED_CUMULATIVE_SAT, CMT) \
51 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
52 VECT_VAR(vector_res, T1, W, N) = \
53 INSN##_##T2##W2(VECT_VAR(vector, T1, W2, N)); \
54 vst1##_##T2##W(VECT_VAR(result, T1, W, N), \
55 VECT_VAR(vector_res, T1, W, N)); \
56 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
58 #define TEST_UNARY_OP(INSN, T1, T2, W, W2, N, EXPECTED_CUMULATIVE_SAT, CMT) \
59 TEST_UNARY_OP1(INSN, T1, T2, W, W2, N, EXPECTED_CUMULATIVE_SAT, CMT)
61 /* No need for 64 bits variants. */
62 DECL_VARIABLE(vector
, int, 16, 8);
63 DECL_VARIABLE(vector
, int, 32, 4);
64 DECL_VARIABLE(vector
, int, 64, 2);
65 DECL_VARIABLE(vector
, uint
, 16, 8);
66 DECL_VARIABLE(vector
, uint
, 32, 4);
67 DECL_VARIABLE(vector
, uint
, 64, 2);
69 DECL_VARIABLE(vector_res
, int, 8, 8);
70 DECL_VARIABLE(vector_res
, int, 16, 4);
71 DECL_VARIABLE(vector_res
, int, 32, 2);
72 DECL_VARIABLE(vector_res
, uint
, 8, 8);
73 DECL_VARIABLE(vector_res
, uint
, 16, 4);
74 DECL_VARIABLE(vector_res
, uint
, 32, 2);
78 /* Fill input vector with arbitrary values. */
79 VDUP(vector
, q
, int, s
, 16, 8, 0x12);
80 VDUP(vector
, q
, int, s
, 32, 4, 0x1278);
81 VDUP(vector
, q
, int, s
, 64, 2, 0x12345678);
82 VDUP(vector
, q
, uint
, u
, 16, 8, 0x82);
83 VDUP(vector
, q
, uint
, u
, 32, 4, 0x8765);
84 VDUP(vector
, q
, uint
, u
, 64, 2, 0x87654321);
86 /* Apply a unary operator named INSN_NAME. */
88 TEST_UNARY_OP(INSN_NAME
, int, s
, 8, 16, 8, expected_cumulative_sat
, CMT
);
89 TEST_UNARY_OP(INSN_NAME
, int, s
, 16, 32, 4, expected_cumulative_sat
, CMT
);
90 TEST_UNARY_OP(INSN_NAME
, int, s
, 32, 64, 2, expected_cumulative_sat
, CMT
);
91 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 8, 16, 8, expected_cumulative_sat
, CMT
);
92 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 16, 32, 4, expected_cumulative_sat
, CMT
);
93 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 32, 64, 2, expected_cumulative_sat
, CMT
);
95 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected
, CMT
);
96 CHECK(TEST_MSG
, int, 16, 4, PRIx16
, expected
, CMT
);
97 CHECK(TEST_MSG
, int, 32, 2, PRIx32
, expected
, CMT
);
98 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected
, CMT
);
99 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected
, CMT
);
100 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected
, CMT
);
103 /* Fill input vector with arbitrary values which cause cumulative
105 VDUP(vector
, q
, int, s
, 16, 8, 0x1234);
106 VDUP(vector
, q
, int, s
, 32, 4, 0x12345678);
107 VDUP(vector
, q
, int, s
, 64, 2, 0x1234567890ABLL
);
108 VDUP(vector
, q
, uint
, u
, 16, 8, 0x8234);
109 VDUP(vector
, q
, uint
, u
, 32, 4, 0x87654321);
110 VDUP(vector
, q
, uint
, u
, 64, 2, 0x8765432187654321ULL
);
112 /* Apply a unary operator named INSN_NAME. */
114 #define CMT " (with saturation)"
115 TEST_UNARY_OP(INSN_NAME
, int, s
, 8, 16, 8, expected_cumulative_sat1
, CMT
);
116 TEST_UNARY_OP(INSN_NAME
, int, s
, 16, 32, 4, expected_cumulative_sat1
, CMT
);
117 TEST_UNARY_OP(INSN_NAME
, int, s
, 32, 64, 2, expected_cumulative_sat1
, CMT
);
118 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 8, 16, 8, expected_cumulative_sat1
, CMT
);
119 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 16, 32, 4, expected_cumulative_sat1
, CMT
);
120 TEST_UNARY_OP(INSN_NAME
, uint
, u
, 32, 64, 2, expected_cumulative_sat1
, CMT
);
122 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected1
, CMT
);
123 CHECK(TEST_MSG
, int, 16, 4, PRIx16
, expected1
, CMT
);
124 CHECK(TEST_MSG
, int, 32, 2, PRIx32
, expected1
, CMT
);
125 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected1
, CMT
);
126 CHECK(TEST_MSG
, uint
, 16, 4, PRIx16
, expected1
, CMT
);
127 CHECK(TEST_MSG
, uint
, 32, 2, PRIx32
, expected1
, CMT
);