Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512dq-vreduceps-2.c
blob97afd2ad93e8bf75144f8a853426f907689f349a
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512dq -DAVX512DQ" } */
3 /* { dg-require-effective-target avx512dq } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 32)
8 #include "avx512f-mask-type.h"
10 #define IMM 0x23
12 void
13 CALC (float *s, float *r)
15 int i;
17 for (i = 0; i < SIZE; i++)
19 float tmp = (int) (4 * s[i]) / 4.0;
20 r[i] = s[i] - tmp;
24 void
25 TEST (void)
27 UNION_TYPE (AVX512F_LEN,) s, res1, res2, res3;
28 MASK_TYPE mask = MASK_VALUE;
29 float res_ref[SIZE];
30 int i, sign = 1;
32 for (i = 0; i < SIZE; i++)
34 s.a[i] = 123.456 * (i + 2000) * sign;
35 res2.a[i] = DEFAULT_VALUE;
36 sign = -sign;
39 res1.x = INTRINSIC (_reduce_ps) (s.x, IMM);
40 res2.x = INTRINSIC (_mask_reduce_ps) (res2.x, mask, s.x, IMM);
41 res3.x = INTRINSIC (_maskz_reduce_ps) (mask, s.x, IMM);
43 CALC (s.a, res_ref);
45 if (UNION_FP_CHECK (AVX512F_LEN,) (res1, res_ref))
46 abort ();
48 MASK_MERGE () (res_ref, mask, SIZE);
49 if (UNION_FP_CHECK (AVX512F_LEN,) (res2, res_ref))
50 abort ();
52 MASK_ZERO () (res_ref, mask, SIZE);
53 if (UNION_FP_CHECK (AVX512F_LEN,) (res3, res_ref))
54 abort ();