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, res5, src1, src2;
27   MASK_TYPE mask = MASK_VALUE;
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       sign = sign * -1;
36     }
37   for (i = 0; i < SIZE; i++)
38     {
39       res1.a[i] = DEFAULT_VALUE;
40       res4.a[i] = DEFAULT_VALUE;
41     }
42 
43   res1.x = _mm_mask_add_ss (res1.x, mask, src1.x, src2.x);
44   res2.x = _mm_maskz_add_ss (mask, src1.x, src2.x);
45   res3.x = _mm_add_round_ss (src1.x, src2.x, _MM_FROUND_NO_EXC);
46   res4.x = _mm_mask_add_round_ss (res4.x, mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
47   res5.x = _mm_maskz_add_round_ss (mask, src1.x, src2.x, _MM_FROUND_NO_EXC);
48 
49   calc_add (res_ref, src1.a, src2.a);
50 
51   MASK_MERGE () (res_ref, mask, 1);
52   if (check_union128 (res1, res_ref))
53     abort ();
54 
55   MASK_ZERO () (res_ref, mask, 1);
56   if (check_union128 (res2, res_ref))
57     abort ();
58 
59   calc_add (res_ref, src1.a, src2.a);
60 
61   if (check_union128 (res3, res_ref))
62     abort();
63 
64   MASK_MERGE () (res_ref, mask, 1);
65   if (check_union128 (res4, res_ref))
66     abort ();
67 
68   MASK_ZERO () (res_ref, mask, 1);
69   if (check_union128 (res5, res_ref))
70     abort ();
71 }
72 
73