| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavxifma" } */ |
| 3 |
/* { dg-require-effective-target avxifma } */ |
| 4 |
#define AVXIFMA |
| 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 |
void |
| 16 |
CALC (long long *r, long long *s1, long long *s2, long long *s3, int size) |
| 17 |
{ |
| 18 |
int i; |
| 19 |
long long a,b; |
| 20 |
|
| 21 |
for (i = 0; i < size; i++) |
| 22 |
{ |
| 23 |
/* Simulate higher 52 bits out of 104 bit, |
| 24 |
by shifting opernads with 0 in lower 26 bits. */ |
| 25 |
a = s2[i] >> 26; |
| 26 |
b = s3[i] >> 26; |
| 27 |
r[i] = a * b + s1[i]; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void |
| 32 |
TEST (void) |
| 33 |
{ |
| 34 |
union256i_q src1_256, src2_256, dst_256; |
| 35 |
union128i_q src1_128, src2_128, dst_128; |
| 36 |
long long dst_ref_256[4], dst_ref_128[2]; |
| 37 |
int i; |
| 38 |
|
| 39 |
for (i = 0; i < 4; i++) |
| 40 |
{ |
| 41 |
src1_256.a[i] = 15 + 3467 * i; |
| 42 |
src2_256.a[i] = 9217 + i; |
| 43 |
src1_256.a[i] = src1_256.a[i] << 26; |
| 44 |
src2_256.a[i] = src2_256.a[i] << 26; |
| 45 |
src1_256.a[i] &= ((1LL << 52) - 1); |
| 46 |
src2_256.a[i] &= ((1LL << 52) - 1); |
| 47 |
dst_256.a[i] = -1; |
| 48 |
} |
| 49 |
|
| 50 |
for (i = 0; i < 2; i++) |
| 51 |
{ |
| 52 |
src1_128.a[i] = 16 + 3467 * i; |
| 53 |
src2_128.a[i] = 9127 + i; |
| 54 |
src1_128.a[i] = src1_128.a[i] << 26; |
| 55 |
src2_128.a[i] = src2_128.a[i] << 26; |
| 56 |
src1_128.a[i] &= ((1LL << 52) - 1); |
| 57 |
src2_128.a[i] &= ((1LL << 52) - 1); |
| 58 |
dst_128.a[i] = -1; |
| 59 |
} |
| 60 |
|
| 61 |
CALC (dst_ref_256, dst_256.a, src1_256.a, src2_256.a, 4); |
| 62 |
dst_256.x = _mm256_madd52hi_avx_epu64 (dst_256.x, src1_256.x, src2_256.x); |
| 63 |
if (check_union256i_q (dst_256, dst_ref_256)) |
| 64 |
abort (); |
| 65 |
|
| 66 |
CALC (dst_ref_128, dst_128.a, src1_128.a, src2_128.a, 2); |
| 67 |
dst_128.x = _mm_madd52hi_avx_epu64 (dst_128.x, src1_128.x, src2_128.x); |
| 68 |
if (check_union128i_q (dst_128, dst_ref_128)) |
| 69 |
abort (); |
| 70 |
|
| 71 |
} |
| 72 |
|