| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx512f -mavx512vnni" } */ |
| 3 |
/* { dg-require-effective-target avx512f } */ |
| 4 |
/* { dg-require-effective-target avx512vnni } */ |
| 5 |
|
| 6 |
#define AVX512F |
| 7 |
|
| 8 |
#define AVX512VNNI |
| 9 |
#include "avx512f-helper.h" |
| 10 |
|
| 11 |
#define SIZE (AVX512F_LEN / 8) |
| 12 |
#define SIZE_RES (AVX512F_LEN / 32) |
| 13 |
|
| 14 |
#include "avx512f-mask-type.h" |
| 15 |
|
| 16 |
static void |
| 17 |
CALC (int *r, int *dst, unsigned char *s1, char *s2) |
| 18 |
{ |
| 19 |
short tempres[SIZE]; |
| 20 |
for (int i = 0; i < SIZE; i++) { |
| 21 |
tempres[i] = ((unsigned short)(s1[i]) * (short)(s2[i])); |
| 22 |
} |
| 23 |
for (int i = 0; i < SIZE_RES; i++) { |
| 24 |
long long test = (long long) dst[i] + tempres[i*4] + tempres[i*4 + 1] + tempres[i*4 + 2] + tempres[i*4 + 3]; |
| 25 |
long long max_int = 0x7FFFFFFF; |
| 26 |
if (test > max_int) |
| 27 |
test = 0x7FFFFFFF; |
| 28 |
r[i] = test; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
void |
| 33 |
TEST (void) |
| 34 |
{ |
| 35 |
int i; |
| 36 |
UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3; |
| 37 |
UNION_TYPE (AVX512F_LEN, i_ub) src1; |
| 38 |
UNION_TYPE (AVX512F_LEN, i_b) src2; |
| 39 |
MASK_TYPE mask = MASK_VALUE; |
| 40 |
int res_ref[SIZE_RES], res_ref2[SIZE_RES]; |
| 41 |
|
| 42 |
for (i = 0; i < SIZE; i++) |
| 43 |
{ |
| 44 |
int sign = i % 2 ? 1 : -1; |
| 45 |
src1.a[i] = 10 + 3*i*i + sign; |
| 46 |
src2.a[i] = sign*10*i*i; |
| 47 |
} |
| 48 |
|
| 49 |
for (i = 0; i < SIZE_RES; i++) |
| 50 |
{ |
| 51 |
res1.a[i] = 0x7FFFFFFF; |
| 52 |
res2.a[i] = DEFAULT_VALUE; |
| 53 |
res3.a[i] = DEFAULT_VALUE; |
| 54 |
} |
| 55 |
|
| 56 |
CALC (res_ref, res1.a, src1.a, src2.a); |
| 57 |
CALC (res_ref2, res2.a, src1.a, src2.a); |
| 58 |
|
| 59 |
res1.x = INTRINSIC (_dpbusds_epi32) (res1.x, src1.x, src2.x); |
| 60 |
res2.x = INTRINSIC (_mask_dpbusds_epi32) (res2.x, mask, src1.x, src2.x); |
| 61 |
res3.x = INTRINSIC (_maskz_dpbusds_epi32) (mask, res3.x, src1.x, src2.x); |
| 62 |
|
| 63 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref)) |
| 64 |
abort (); |
| 65 |
|
| 66 |
MASK_MERGE (i_d) (res_ref2, mask, SIZE_RES); |
| 67 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref2)) |
| 68 |
abort (); |
| 69 |
|
| 70 |
MASK_ZERO (i_d) (res_ref2, mask, SIZE_RES); |
| 71 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref2)) |
| 72 |
abort (); |
| 73 |
} |