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 * s1,float * s2,float * s3,float * r)13 calc_add (float *s1, float *s2, float *s3, float* r)
14 {
15 r[0] = -s1[0] * s2[0] - s3[0];
16
17 int i;
18 for (i = 1; i < SIZE; i++)
19 r[i] = s1[i];
20 }
21
22 static void
calc_add_3(float * s1,float * s2,float * s3,float * r)23 calc_add_3 (float *s1, float *s2, float *s3, float* r)
24 {
25 r[0] = -s2[0] * s3[0] - s1[0];
26
27 int i;
28 for (i = 1; i < SIZE; i++)
29 r[i] = s1[i];
30 }
31
32 void
avx512f_test(void)33 avx512f_test (void)
34 {
35 int i, sign;
36 union128 res1, res2, res3, res4, res5, res6, res7, src1, src2, src3;
37 MASK_TYPE mask = MASK_VALUE;
38 float res_ref1[SIZE], res_ref2[SIZE];
39
40 sign = -1;
41 for (i = 0; i < SIZE; i++)
42 {
43 src1.a[i] = DEFAULT_VALUE;
44 src2.a[i] = 56.78 * (i + 1) * sign;
45 src3.a[i] = 90.12 * (i + 2) * sign;
46 sign = sign * -1;
47 }
48 for (i = 0; i < SIZE; i++)
49 {
50 res1.a[i] = DEFAULT_VALUE;
51 res2.a[i] = DEFAULT_VALUE;
52 res5.a[i] = DEFAULT_VALUE;
53 res6.a[i] = DEFAULT_VALUE;
54 }
55
56 calc_add (src1.a, src2.a, src3.a, res_ref1);
57 calc_add_3(src1.a, src2.a, src3.a, res_ref2);
58
59 res1.x = _mm_mask_fnmsub_ss (src1.x, mask, src2.x, src3.x);
60 res2.x = _mm_mask3_fnmsub_ss (src2.x, src3.x, src1.x, mask);
61 res3.x = _mm_maskz_fnmsub_ss (mask, src1.x, src2.x, src3.x);
62 res4.x = _mm_fnmsub_round_ss (src1.x, src2.x, src3.x, _MM_FROUND_NO_EXC);
63 res5.x = _mm_mask_fnmsub_round_ss (src1.x, mask, src2.x, src3.x, _MM_FROUND_NO_EXC);
64 res6.x = _mm_mask3_fnmsub_round_ss (src2.x, src3.x, src1.x, mask, _MM_FROUND_NO_EXC);
65 res7.x = _mm_maskz_fnmsub_round_ss (mask, src1.x, src2.x, src3.x, _MM_FROUND_NO_EXC);
66
67 if (check_union128 (res4, res_ref1))
68 abort();
69
70 MASK_ZERO () (res_ref1, mask, 1);
71 if (check_union128 (res3, res_ref1))
72 abort ();
73
74 MASK_ZERO () (res_ref1, mask, 1);
75 if (check_union128 (res7, res_ref1))
76 abort ();
77
78 MASK_MERGE () (res_ref2, mask, 1);
79 if (check_union128 (res2, res_ref2))
80 abort ();
81
82 MASK_MERGE () (res_ref2, mask, 1);
83 if (check_union128 (res6, res_ref2))
84 abort ();
85
86 MASK_MERGE () (res_ref1, mask, 1);
87 if (check_union128 (res1, res_ref1))
88 abort ();
89
90 MASK_MERGE () (res_ref1, mask, 1);
91 if (check_union128 (res5, res_ref1))
92 abort ();
93 }
94
95