| 1 |
#define INSN_NAME vqsub |
| 2 |
#define TEST_MSG "VQSUB/VQSUBQ" |
| 3 |
|
| 4 |
/* Extra tests for special cases: |
| 5 |
- some requiring intermediate types larger than 64 bits to |
| 6 |
compute saturation flag. |
| 7 |
- corner case saturations with types smaller than 64 bits. |
| 8 |
*/ |
| 9 |
void vqsub_extras(void); |
| 10 |
#define EXTRA_TESTS vqsub_extras |
| 11 |
|
| 12 |
#include "binary_sat_op.inc" |
| 13 |
|
| 14 |
|
| 15 |
/* Expected results. */ |
| 16 |
VECT_VAR_DECL(expected,int,8,8) [] = { 0xdf, 0xe0, 0xe1, 0xe2, |
| 17 |
0xe3, 0xe4, 0xe5, 0xe6 }; |
| 18 |
VECT_VAR_DECL(expected,int,16,4) [] = { 0xffce, 0xffcf, |
| 19 |
0xffd0, 0xffd1 }; |
| 20 |
VECT_VAR_DECL(expected,int,32,2) [] = { 0xffffffbd, 0xffffffbe }; |
| 21 |
VECT_VAR_DECL(expected,int,64,1) [] = { 0xffffffffffffffac }; |
| 22 |
VECT_VAR_DECL(expected,uint,8,8) [] = { 0x9b, 0x9c, 0x9d, 0x9e, |
| 23 |
0x9f, 0xa0, 0xa1, 0xa2 }; |
| 24 |
VECT_VAR_DECL(expected,uint,16,4) [] = { 0xff8a, 0xff8b, |
| 25 |
0xff8c, 0xff8d }; |
| 26 |
VECT_VAR_DECL(expected,uint,32,2) [] = { 0xffffff79, 0xffffff7a }; |
| 27 |
VECT_VAR_DECL(expected,uint,64,1) [] = { 0xffffffffffffff68 }; |
| 28 |
VECT_VAR_DECL(expected,int,8,16) [] = { 0xdf, 0xe0, 0xe1, 0xe2, |
| 29 |
0xe3, 0xe4, 0xe5, 0xe6, |
| 30 |
0xe7, 0xe8, 0xe9, 0xea, |
| 31 |
0xeb, 0xec, 0xed, 0xee }; |
| 32 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0xffce, 0xffcf, 0xffd0, 0xffd1, |
| 33 |
0xffd2, 0xffd3, 0xffd4, 0xffd5 }; |
| 34 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0xffffffbd, 0xffffffbe, |
| 35 |
0xffffffbf, 0xffffffc0 }; |
| 36 |
VECT_VAR_DECL(expected,int,64,2) [] = { 0xffffffffffffffac, |
| 37 |
0xffffffffffffffad }; |
| 38 |
VECT_VAR_DECL(expected,uint,8,16) [] = { 0x9b, 0x9c, 0x9d, 0x9e, |
| 39 |
0x9f, 0xa0, 0xa1, 0xa2, |
| 40 |
0xa3, 0xa4, 0xa5, 0xa6, |
| 41 |
0xa7, 0xa8, 0xa9, 0xaa }; |
| 42 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0xff8a, 0xff8b, 0xff8c, 0xff8d, |
| 43 |
0xff8e, 0xff8f, 0xff90, 0xff91 }; |
| 44 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xffffff79, 0xffffff7a, |
| 45 |
0xffffff7b, 0xffffff7c }; |
| 46 |
VECT_VAR_DECL(expected,uint,64,2) [] = { 0xffffffffffffff68, |
| 47 |
0xffffffffffffff69 }; |
| 48 |
|
| 49 |
/* 64-bits types, with 0 as second input. */ |
| 50 |
VECT_VAR_DECL(expected_64,int,64,1) [] = { 0xfffffffffffffff0 }; |
| 51 |
VECT_VAR_DECL(expected_64,uint,64,1) [] = { 0xfffffffffffffff0 }; |
| 52 |
VECT_VAR_DECL(expected_64,int,64,2) [] = { 0xfffffffffffffff0, |
| 53 |
0xfffffffffffffff1 }; |
| 54 |
VECT_VAR_DECL(expected_64,uint,64,2) [] = { 0xfffffffffffffff0, |
| 55 |
0xfffffffffffffff1 }; |
| 56 |
/* 64-bits types, other cases. */ |
| 57 |
VECT_VAR_DECL(expected_64_2,int,64,1) [] = { 0xffffffffffffffac }; |
| 58 |
VECT_VAR_DECL(expected_64_2,uint,64,1) [] = { 0xffffffffffffff68 }; |
| 59 |
VECT_VAR_DECL(expected_64_2,int,64,2) [] = { 0xffffffffffffffac, |
| 60 |
0xffffffffffffffad }; |
| 61 |
VECT_VAR_DECL(expected_64_2,uint,64,2) [] = { 0xffffffffffffff68, |
| 62 |
0xffffffffffffff69 }; |
| 63 |
|
| 64 |
/* 64-bits types, all causing cumulative saturation. */ |
| 65 |
VECT_VAR_DECL(expected_64_3,int,64,1) [] = { 0x8000000000000000 }; |
| 66 |
VECT_VAR_DECL(expected_64_3,uint,64,1) [] = { 0x0 }; |
| 67 |
VECT_VAR_DECL(expected_64_3,int,64,2) [] = { 0x7fffffffffffffff, |
| 68 |
0x7fffffffffffffff }; |
| 69 |
VECT_VAR_DECL(expected_64_3,uint,64,2) [] = { 0x0, 0x0 }; |
| 70 |
|
| 71 |
/* smaller types, corner cases causing cumulative saturation. (1) */ |
| 72 |
VECT_VAR_DECL(expected_lt_64_1,int,8,8) [] = { 0x80, 0x80, 0x80, 0x80, |
| 73 |
0x80, 0x80, 0x80, 0x80 }; |
| 74 |
VECT_VAR_DECL(expected_lt_64_1,int,16,4) [] = { 0x8000, 0x8000, |
| 75 |
0x8000, 0x8000 }; |
| 76 |
VECT_VAR_DECL(expected_lt_64_1,int,32,2) [] = { 0x80000000, 0x80000000 }; |
| 77 |
VECT_VAR_DECL(expected_lt_64_1,int,8,16) [] = { 0x80, 0x80, 0x80, 0x80, |
| 78 |
0x80, 0x80, 0x80, 0x80, |
| 79 |
0x80, 0x80, 0x80, 0x80, |
| 80 |
0x80, 0x80, 0x80, 0x80 }; |
| 81 |
VECT_VAR_DECL(expected_lt_64_1,int,16,8) [] = { 0x8000, 0x8000, |
| 82 |
0x8000, 0x8000, |
| 83 |
0x8000, 0x8000, |
| 84 |
0x8000, 0x8000 }; |
| 85 |
VECT_VAR_DECL(expected_lt_64_1,int,32,4) [] = { 0x80000000, 0x80000000, |
| 86 |
0x80000000, 0x80000000 }; |
| 87 |
/* smaller types, corner cases causing cumulative saturation. (2) */ |
| 88 |
VECT_VAR_DECL(expected_lt_64_2,uint,8,8) [] = { 0x0, 0x0, 0x0, 0x0, |
| 89 |
0x0, 0x0, 0x0, 0x0 }; |
| 90 |
VECT_VAR_DECL(expected_lt_64_2,uint,16,4) [] = { 0x0, 0x0, 0x0, 0x0 }; |
| 91 |
VECT_VAR_DECL(expected_lt_64_2,uint,32,2) [] = { 0x0, 0x0 }; |
| 92 |
VECT_VAR_DECL(expected_lt_64_2,uint,8,16) [] = { 0x0, 0x0, 0x0, 0x0, |
| 93 |
0x0, 0x0, 0x0, 0x0, |
| 94 |
0x0, 0x0, 0x0, 0x0, |
| 95 |
0x0, 0x0, 0x0, 0x0 }; |
| 96 |
VECT_VAR_DECL(expected_lt_64_2,uint,16,8) [] = { 0x0, 0x0, 0x0, 0x0, |
| 97 |
0x0, 0x0, 0x0, 0x0 }; |
| 98 |
VECT_VAR_DECL(expected_lt_64_2,uint,32,4) [] = { 0x0, 0x0, 0x0, 0x0 }; |
| 99 |
|
| 100 |
void vqsub_extras(void) |
| 101 |
{ |
| 102 |
DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 103 |
DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 104 |
DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 105 |
|
| 106 |
/* Initialize input "vector1" from "buffer". */ |
| 107 |
TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
| 108 |
|
| 109 |
/* Use a second vector full of 0. */ |
| 110 |
VDUP(vector2, , int, s, 64, 1, 0x0); |
| 111 |
VDUP(vector2, , uint, u, 64, 1, 0x0); |
| 112 |
VDUP(vector2, q, int, s, 64, 2, 0x0); |
| 113 |
VDUP(vector2, q, uint, u, 64, 2, 0x0); |
| 114 |
|
| 115 |
#define MSG "64 bits saturation when adding zero" |
| 116 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 117 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, MSG); |
| 118 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 119 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 120 |
|
| 121 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64, MSG); |
| 122 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64, MSG); |
| 123 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64, MSG); |
| 124 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64, MSG); |
| 125 |
|
| 126 |
/* Another set of tests with non-zero values. */ |
| 127 |
VDUP(vector2, , int, s, 64, 1, 0x44); |
| 128 |
VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 129 |
VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 130 |
VDUP(vector2, q, uint, u, 64, 2, 0x88); |
| 131 |
|
| 132 |
#undef MSG |
| 133 |
#define MSG "64 bits saturation cumulative_sat (2)" |
| 134 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 135 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, MSG); |
| 136 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 137 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 138 |
|
| 139 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64_2, MSG); |
| 140 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64_2, MSG); |
| 141 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64_2, MSG); |
| 142 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64_2, MSG); |
| 143 |
|
| 144 |
/* Another set of tests, with input values chosen to set |
| 145 |
cumulative_sat in all cases. */ |
| 146 |
VDUP(vector2, , int, s, 64, 1, 0x7fffffffffffffffLL); |
| 147 |
VDUP(vector2, , uint, u, 64, 1, 0xffffffffffffffffULL); |
| 148 |
/* To check positive saturation, we need to write a positive value |
| 149 |
in vector1. */ |
| 150 |
VDUP(vector1, q, int, s, 64, 2, 0x3fffffffffffffffLL); |
| 151 |
VDUP(vector2, q, int, s, 64, 2, 0x8000000000000000LL); |
| 152 |
VDUP(vector2, q, uint, u, 64, 2, 0xffffffffffffffffULL); |
| 153 |
|
| 154 |
#undef MSG |
| 155 |
#define MSG "64 bits saturation cumulative_sat (3)" |
| 156 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 157 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, MSG); |
| 158 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 159 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 160 |
|
| 161 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64_3, MSG); |
| 162 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64_3, MSG); |
| 163 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64_3, MSG); |
| 164 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64_3, MSG); |
| 165 |
|
| 166 |
/* To improve coverage, check saturation with less than 64 bits |
| 167 |
too. */ |
| 168 |
VDUP(vector2, , int, s, 8, 8, 0x7F); |
| 169 |
VDUP(vector2, , int, s, 16, 4, 0x7FFF); |
| 170 |
VDUP(vector2, , int, s, 32, 2, 0x7FFFFFFF); |
| 171 |
VDUP(vector2, q, int, s, 8, 16, 0x7F); |
| 172 |
VDUP(vector2, q, int, s, 16, 8, 0x7FFF); |
| 173 |
VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF); |
| 174 |
|
| 175 |
#undef MSG |
| 176 |
#define MSG "less than 64 bits saturation cumulative_sat (1)" |
| 177 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8, MSG); |
| 178 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4, MSG); |
| 179 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2, MSG); |
| 180 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, MSG); |
| 181 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, MSG); |
| 182 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, MSG); |
| 183 |
|
| 184 |
CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_lt_64_1, MSG); |
| 185 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_lt_64_1, MSG); |
| 186 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_lt_64_1, MSG); |
| 187 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_lt_64_1, MSG); |
| 188 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_lt_64_1, MSG); |
| 189 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_lt_64_1, MSG); |
| 190 |
|
| 191 |
/* Another set of tests with vector1 values smaller than |
| 192 |
vector2. */ |
| 193 |
VDUP(vector1, , uint, u, 8, 8, 0x10); |
| 194 |
VDUP(vector1, , uint, u, 16, 4, 0x10); |
| 195 |
VDUP(vector1, , uint, u, 32, 2, 0x10); |
| 196 |
VDUP(vector1, q, uint, u, 8, 16, 0x10); |
| 197 |
VDUP(vector1, q, uint, u, 16, 8, 0x10); |
| 198 |
VDUP(vector1, q, uint, u, 32, 4, 0x10); |
| 199 |
|
| 200 |
VDUP(vector2, , uint, u, 8, 8, 0x20); |
| 201 |
VDUP(vector2, , uint, u, 16, 4, 0x20); |
| 202 |
VDUP(vector2, , uint, u, 32, 2, 0x20); |
| 203 |
VDUP(vector2, q, uint, u, 8, 16, 0x20); |
| 204 |
VDUP(vector2, q, uint, u, 16, 8, 0x20); |
| 205 |
VDUP(vector2, q, uint, u, 32, 4, 0x20); |
| 206 |
|
| 207 |
#undef MSG |
| 208 |
#define MSG "less than 64 bits saturation cumulative_sat (2)" |
| 209 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8, MSG); |
| 210 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4, MSG); |
| 211 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2, MSG); |
| 212 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16, MSG); |
| 213 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8, MSG); |
| 214 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4, MSG); |
| 215 |
|
| 216 |
CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_lt_64_2, MSG); |
| 217 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_lt_64_2, MSG); |
| 218 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_lt_64_2, MSG); |
| 219 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_lt_64_2, MSG); |
| 220 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_lt_64_2, MSG); |
| 221 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_lt_64_2, MSG); |
| 222 |
} |