| 1 |
#include "avx512fp16-zmm-check.h" |
| 2 |
#include "args.h" |
| 3 |
|
| 4 |
struct IntegerRegisters iregs; |
| 5 |
struct FloatRegisters fregs; |
| 6 |
unsigned int num_iregs, num_fregs; |
| 7 |
|
| 8 |
union un1 |
| 9 |
{ |
| 10 |
__m512 x; |
| 11 |
float f; |
| 12 |
}; |
| 13 |
|
| 14 |
union un2 |
| 15 |
{ |
| 16 |
__m512 x; |
| 17 |
double d; |
| 18 |
}; |
| 19 |
|
| 20 |
union un3 |
| 21 |
{ |
| 22 |
__m512 x; |
| 23 |
__m128 v; |
| 24 |
}; |
| 25 |
|
| 26 |
union un4 |
| 27 |
{ |
| 28 |
__m512 x; |
| 29 |
long double ld; |
| 30 |
}; |
| 31 |
|
| 32 |
union un5 |
| 33 |
{ |
| 34 |
__m512 x; |
| 35 |
int i; |
| 36 |
}; |
| 37 |
|
| 38 |
union un6 |
| 39 |
{ |
| 40 |
__m512 x; |
| 41 |
__m256 v; |
| 42 |
}; |
| 43 |
|
| 44 |
union un1h |
| 45 |
{ |
| 46 |
__m512 x; |
| 47 |
_Float16 f; |
| 48 |
}; |
| 49 |
|
| 50 |
union un1hf |
| 51 |
{ |
| 52 |
__m512h x; |
| 53 |
float f; |
| 54 |
}; |
| 55 |
|
| 56 |
union un1hh |
| 57 |
{ |
| 58 |
__m512h x; |
| 59 |
_Float16 f; |
| 60 |
}; |
| 61 |
|
| 62 |
union un2h |
| 63 |
{ |
| 64 |
__m512h x; |
| 65 |
double d; |
| 66 |
}; |
| 67 |
|
| 68 |
union un3h |
| 69 |
{ |
| 70 |
__m512h x; |
| 71 |
__m128 v; |
| 72 |
}; |
| 73 |
|
| 74 |
union un4h |
| 75 |
{ |
| 76 |
__m512h x; |
| 77 |
long double ld; |
| 78 |
}; |
| 79 |
|
| 80 |
union un5h |
| 81 |
{ |
| 82 |
__m512h x; |
| 83 |
int i; |
| 84 |
}; |
| 85 |
|
| 86 |
union un6h |
| 87 |
{ |
| 88 |
__m512h x; |
| 89 |
__m256 v; |
| 90 |
}; |
| 91 |
|
| 92 |
void |
| 93 |
check_union_passing1(union un1 u1 ATTRIBUTE_UNUSED, |
| 94 |
union un1 u2 ATTRIBUTE_UNUSED, |
| 95 |
union un1 u3 ATTRIBUTE_UNUSED, |
| 96 |
union un1 u4 ATTRIBUTE_UNUSED, |
| 97 |
union un1 u5 ATTRIBUTE_UNUSED, |
| 98 |
union un1 u6 ATTRIBUTE_UNUSED, |
| 99 |
union un1 u7 ATTRIBUTE_UNUSED, |
| 100 |
union un1 u8 ATTRIBUTE_UNUSED) |
| 101 |
{ |
| 102 |
/* Check register contents. */ |
| 103 |
check_m512_arguments; |
| 104 |
} |
| 105 |
|
| 106 |
void |
| 107 |
check_union_passing1h(union un1h u1 ATTRIBUTE_UNUSED, |
| 108 |
union un1h u2 ATTRIBUTE_UNUSED, |
| 109 |
union un1h u3 ATTRIBUTE_UNUSED, |
| 110 |
union un1h u4 ATTRIBUTE_UNUSED, |
| 111 |
union un1h u5 ATTRIBUTE_UNUSED, |
| 112 |
union un1h u6 ATTRIBUTE_UNUSED, |
| 113 |
union un1h u7 ATTRIBUTE_UNUSED, |
| 114 |
union un1h u8 ATTRIBUTE_UNUSED) |
| 115 |
{ |
| 116 |
/* Check register contents. */ |
| 117 |
check_m512_arguments; |
| 118 |
} |
| 119 |
|
| 120 |
void |
| 121 |
check_union_passing1hf(union un1hf u1 ATTRIBUTE_UNUSED, |
| 122 |
union un1hf u2 ATTRIBUTE_UNUSED, |
| 123 |
union un1hf u3 ATTRIBUTE_UNUSED, |
| 124 |
union un1hf u4 ATTRIBUTE_UNUSED, |
| 125 |
union un1hf u5 ATTRIBUTE_UNUSED, |
| 126 |
union un1hf u6 ATTRIBUTE_UNUSED, |
| 127 |
union un1hf u7 ATTRIBUTE_UNUSED, |
| 128 |
union un1hf u8 ATTRIBUTE_UNUSED) |
| 129 |
{ |
| 130 |
/* Check register contents. */ |
| 131 |
check_m512_arguments; |
| 132 |
} |
| 133 |
|
| 134 |
void |
| 135 |
check_union_passing1hh(union un1hh u1 ATTRIBUTE_UNUSED, |
| 136 |
union un1hh u2 ATTRIBUTE_UNUSED, |
| 137 |
union un1hh u3 ATTRIBUTE_UNUSED, |
| 138 |
union un1hh u4 ATTRIBUTE_UNUSED, |
| 139 |
union un1hh u5 ATTRIBUTE_UNUSED, |
| 140 |
union un1hh u6 ATTRIBUTE_UNUSED, |
| 141 |
union un1hh u7 ATTRIBUTE_UNUSED, |
| 142 |
union un1hh u8 ATTRIBUTE_UNUSED) |
| 143 |
{ |
| 144 |
/* Check register contents. */ |
| 145 |
check_m512_arguments; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
void |
| 150 |
check_union_passing2(union un2 u1 ATTRIBUTE_UNUSED, |
| 151 |
union un2 u2 ATTRIBUTE_UNUSED, |
| 152 |
union un2 u3 ATTRIBUTE_UNUSED, |
| 153 |
union un2 u4 ATTRIBUTE_UNUSED, |
| 154 |
union un2 u5 ATTRIBUTE_UNUSED, |
| 155 |
union un2 u6 ATTRIBUTE_UNUSED, |
| 156 |
union un2 u7 ATTRIBUTE_UNUSED, |
| 157 |
union un2 u8 ATTRIBUTE_UNUSED) |
| 158 |
{ |
| 159 |
/* Check register contents. */ |
| 160 |
check_m512_arguments; |
| 161 |
} |
| 162 |
|
| 163 |
void |
| 164 |
check_union_passing2h(union un2h u1 ATTRIBUTE_UNUSED, |
| 165 |
union un2h u2 ATTRIBUTE_UNUSED, |
| 166 |
union un2h u3 ATTRIBUTE_UNUSED, |
| 167 |
union un2h u4 ATTRIBUTE_UNUSED, |
| 168 |
union un2h u5 ATTRIBUTE_UNUSED, |
| 169 |
union un2h u6 ATTRIBUTE_UNUSED, |
| 170 |
union un2h u7 ATTRIBUTE_UNUSED, |
| 171 |
union un2h u8 ATTRIBUTE_UNUSED) |
| 172 |
{ |
| 173 |
/* Check register contents. */ |
| 174 |
check_m512_arguments; |
| 175 |
} |
| 176 |
|
| 177 |
void |
| 178 |
check_union_passing3(union un3 u1 ATTRIBUTE_UNUSED, |
| 179 |
union un3 u2 ATTRIBUTE_UNUSED, |
| 180 |
union un3 u3 ATTRIBUTE_UNUSED, |
| 181 |
union un3 u4 ATTRIBUTE_UNUSED, |
| 182 |
union un3 u5 ATTRIBUTE_UNUSED, |
| 183 |
union un3 u6 ATTRIBUTE_UNUSED, |
| 184 |
union un3 u7 ATTRIBUTE_UNUSED, |
| 185 |
union un3 u8 ATTRIBUTE_UNUSED) |
| 186 |
{ |
| 187 |
/* Check register contents. */ |
| 188 |
check_m512_arguments; |
| 189 |
} |
| 190 |
|
| 191 |
void |
| 192 |
check_union_passing3h(union un3h u1 ATTRIBUTE_UNUSED, |
| 193 |
union un3h u2 ATTRIBUTE_UNUSED, |
| 194 |
union un3h u3 ATTRIBUTE_UNUSED, |
| 195 |
union un3h u4 ATTRIBUTE_UNUSED, |
| 196 |
union un3h u5 ATTRIBUTE_UNUSED, |
| 197 |
union un3h u6 ATTRIBUTE_UNUSED, |
| 198 |
union un3h u7 ATTRIBUTE_UNUSED, |
| 199 |
union un3h u8 ATTRIBUTE_UNUSED) |
| 200 |
{ |
| 201 |
/* Check register contents. */ |
| 202 |
check_m512_arguments; |
| 203 |
} |
| 204 |
|
| 205 |
void |
| 206 |
check_union_passing4(union un4 u ATTRIBUTE_UNUSED) |
| 207 |
{ |
| 208 |
/* Check the passing on the stack by comparing the address of the |
| 209 |
stack elements to the expected place on the stack. */ |
| 210 |
assert ((unsigned long)&u.x == rsp+8); |
| 211 |
assert ((unsigned long)&u.ld == rsp+8); |
| 212 |
} |
| 213 |
|
| 214 |
void |
| 215 |
check_union_passing4h(union un4h u ATTRIBUTE_UNUSED) |
| 216 |
{ |
| 217 |
/* Check the passing on the stack by comparing the address of the |
| 218 |
stack elements to the expected place on the stack. */ |
| 219 |
assert ((unsigned long)&u.x == rsp+8); |
| 220 |
assert ((unsigned long)&u.ld == rsp+8); |
| 221 |
} |
| 222 |
|
| 223 |
void |
| 224 |
check_union_passing5(union un5 u ATTRIBUTE_UNUSED) |
| 225 |
{ |
| 226 |
/* Check the passing on the stack by comparing the address of the |
| 227 |
stack elements to the expected place on the stack. */ |
| 228 |
assert ((unsigned long)&u.x == rsp+8); |
| 229 |
assert ((unsigned long)&u.i == rsp+8); |
| 230 |
} |
| 231 |
|
| 232 |
void |
| 233 |
check_union_passing5h(union un5h u ATTRIBUTE_UNUSED) |
| 234 |
{ |
| 235 |
/* Check the passing on the stack by comparing the address of the |
| 236 |
stack elements to the expected place on the stack. */ |
| 237 |
assert ((unsigned long)&u.x == rsp+8); |
| 238 |
assert ((unsigned long)&u.i == rsp+8); |
| 239 |
} |
| 240 |
|
| 241 |
void |
| 242 |
check_union_passing6(union un6 u1 ATTRIBUTE_UNUSED, |
| 243 |
union un6 u2 ATTRIBUTE_UNUSED, |
| 244 |
union un6 u3 ATTRIBUTE_UNUSED, |
| 245 |
union un6 u4 ATTRIBUTE_UNUSED, |
| 246 |
union un6 u5 ATTRIBUTE_UNUSED, |
| 247 |
union un6 u6 ATTRIBUTE_UNUSED, |
| 248 |
union un6 u7 ATTRIBUTE_UNUSED, |
| 249 |
union un6 u8 ATTRIBUTE_UNUSED) |
| 250 |
{ |
| 251 |
/* Check register contents. */ |
| 252 |
check_m512_arguments; |
| 253 |
} |
| 254 |
|
| 255 |
void |
| 256 |
check_union_passing6h(union un6h u1 ATTRIBUTE_UNUSED, |
| 257 |
union un6h u2 ATTRIBUTE_UNUSED, |
| 258 |
union un6h u3 ATTRIBUTE_UNUSED, |
| 259 |
union un6h u4 ATTRIBUTE_UNUSED, |
| 260 |
union un6h u5 ATTRIBUTE_UNUSED, |
| 261 |
union un6h u6 ATTRIBUTE_UNUSED, |
| 262 |
union un6h u7 ATTRIBUTE_UNUSED, |
| 263 |
union un6h u8 ATTRIBUTE_UNUSED) |
| 264 |
{ |
| 265 |
/* Check register contents. */ |
| 266 |
check_m512_arguments; |
| 267 |
} |
| 268 |
|
| 269 |
#define check_union_passing1 WRAP_CALL(check_union_passing1) |
| 270 |
#define check_union_passing2 WRAP_CALL(check_union_passing2) |
| 271 |
#define check_union_passing3 WRAP_CALL(check_union_passing3) |
| 272 |
#define check_union_passing4 WRAP_CALL(check_union_passing4) |
| 273 |
#define check_union_passing5 WRAP_CALL(check_union_passing5) |
| 274 |
#define check_union_passing6 WRAP_CALL(check_union_passing6) |
| 275 |
|
| 276 |
#define check_union_passing1h WRAP_CALL(check_union_passing1h) |
| 277 |
#define check_union_passing1hf WRAP_CALL(check_union_passing1hf) |
| 278 |
#define check_union_passing1hh WRAP_CALL(check_union_passing1hh) |
| 279 |
#define check_union_passing2h WRAP_CALL(check_union_passing2h) |
| 280 |
#define check_union_passing3h WRAP_CALL(check_union_passing3h) |
| 281 |
#define check_union_passing4h WRAP_CALL(check_union_passing4h) |
| 282 |
#define check_union_passing5h WRAP_CALL(check_union_passing5h) |
| 283 |
#define check_union_passing6h WRAP_CALL(check_union_passing6h) |
| 284 |
|
| 285 |
|
| 286 |
static void |
| 287 |
do_test (void) |
| 288 |
{ |
| 289 |
union un1 u1[8]; |
| 290 |
union un2 u2[8]; |
| 291 |
union un3 u3[8]; |
| 292 |
union un4 u4; |
| 293 |
union un5 u5; |
| 294 |
union un6 u6[8]; |
| 295 |
union un1h u1h[8]; |
| 296 |
union un1hf u1hf[8]; |
| 297 |
union un1hh u1hh[8]; |
| 298 |
union un2h u2h[8]; |
| 299 |
union un3h u3h[8]; |
| 300 |
union un4h u4h; |
| 301 |
union un5h u5h; |
| 302 |
union un6h u6h[8]; |
| 303 |
int i; |
| 304 |
|
| 305 |
for (i = 0; i < 8; i++) |
| 306 |
{ |
| 307 |
u1[i].x = (__m512){32+i, 0, i, 0, -i, 0, i - 12, i + 8, |
| 308 |
32+i, 0, i, 0, -i, 0, i - 12, i + 8}; |
| 309 |
|
| 310 |
u1hf[i].x = (__m512h){ 33+i, 1, i, 2, -i, 0, i - 15, i + 9, |
| 311 |
34+i, 1, i, 2, -i, 0, i - 15, i + 9, |
| 312 |
35+i, 1, i, 2, -i, 0, i - 15, i + 9, |
| 313 |
36+i, 1, i, 2, -i, 0, i - 15, i + 9}; |
| 314 |
} |
| 315 |
|
| 316 |
clear_struct_registers; |
| 317 |
for (i = 0; i < 8; i++) |
| 318 |
(&fregs.zmm0)[i]._m512[0] = u1[i].x; |
| 319 |
num_fregs = 8; |
| 320 |
check_union_passing1(u1[0], u1[1], u1[2], u1[3], |
| 321 |
u1[4], u1[5], u1[6], u1[7]); |
| 322 |
|
| 323 |
clear_struct_registers; |
| 324 |
for (i = 0; i < 8; i++) |
| 325 |
{ |
| 326 |
u1h[i].x = u1[i].x; |
| 327 |
(&fregs.zmm0)[i]._m512[0] = u1h[i].x; |
| 328 |
} |
| 329 |
num_fregs = 8; |
| 330 |
check_union_passing1h(u1h[0], u1h[1], u1h[2], u1h[3], |
| 331 |
u1h[4], u1h[5], u1h[6], u1h[7]); |
| 332 |
|
| 333 |
clear_struct_registers; |
| 334 |
for (i = 0; i < 8; i++) |
| 335 |
(&fregs.zmm0)[i]._m512h[0] = u1hf[i].x; |
| 336 |
num_fregs = 8; |
| 337 |
check_union_passing1hf(u1hf[0], u1hf[1], u1hf[2], u1hf[3], |
| 338 |
u1hf[4], u1hf[5], u1hf[6], u1hf[7]); |
| 339 |
|
| 340 |
clear_struct_registers; |
| 341 |
for (i = 0; i < 8; i++) |
| 342 |
{ |
| 343 |
u1hh[i].x = u1hf[i].x; |
| 344 |
(&fregs.zmm0)[i]._m512h[0] = u1hh[i].x; |
| 345 |
} |
| 346 |
num_fregs = 8; |
| 347 |
check_union_passing1hh(u1hh[0], u1hh[1], u1hh[2], u1hh[3], |
| 348 |
u1hh[4], u1hh[5], u1hh[6], u1hh[7]); |
| 349 |
|
| 350 |
clear_struct_registers; |
| 351 |
for (i = 0; i < 8; i++) |
| 352 |
{ |
| 353 |
u2[i].x = u1[i].x; |
| 354 |
(&fregs.zmm0)[i]._m512[0] = u2[i].x; |
| 355 |
} |
| 356 |
num_fregs = 8; |
| 357 |
check_union_passing2(u2[0], u2[1], u2[2], u2[3], |
| 358 |
u2[4], u2[5], u2[6], u2[7]); |
| 359 |
|
| 360 |
clear_struct_registers; |
| 361 |
for (i = 0; i < 8; i++) |
| 362 |
{ |
| 363 |
u2h[i].x = u1hf[i].x; |
| 364 |
(&fregs.zmm0)[i]._m512h[0] = u2h[i].x; |
| 365 |
} |
| 366 |
num_fregs = 8; |
| 367 |
check_union_passing2h(u2h[0], u2h[1], u2h[2], u2h[3], |
| 368 |
u2h[4], u2h[5], u2h[6], u2h[7]); |
| 369 |
|
| 370 |
clear_struct_registers; |
| 371 |
for (i = 0; i < 8; i++) |
| 372 |
{ |
| 373 |
u3[i].x = u1[i].x; |
| 374 |
(&fregs.zmm0)[i]._m512[0] = u3[i].x; |
| 375 |
} |
| 376 |
num_fregs = 8; |
| 377 |
check_union_passing3(u3[0], u3[1], u3[2], u3[3], |
| 378 |
u3[4], u3[5], u3[6], u3[7]); |
| 379 |
|
| 380 |
clear_struct_registers; |
| 381 |
for (i = 0; i < 8; i++) |
| 382 |
{ |
| 383 |
u3h[i].x = u1hf[i].x; |
| 384 |
(&fregs.zmm0)[i]._m512h[0] = u3h[i].x; |
| 385 |
} |
| 386 |
num_fregs = 8; |
| 387 |
check_union_passing3h(u3h[0], u3h[1], u3h[2], u3h[3], |
| 388 |
u3h[4], u3h[5], u3h[6], u3h[7]); |
| 389 |
|
| 390 |
check_union_passing4(u4); |
| 391 |
check_union_passing5(u5); |
| 392 |
|
| 393 |
check_union_passing4h(u4h); |
| 394 |
check_union_passing5h(u5h); |
| 395 |
|
| 396 |
clear_struct_registers; |
| 397 |
for (i = 0; i < 8; i++) |
| 398 |
{ |
| 399 |
u6[i].x = u1[i].x; |
| 400 |
(&fregs.zmm0)[i]._m512[0] = u6[i].x; |
| 401 |
} |
| 402 |
num_fregs = 8; |
| 403 |
check_union_passing6(u6[0], u6[1], u6[2], u6[3], |
| 404 |
u6[4], u6[5], u6[6], u6[7]); |
| 405 |
|
| 406 |
clear_struct_registers; |
| 407 |
for (i = 0; i < 8; i++) |
| 408 |
{ |
| 409 |
u6h[i].x = u1hf[i].x; |
| 410 |
(&fregs.zmm0)[i]._m512h[0] = u6h[i].x; |
| 411 |
} |
| 412 |
num_fregs = 8; |
| 413 |
check_union_passing6h(u6h[0], u6h[1], u6h[2], u6h[3], |
| 414 |
u6h[4], u6h[5], u6h[6], u6h[7]); |
| 415 |
} |