2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512ifma-vpmaddhuq-2.c
blob78af9d4cda902dba666f2e8ad587c75575519c79
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512ifma" } */
3 /* { dg-require-effective-target avx512ifma } */
5 #define AVX512IFMA
7 #include "avx512f-helper.h"
9 #define SIZE (AVX512F_LEN / 64)
10 #include "avx512f-mask-type.h"
12 void
13 CALC (long long *r, long long *s1, long long *s2, long long *s3)
15 int i;
16 long long a, b;
18 for (i = 0; i < SIZE; i++)
20 /* Simulate higher 52 bits out of 104 bit,
21 by shifting opernads with 0 in lower 26 bits. */
22 a = s2[i] >> 26;
23 b = s3[i] >> 26;
24 r[i] = a * b + s1[i];
28 void
29 TEST (void)
31 UNION_TYPE (AVX512F_LEN, i_q) src1, src2, dst1, dst2, dst3;
32 long long dst_ref[SIZE];
33 int i;
34 MASK_TYPE mask = MASK_VALUE;
36 for (i = 0; i < SIZE; i++)
38 src1.a[i] = 15 + 3467 * i;
39 src2.a[i] = 9217 + i;
40 src1.a[i] = src1.a[i] << 26;
41 src1.a[i] = src1.a[i] << 26;
42 src1.a[i] &= ((1LL << 52) - 1);
43 src2.a[i] &= ((1LL << 52) - 1);
44 dst1.a[i] = DEFAULT_VALUE;
45 dst2.a[i] = DEFAULT_VALUE;
46 dst3.a[i] = DEFAULT_VALUE;
49 CALC (dst_ref, dst1.a, src1.a, src2.a);
50 dst1.x = INTRINSIC (_madd52hi_epu64) (dst1.x, src1.x, src2.x);
51 dst2.x = INTRINSIC (_mask_madd52hi_epu64) (dst2.x, mask, src1.x, src2.x);
52 dst3.x = INTRINSIC (_maskz_madd52hi_epu64) (mask, dst3.x, src1.x, src2.x);
54 if (UNION_CHECK (AVX512F_LEN, i_q) (dst1, dst_ref))
55 abort ();
57 MASK_MERGE (i_q) (dst_ref, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN, i_q) (dst2, dst_ref))
59 abort ();
61 MASK_ZERO (i_q) (dst_ref, mask, SIZE);
62 if (UNION_CHECK (AVX512F_LEN, i_q) (dst3, dst_ref))
63 abort ();