1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4
5 #define AVX512F
6
7 #include "avx512f-helper.h"
8
9 #define SIZE (AVX512F_LEN / 64)
10 #include "avx512f-mask-type.h"
11
12 static void
CALC(double * s1,double * s2,double * s3,double * r)13 CALC (double *s1, double *s2, double *s3, double *r)
14 {
15 int i;
16
17 for (i = 0; i < SIZE; i++)
18 {
19 if (i % 2)
20 r[i] = s1[i] * s2[i] + s3[i];
21 else
22 r[i] = s1[i] * s2[i] - s3[i];
23 }
24 }
25
26 void
TEST(void)27 TEST (void)
28 {
29 UNION_TYPE (AVX512F_LEN, d) s1, s2, s3, res1, res2, res3, res4;
30 MASK_TYPE mask = MASK_VALUE;
31 double res_ref1[SIZE];
32 double res_ref2[SIZE];
33 int i, sign = 1;
34
35 for (i = 0; i < SIZE; i++)
36 {
37 s1.a[i] = DEFAULT_VALUE;
38 s2.a[i] = 56.78 * (i + 1) * sign;
39 s3.a[i] = 90.12 * (i + 2) * sign;
40 sign = -sign;
41 }
42
43 #if AVX512F_LEN == 512
44 res1.x = INTRINSIC (_fmaddsub_pd) (s1.x, s2.x, s3.x);
45 #endif
46 res2.x = INTRINSIC (_mask_fmaddsub_pd) (s1.x, mask, s2.x, s3.x);
47 res3.x = INTRINSIC (_mask3_fmaddsub_pd) (s2.x, s3.x, s1.x, mask);
48 res4.x = INTRINSIC (_maskz_fmaddsub_pd) (mask, s1.x, s2.x, s3.x);
49
50 CALC (s1.a, s2.a, s3.a, res_ref1);
51 CALC (s2.a, s3.a, s1.a, res_ref2);
52
53 #if AVX512F_LEN == 512
54 if (UNION_ROUGH_CHECK (AVX512F_LEN, d) (res1, res_ref1, 0.0001))
55 abort ();
56 #endif
57
58 MASK_MERGE (d) (res_ref1, mask, SIZE);
59 if (UNION_ROUGH_CHECK (AVX512F_LEN, d) (res2, res_ref1, 0.0001))
60 abort ();
61
62 MASK_MERGE (d) (res_ref2, mask, SIZE);
63 if (UNION_ROUGH_CHECK (AVX512F_LEN, d) (res3, res_ref2, 0.0001))
64 abort ();
65
66 MASK_ZERO (d) (res_ref1, mask, SIZE);
67 if (UNION_ROUGH_CHECK (AVX512F_LEN, d) (res4, res_ref1, 0.0001))
68 abort ();
69 }
70