| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavxvnni" } */ |
| 3 |
/* { dg-require-effective-target avxvnni } */ |
| 4 |
|
| 5 |
#ifndef CHECK |
| 6 |
#define CHECK "avx-check.h" |
| 7 |
#endif |
| 8 |
|
| 9 |
#ifndef TEST |
| 10 |
#define TEST avx_test |
| 11 |
#endif |
| 12 |
|
| 13 |
#include CHECK |
| 14 |
|
| 15 |
static void |
| 16 |
CALC (int *r, int *dst, short *s1, short *s2, int size) |
| 17 |
{ |
| 18 |
short tempres[16]; |
| 19 |
for (int i = 0; i < size; i++) { |
| 20 |
tempres[i] = ((int)(s1[i]) * (int)(s2[i])); |
| 21 |
} |
| 22 |
for (int i = 0; i < size / 2; i++) { |
| 23 |
long long test = (long long)dst[i] + tempres[i*2] + tempres[i*2 + 1]; |
| 24 |
r[i] = test > 0x7FFFFFFF ? 0x7FFFFFFF : test; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
TEST (void) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
union256i_d res_256; |
| 33 |
union256i_w src1_256, src2_256; |
| 34 |
int res_ref_256[8]; |
| 35 |
|
| 36 |
if (!__builtin_cpu_supports ("avxvnni")) |
| 37 |
return; |
| 38 |
|
| 39 |
for (i = 0; i < 16; i++) |
| 40 |
{ |
| 41 |
src1_256.a[i] = 1 + i; |
| 42 |
src2_256.a[i] = 2 + 2*i + i * i; |
| 43 |
} |
| 44 |
|
| 45 |
for (i = 0; i < 8; i++) |
| 46 |
res_256.a[i] = 0x7fffffff; |
| 47 |
|
| 48 |
CALC (res_ref_256, res_256.a, src1_256.a, src2_256.a, 16); |
| 49 |
res_256.x = _mm256_dpwssds_avx_epi32 (res_256.x, src1_256.x, src2_256.x); |
| 50 |
if (check_union256i_d (res_256, res_ref_256)) |
| 51 |
abort (); |
| 52 |
|
| 53 |
union128i_d res_128; |
| 54 |
union128i_w src1_128, src2_128; |
| 55 |
int res_ref_128[4]; |
| 56 |
|
| 57 |
for (i = 0; i < 8; i++) |
| 58 |
{ |
| 59 |
src1_128.a[i] = 1 + i; |
| 60 |
src2_128.a[i] = 2 + 2*i + i * i; |
| 61 |
} |
| 62 |
|
| 63 |
for (i = 0; i < 4; i++) |
| 64 |
res_128.a[i] = 0x7fffffff; |
| 65 |
|
| 66 |
CALC (res_ref_128, res_128.a, src1_128.a, src2_128.a, 8); |
| 67 |
res_128.x = _mm_dpwssds_avx_epi32 (res_128.x, src1_128.x, src2_128.x); |
| 68 |
if (check_union128i_d (res_128, res_ref_128)) |
| 69 |
abort (); |
| 70 |
} |