1 /* { dg-do run } */
2 /* { dg-require-effective-target avx512f } */
3 /* { dg-require-effective-target c99_runtime } */
4 /* { dg-options "-O2 -mavx512f -std=c99" } */
5 
6 #include "avx512f-check.h"
7 #include <math.h>
8 
9 double s1[2] = {2134.3343, 6678.346};
10 double s2[2] = {1485.1288, 6678.346};
11 
12 __mmask8 dst_ref;
13 
14 #define CMP(imm, rel)					\
15     dst_ref = 0;					\
16     dst_ref = ((int) rel) | dst_ref;			\
17     source1 = _mm_loadu_pd(s1);				\
18     source2 = _mm_loadu_pd(s2);				\
19     dst = _mm_cmp_sd_mask(source1, source2, imm);	\
20     dst2 = _mm_mask_cmp_sd_mask(mask, source1, source2, imm);\
21     if (dst_ref != dst) abort();			\
22     if ((dst_ref & mask) != dst2) abort();
23 
24 static void
avx512f_test()25 avx512f_test ()
26 {
27     __m128d source1, source2;
28     __mmask8 dst, dst2, mask;
29     mask = 1;
30 
31     CMP(_CMP_EQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
32     CMP(_CMP_LT_OS, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
33     CMP(_CMP_LE_OS, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
34     CMP(_CMP_UNORD_Q, isunordered(s1[0], s2[0]));
35     CMP(_CMP_NEQ_UQ, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
36     CMP(_CMP_NLT_US, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
37     CMP(_CMP_NLE_US, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
38     CMP(_CMP_ORD_Q, !isunordered(s1[0], s2[0]));
39 
40     CMP(_CMP_EQ_UQ, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
41     CMP(_CMP_NGE_US, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
42     CMP(_CMP_NGT_US, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
43 
44     CMP(_CMP_FALSE_OQ, 0);
45     CMP(_CMP_NEQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
46     CMP(_CMP_GE_OS, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
47     CMP(_CMP_GT_OS, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
48     CMP(_CMP_TRUE_UQ, 1);
49 
50     CMP(_CMP_EQ_OS, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
51     CMP(_CMP_LT_OQ, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
52     CMP(_CMP_LE_OQ, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
53     CMP(_CMP_UNORD_S, isunordered(s1[0], s2[0]));
54     CMP(_CMP_NEQ_US, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
55     CMP(_CMP_NLT_UQ, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
56     CMP(_CMP_NLE_UQ, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
57     CMP(_CMP_ORD_S, !isunordered(s1[0], s2[0]));
58     CMP(_CMP_EQ_US, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
59     CMP(_CMP_NGE_UQ, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
60     CMP(_CMP_NGT_UQ, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
61     CMP(_CMP_FALSE_OS, 0);
62     CMP(_CMP_NEQ_OS, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
63     CMP(_CMP_GE_OQ, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
64     CMP(_CMP_GT_OQ, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
65     CMP(_CMP_TRUE_US, 1)
66 }
67