1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512dq" } */
3 /* { dg-require-effective-target avx512dq } */
4
5 #define AVX512DQ
6 #include "avx512f-helper.h"
7 #include <string.h>
8
9 #define SIZE (AVX512F_LEN / 64)
10 #include "avx512f-mask-type.h"
11
12 #define IMM 0x23
13
14 void
CALC(double * r,double * s)15 CALC (double *r, double *s)
16 {
17 int i;
18
19 memcpy (&r[1], &s[1], sizeof(double));
20
21 for (i = 0; i < 1; i++)
22 {
23 double tmp = (int) (4 * s[i]) / 4.0;
24 r[i] = s[i] - tmp;
25 }
26 }
27
28 void
TEST(void)29 TEST (void)
30 {
31 union128d res1, res2, res3;
32 union128d s1, s2, src;
33 double res_ref[2];
34 MASK_TYPE mask = MASK_VALUE;
35 int j;
36
37 for (j = 0; j < 2; j++)
38 {
39 s1.a[j] = j / 123.456;
40 s2.a[j] = j / 123.456;
41 res_ref[j] = j / 123.456;
42 res1.a[j] = DEFAULT_VALUE;
43 res2.a[j] = DEFAULT_VALUE;
44 res3.a[j] = DEFAULT_VALUE;
45 }
46
47 res1.x = _mm_reduce_sd (s1.x, s2.x, IMM);
48 res2.x = _mm_mask_reduce_sd (s1.x, mask, s1.x, s2.x, IMM);
49 res3.x = _mm_maskz_reduce_sd (mask, s1.x, s2.x, IMM);
50
51 CALC (res_ref, s2.a);
52
53 if (check_union128d (res1, res_ref))
54 abort ();
55
56 MASK_MERGE (d) (res_ref, mask, 1);
57
58 if (check_union128d (res2, res_ref))
59 abort ();
60
61 MASK_ZERO (d) (res_ref, mask, 1);
62
63 if (check_union128d (res3, res_ref))
64 abort ();
65
66 }
67