1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx5124fmaps" } */
3 /* { dg-require-effective-target avx5124fmaps } */
4 
5 #define ESP_FLOAT 1.0
6 
7 #define AVX5124FMAPS
8 #include "avx512f-helper.h"
9 
10 #define SIZE (AVX512F_LEN / 32)
11 
12 #include "avx512f-mask-type.h"
13 
14 void
CALC(float * src1,float * src2,float * src3,float * src4,float * prev_dst,float * mult,float * dst)15 CALC (float *src1, float* src2, float *src3,
16       float *src4, float* prev_dst, float *mult, float *dst)
17 {
18   int i;
19 
20   for (i = 0; i < SIZE; i++)
21     {
22       dst[i] = (double)prev_dst[i]
23 	- (double)src1[i] * (double)mult[0]
24 	- (double)src2[i] * (double)mult[1]
25 	- (double)src3[i] * (double)mult[2]
26 	- (double)src4[i] * (double)mult[3];
27     }
28 }
29 
30 void
TEST(void)31 TEST (void)
32 {
33   int i, sign;
34   UNION_TYPE (AVX512F_LEN,) src1, src2, src3, src4, src5, dst, res1, res2, res3;
35   UNION_TYPE (128,) mult;
36   MASK_TYPE mask = MASK_VALUE;
37   float res_ref[SIZE];
38 
39   sign = -1;
40   for (i = 0; i < SIZE; i++)
41     {
42       src1.a[i] = 1.5 + 34.67 * i * sign;
43       src2.a[i] = -22.17 * i * sign;
44       src3.a[i] = src1.a[i] * src1.a[i];
45       src4.a[i] = src2.a[i] * src2.a[i];
46       sign = sign * -1;
47     }
48   for (i = 0; i < 4; i++)
49     mult.a[i] = 3.1415 + i * 2.71828;
50 
51   for (i = 0; i < SIZE; i++)
52     src5.a[i] = DEFAULT_VALUE;
53 
54   CALC (src1.a, src2.a, src3.a, src4.a, src5.a, mult.a, res_ref);
55 
56   res1.x = INTRINSIC (_4fnmadd_ps)       (      src5.x, src1.x, src2.x, src3.x, src4.x, &mult.x);
57   res2.x = INTRINSIC (_mask_4fnmadd_ps)  (src5.x, mask, src1.x, src2.x, src3.x, src4.x, &mult.x);
58   res3.x = INTRINSIC (_maskz_4fnmadd_ps) (mask, src5.x, src1.x, src2.x, src3.x, src4.x, &mult.x);
59 
60   if (UNION_FP_CHECK (AVX512F_LEN,) (res1, res_ref))
61     abort ();
62 
63   MASK_MERGE () (res_ref, mask, SIZE);
64   if (UNION_FP_CHECK (AVX512F_LEN,) (res2, res_ref))
65     abort ();
66 
67   MASK_ZERO () (res_ref, mask, SIZE);
68   if (UNION_FP_CHECK (AVX512F_LEN,) (res3, res_ref))
69     abort ();
70 }
71