1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4
5 #include "avx512f-check.h"
6
7 #include "avx512f-helper.h"
8
9 #define SIZE (128 / 64)
10 #include "avx512f-mask-type.h"
11
12 static void
calc_sub(double * r,double * s1,double * s2)13 calc_sub (double *r, double *s1, double *s2)
14 {
15 r[0] = s1[0] - s2[0];
16 r[1] = s1[1];
17 }
18
19 void
avx512f_test(void)20 avx512f_test (void)
21 {
22 int i, sign;
23 union128d res1, res2, res3, res4, src1, src2;
24 MASK_TYPE mask = 0;
25 double res_ref[SIZE];
26
27 sign = -1;
28 for (i = 0; i < SIZE; i++)
29 {
30 src1.a[i] = 1.5 + 34.67 * i * sign;
31 src2.a[i] = -22.17 * i * sign + 1.0;
32 res1.a[i] = DEFAULT_VALUE;
33 res3.a[i] = DEFAULT_VALUE;
34 sign = sign * -1;
35 }
36
37 res1.x = _mm_mask_sub_sd (res1.x, mask, src1.x, src2.x);
38 res2.x = _mm_maskz_sub_sd (mask, src1.x, src2.x);
39 res3.x = _mm_mask_sub_round_sd (res3.x, mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
40 res4.x = _mm_maskz_sub_round_sd (mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
41
42 calc_sub (res_ref, src1.a, src2.a);
43
44 MASK_MERGE (d) (res_ref, mask, 1);
45 if (check_union128d (res1, res_ref))
46 abort ();
47
48 MASK_ZERO (d) (res_ref, mask, 1);
49 if (check_union128d (res2, res_ref))
50 abort ();
51
52 calc_sub (res_ref, src1.a, src2.a);
53
54 MASK_MERGE (d) (res_ref, mask, 1);
55 if (check_union128d (res3, res_ref))
56 abort ();
57
58 MASK_ZERO (d) (res_ref, mask, 1);
59 if (check_union128d (res4, res_ref))
60 abort ();
61 }
62
63