1 /* { dg-do run } */
2 /* { dg-require-effective-target avx } */
3 /* { dg-require-effective-target c99_runtime } */
4 /* { dg-options "-O2 -mavx -std=c99" } */
5
6 #include "avx-check.h"
7 #include <math.h>
8
9 double s1[] = {2134.3343, 6678.346};
10 double s2[] = {41124.234, 6678.346};
11 long long dd[] = {1, 2}, d[2];
12 union{long long l[2]; double d[2];} e;
13
check(unsigned imm,char * id)14 void check(unsigned imm, char *id)
15 {
16 if(checkVl(d, e.l, 2)){
17 printf("mm_cmp_sd(%s: 0x%x) FAILED\n", id, imm);
18 }
19 }
20
21 #define CMP(imm, rel) \
22 e.l[0] = rel ? -1 : 0; \
23 dest = _mm_loadu_pd((double*)dd); \
24 source1 = _mm_loadu_pd(s1); \
25 source2 = _mm_loadu_pd(s2); \
26 dest = _mm_cmp_sd(source1, source2, imm); \
27 _mm_storeu_pd((double*) d, dest); \
28 check(imm, "" #imm "");
29
30 static void
avx_test()31 avx_test ()
32 {
33 __m128d source1, source2, dest;
34
35 e.d[1] = s1[1];
36
37 CMP(_CMP_EQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
38 CMP(_CMP_LT_OS, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
39 CMP(_CMP_LE_OS, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
40 CMP(_CMP_UNORD_Q, isunordered(s1[0], s2[0]));
41 CMP(_CMP_NEQ_UQ, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
42 CMP(_CMP_NLT_US, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
43 CMP(_CMP_NLE_US, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
44 CMP(_CMP_ORD_Q, !isunordered(s1[0], s2[0]));
45
46 CMP(_CMP_EQ_UQ, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
47 CMP(_CMP_NGE_US, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
48 CMP(_CMP_NGT_US, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
49
50 CMP(_CMP_FALSE_OQ, 0);
51 CMP(_CMP_NEQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
52 CMP(_CMP_GE_OS, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
53 CMP(_CMP_GT_OS, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
54 CMP(_CMP_TRUE_UQ, 1);
55
56 CMP(_CMP_EQ_OS, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
57 CMP(_CMP_LT_OQ, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
58 CMP(_CMP_LE_OQ, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
59 CMP(_CMP_UNORD_S, isunordered(s1[0], s2[0]));
60 CMP(_CMP_NEQ_US, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
61 CMP(_CMP_NLT_UQ, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
62 CMP(_CMP_NLE_UQ, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
63 CMP(_CMP_ORD_S, !isunordered(s1[0], s2[0]));
64 CMP(_CMP_EQ_US, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
65 CMP(_CMP_NGE_UQ, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
66 CMP(_CMP_NGT_UQ, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
67 CMP(_CMP_FALSE_OS, 0);
68 CMP(_CMP_NEQ_OS, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
69 CMP(_CMP_GE_OQ, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
70 CMP(_CMP_GT_OQ, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
71 CMP(_CMP_TRUE_US, 1);
72 }
73