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 / 32)
10 #include "avx512f-mask-type.h"
11 
12 static void
calc_add(float * r,float * s1,float * s2)13 calc_add (float *r, float *s1, float *s2)
14 {
15   r[0] = s1[0] + s2[0];
16 
17   int i;
18   for (i = 1; i < SIZE; i++)
19     r[i] = s1[i];
20 }
21 
22 void
avx512f_test(void)23 avx512f_test (void)
24 {
25   int i, sign;
26   union128 res1, res2, res3, res4, src1, src2;
27   MASK_TYPE mask = 0;
28   float res_ref[SIZE];
29 
30   sign = -1;
31   for (i = 0; i < SIZE; i++)
32     {
33       src1.a[i] = 1.5 + 34.67 * i * sign;
34       src2.a[i] = -22.17 * i * sign + 1.0;
35       res1.a[i] = DEFAULT_VALUE;
36       res3.a[i] = DEFAULT_VALUE;
37       sign = sign * -1;
38     }
39 
40   res1.x = _mm_mask_add_ss (res1.x, mask, src1.x, src2.x);
41   res2.x = _mm_maskz_add_ss (mask, src1.x, src2.x);
42   res3.x = _mm_mask_add_round_ss (res3.x, mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
43   res4.x = _mm_maskz_add_round_ss (mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
44 
45   calc_add (res_ref, src1.a, src2.a);
46 
47   MASK_MERGE () (res_ref, mask, 1);
48   if (check_union128 (res1, res_ref))
49     abort ();
50 
51   MASK_ZERO () (res_ref, mask, 1);
52   if (check_union128 (res2, res_ref))
53     abort ();
54 
55   calc_add (res_ref, src1.a, src2.a);
56 
57   MASK_MERGE () (res_ref, mask, 1);
58   if (check_union128 (res3, res_ref))
59     abort ();
60 
61   MASK_ZERO () (res_ref, mask, 1);
62   if (check_union128 (res4, res_ref))
63     abort ();
64 }
65 
66