| 1 |
#define INSN_NAME vqadd |
| 2 |
#define TEST_MSG "VQADD/VQADDQ" |
| 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 vqadd_extras(void); |
| 10 |
#define EXTRA_TESTS vqadd_extras |
| 11 |
|
| 12 |
#include "binary_sat_op.inc" |
| 13 |
|
| 14 |
/* Expected results. */ |
| 15 |
VECT_VAR_DECL(expected,int,8,8) [] = { 0x1, 0x2, 0x3, 0x4, |
| 16 |
0x5, 0x6, 0x7, 0x8 }; |
| 17 |
VECT_VAR_DECL(expected,int,16,4) [] = { 0x12, 0x13, 0x14, 0x15 }; |
| 18 |
VECT_VAR_DECL(expected,int,32,2) [] = { 0x23, 0x24 }; |
| 19 |
VECT_VAR_DECL(expected,int,64,1) [] = { 0x34 }; |
| 20 |
VECT_VAR_DECL(expected,uint,8,8) [] = { 0xff, 0xff, 0xff, 0xff, |
| 21 |
0xff, 0xff, 0xff, 0xff }; |
| 22 |
VECT_VAR_DECL(expected,uint,16,4) [] = { 0xffff, 0xffff, 0xffff, 0xffff }; |
| 23 |
VECT_VAR_DECL(expected,uint,32,2) [] = { 0xffffffff, 0xffffffff }; |
| 24 |
VECT_VAR_DECL(expected,uint,64,1) [] = { 0xffffffffffffffff }; |
| 25 |
VECT_VAR_DECL(expected,int,8,16) [] = { 0x1, 0x2, 0x3, 0x4, |
| 26 |
0x5, 0x6, 0x7, 0x8, |
| 27 |
0x9, 0xa, 0xb, 0xc, |
| 28 |
0xd, 0xe, 0xf, 0x10 }; |
| 29 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0x12, 0x13, 0x14, 0x15, |
| 30 |
0x16, 0x17, 0x18, 0x19 }; |
| 31 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0x23, 0x24, 0x25, 0x26 }; |
| 32 |
VECT_VAR_DECL(expected,int,64,2) [] = { 0x34, 0x35 }; |
| 33 |
VECT_VAR_DECL(expected,uint,8,16) [] = { 0xff, 0xff, 0xff, 0xff, |
| 34 |
0xff, 0xff, 0xff, 0xff, |
| 35 |
0xff, 0xff, 0xff, 0xff, |
| 36 |
0xff, 0xff, 0xff, 0xff }; |
| 37 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff, |
| 38 |
0xffff, 0xffff, 0xffff, 0xffff }; |
| 39 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xffffffff, 0xffffffff, |
| 40 |
0xffffffff, 0xffffffff }; |
| 41 |
VECT_VAR_DECL(expected,uint,64,2) [] = { 0xffffffffffffffff, |
| 42 |
0xffffffffffffffff }; |
| 43 |
|
| 44 |
|
| 45 |
/* 64-bits types, with 0 as second input. */ |
| 46 |
VECT_VAR_DECL(expected_64,int,64,1) [] = { 0xfffffffffffffff0 }; |
| 47 |
VECT_VAR_DECL(expected_64,uint,64,1) [] = { 0xfffffffffffffff0 }; |
| 48 |
VECT_VAR_DECL(expected_64,int,64,2) [] = { 0xfffffffffffffff0, |
| 49 |
0xfffffffffffffff1 }; |
| 50 |
VECT_VAR_DECL(expected_64,uint,64,2) [] = { 0xfffffffffffffff0, |
| 51 |
0xfffffffffffffff1 }; |
| 52 |
|
| 53 |
/* 64-bits types, some cases causing cumulative saturation. */ |
| 54 |
VECT_VAR_DECL(expected_64_2,int,64,1) [] = { 0x34 }; |
| 55 |
VECT_VAR_DECL(expected_64_2,uint,64,1) [] = { 0xffffffffffffffff }; |
| 56 |
VECT_VAR_DECL(expected_64_2,int,64,2) [] = { 0x34, 0x35 }; |
| 57 |
VECT_VAR_DECL(expected_64_2,uint,64,2) [] = { 0xffffffffffffffff, |
| 58 |
0xffffffffffffffff }; |
| 59 |
|
| 60 |
/* 64-bits types, all causing cumulative saturation. */ |
| 61 |
VECT_VAR_DECL(expected_64_3,int,64,1) [] = { 0x8000000000000000 }; |
| 62 |
VECT_VAR_DECL(expected_64_3,uint,64,1) [] = { 0xffffffffffffffff }; |
| 63 |
VECT_VAR_DECL(expected_64_3,int,64,2) [] = { 0x7fffffffffffffff, |
| 64 |
0x7fffffffffffffff }; |
| 65 |
VECT_VAR_DECL(expected_64_3,uint,64,2) [] = { 0xffffffffffffffff, |
| 66 |
0xffffffffffffffff }; |
| 67 |
|
| 68 |
VECT_VAR_DECL(expected_lt_64_1,int,8,8) [] = { 0x80, 0x80, 0x80, 0x80, |
| 69 |
0x80, 0x80, 0x80, 0x80 }; |
| 70 |
VECT_VAR_DECL(expected_lt_64_1,int,16,4) [] = { 0x8000, 0x8000, |
| 71 |
0x8000, 0x8000 }; |
| 72 |
VECT_VAR_DECL(expected_lt_64_1,int,32,2) [] = { 0x80000000, 0x80000000 }; |
| 73 |
VECT_VAR_DECL(expected_lt_64_1,int,8,16) [] = { 0x80, 0x80, 0x80, 0x80, |
| 74 |
0x80, 0x80, 0x80, 0x80, |
| 75 |
0x80, 0x80, 0x80, 0x80, |
| 76 |
0x80, 0x80, 0x80, 0x80 }; |
| 77 |
VECT_VAR_DECL(expected_lt_64_1,int,16,8) [] = { 0x8000, 0x8000, |
| 78 |
0x8000, 0x8000, |
| 79 |
0x8000, 0x8000, |
| 80 |
0x8000, 0x8000 }; |
| 81 |
VECT_VAR_DECL(expected_lt_64_1,int,32,4) [] = { 0x80000000, 0x80000000, |
| 82 |
0x80000000, 0x80000000 }; |
| 83 |
|
| 84 |
VECT_VAR_DECL(expected_lt_64_2,uint,8,8) [] = { 0xff, 0xff, 0xff, 0xff, |
| 85 |
0xff, 0xff, 0xff, 0xff }; |
| 86 |
VECT_VAR_DECL(expected_lt_64_2,uint,16,4) [] = { 0xffff, 0xffff, |
| 87 |
0xffff, 0xffff }; |
| 88 |
VECT_VAR_DECL(expected_lt_64_2,uint,32,2) [] = { 0xffffffff, |
| 89 |
0xffffffff }; |
| 90 |
VECT_VAR_DECL(expected_lt_64_2,uint,8,16) [] = { 0xff, 0xff, 0xff, 0xff, |
| 91 |
0xff, 0xff, 0xff, 0xff, |
| 92 |
0xff, 0xff, 0xff, 0xff, |
| 93 |
0xff, 0xff, 0xff, 0xff }; |
| 94 |
VECT_VAR_DECL(expected_lt_64_2,uint,16,8) [] = { 0xffff, 0xffff, |
| 95 |
0xffff, 0xffff, |
| 96 |
0xffff, 0xffff, |
| 97 |
0xffff, 0xffff }; |
| 98 |
VECT_VAR_DECL(expected_lt_64_2,uint,32,4) [] = { 0xffffffff, 0xffffffff, |
| 99 |
0xffffffff, 0xffffffff }; |
| 100 |
|
| 101 |
void vqadd_extras(void) |
| 102 |
{ |
| 103 |
DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 104 |
DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 105 |
DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 106 |
|
| 107 |
/* Initialize input "vector1" from "buffer". */ |
| 108 |
TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
| 109 |
|
| 110 |
/* Use a second vector full of 0. */ |
| 111 |
VDUP(vector2, , int, s, 64, 1, 0); |
| 112 |
VDUP(vector2, , uint, u, 64, 1, 0); |
| 113 |
VDUP(vector2, q, int, s, 64, 2, 0); |
| 114 |
VDUP(vector2, q, uint, u, 64, 2, 0); |
| 115 |
|
| 116 |
#define MSG "64 bits saturation adding zero" |
| 117 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 118 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1,MSG); |
| 119 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 120 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 121 |
|
| 122 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64, MSG); |
| 123 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64, MSG); |
| 124 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64, MSG); |
| 125 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64, MSG); |
| 126 |
|
| 127 |
/* Another set of tests with non-zero values, some chosen to create |
| 128 |
overflow. */ |
| 129 |
VDUP(vector2, , int, s, 64, 1, 0x44); |
| 130 |
VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 131 |
VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 132 |
VDUP(vector2, q, uint, u, 64, 2, 0x88); |
| 133 |
|
| 134 |
#undef MSG |
| 135 |
#define MSG "64 bits saturation cumulative_sat (2)" |
| 136 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 137 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, MSG); |
| 138 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 139 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 140 |
|
| 141 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64_2, MSG); |
| 142 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64_2, MSG); |
| 143 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64_2, MSG); |
| 144 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64_2, MSG); |
| 145 |
|
| 146 |
/* Another set of tests, with input values chosen to set |
| 147 |
cumulative_sat in all cases. */ |
| 148 |
VDUP(vector2, , int, s, 64, 1, 0x8000000000000003LL); |
| 149 |
VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 150 |
/* To check positive saturation, we need to write a positive value |
| 151 |
in vector1. */ |
| 152 |
VDUP(vector1, q, int, s, 64, 2, 0x4000000000000000LL); |
| 153 |
VDUP(vector2, q, int, s, 64, 2, 0x4000000000000000LL); |
| 154 |
VDUP(vector2, q, uint, u, 64, 2, 0x22); |
| 155 |
|
| 156 |
#undef MSG |
| 157 |
#define MSG "64 bits saturation cumulative_sat (3)" |
| 158 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, MSG); |
| 159 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, MSG); |
| 160 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, MSG); |
| 161 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, MSG); |
| 162 |
|
| 163 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_64_3, MSG); |
| 164 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_64_3, MSG); |
| 165 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_64_3, MSG); |
| 166 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_64_3, MSG); |
| 167 |
|
| 168 |
/* To improve coverage, check saturation with less than 64 bits |
| 169 |
too. */ |
| 170 |
VDUP(vector2, , int, s, 8, 8, 0x81); |
| 171 |
VDUP(vector2, , int, s, 16, 4, 0x8001); |
| 172 |
VDUP(vector2, , int, s, 32, 2, 0x80000001); |
| 173 |
VDUP(vector2, q, int, s, 8, 16, 0x81); |
| 174 |
VDUP(vector2, q, int, s, 16, 8, 0x8001); |
| 175 |
VDUP(vector2, q, int, s, 32, 4, 0x80000001); |
| 176 |
|
| 177 |
#undef MSG |
| 178 |
#define MSG "less than 64 bits saturation cumulative_sat (1)" |
| 179 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8, MSG); |
| 180 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4, MSG); |
| 181 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2, MSG); |
| 182 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, MSG); |
| 183 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, MSG); |
| 184 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, MSG); |
| 185 |
|
| 186 |
CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_lt_64_1, MSG); |
| 187 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_lt_64_1, MSG); |
| 188 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_lt_64_1, MSG); |
| 189 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_lt_64_1, MSG); |
| 190 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_lt_64_1, MSG); |
| 191 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_lt_64_1, MSG); |
| 192 |
|
| 193 |
/* Another set of tests with large vector1 values. */ |
| 194 |
VDUP(vector1, , uint, u, 8, 8, 0xF0); |
| 195 |
VDUP(vector1, , uint, u, 16, 4, 0xFFF0); |
| 196 |
VDUP(vector1, , uint, u, 32, 2, 0xFFFFFFF0); |
| 197 |
VDUP(vector1, q, uint, u, 8, 16, 0xF0); |
| 198 |
VDUP(vector1, q, uint, u, 16, 8, 0xFFF0); |
| 199 |
VDUP(vector1, q, uint, u, 32, 4, 0xFFFFFFF0); |
| 200 |
|
| 201 |
VDUP(vector2, , uint, u, 8, 8, 0x20); |
| 202 |
VDUP(vector2, , uint, u, 16, 4, 0x20); |
| 203 |
VDUP(vector2, , uint, u, 32, 2, 0x20); |
| 204 |
VDUP(vector2, q, uint, u, 8, 16, 0x20); |
| 205 |
VDUP(vector2, q, uint, u, 16, 8, 0x20); |
| 206 |
VDUP(vector2, q, uint, u, 32, 4, 0x20); |
| 207 |
|
| 208 |
#undef MSG |
| 209 |
#define MSG "less than 64 bits saturation cumulative_sat (2)" |
| 210 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8, MSG); |
| 211 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4, MSG); |
| 212 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2, MSG); |
| 213 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16, MSG); |
| 214 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8, MSG); |
| 215 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4, MSG); |
| 216 |
|
| 217 |
CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_lt_64_2, MSG); |
| 218 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_lt_64_2, MSG); |
| 219 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_lt_64_2, MSG); |
| 220 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_lt_64_2, MSG); |
| 221 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_lt_64_2, MSG); |
| 222 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_lt_64_2, MSG); |
| 223 |
} |