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 float s1[]={2134.3343, 6678.346, 453.345635, 54646.464356};
10 float s2[]={41124.234, 6678.346, 8653.65635, 856.43576};
11 int dd[] = {1, 2, 3, 4};
12 float d[4];
13 union{int i[4]; float f[4];} e;
14
check(unsigned imm,char * id)15 void check(unsigned imm, char *id)
16 {
17 if(checkVi((int*)d, e.i, 4)){
18 printf("mm_cmp_ss(0x%x, %s) FAILED\n", imm, id);
19 }
20 }
21
22 static void
avx_test()23 avx_test ()
24 {
25 __m128 source1, source2, dest;
26 int i;
27
28 #define CMP(imm, rel) \
29 e.i[0] = rel ? -1 : 0; \
30 dest = _mm_loadu_ps((float*)dd); \
31 source1 = _mm_loadu_ps(s1); \
32 source2 = _mm_loadu_ps(s2); \
33 dest = _mm_cmp_ss(source1, source2, imm); \
34 _mm_storeu_ps(d, dest); \
35 check(imm, "" #imm "");
36
37 for(i = 1; i < 4; i++) e.f[i] = s1[i];
38
39 CMP(_CMP_EQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
40 CMP(_CMP_LT_OS, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
41 CMP(_CMP_LE_OS, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
42 CMP(_CMP_UNORD_Q, isunordered(s1[0], s2[0]));
43 CMP(_CMP_NEQ_UQ, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
44 CMP(_CMP_NLT_US, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
45 CMP(_CMP_NLE_US, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
46 CMP(_CMP_ORD_Q, !isunordered(s1[0], s2[0]));
47
48 CMP(_CMP_EQ_UQ, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
49 CMP(_CMP_NGE_US, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
50 CMP(_CMP_NGT_US, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
51
52 CMP(_CMP_FALSE_OQ, 0);
53 CMP(_CMP_NEQ_OQ, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
54 CMP(_CMP_GE_OS, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
55 CMP(_CMP_GT_OS, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
56 CMP(_CMP_TRUE_UQ, 1);
57
58 CMP(_CMP_EQ_OS, !isunordered(s1[0], s2[0]) && s1[0] == s2[0]);
59 CMP(_CMP_LT_OQ, !isunordered(s1[0], s2[0]) && s1[0] < s2[0]);
60 CMP(_CMP_LE_OQ, !isunordered(s1[0], s2[0]) && s1[0] <= s2[0]);
61 CMP(_CMP_UNORD_S, isunordered(s1[0], s2[0]));
62 CMP(_CMP_NEQ_US, isunordered(s1[0], s2[0]) || s1[0] != s2[0]);
63 CMP(_CMP_NLT_UQ, isunordered(s1[0], s2[0]) || s1[0] >= s2[0]);
64 CMP(_CMP_NLE_UQ, isunordered(s1[0], s2[0]) || s1[0] > s2[0]);
65 CMP(_CMP_ORD_S, !isunordered(s1[0], s2[0]));
66 CMP(_CMP_EQ_US, isunordered(s1[0], s2[0]) || s1[0] == s2[0]);
67 CMP(_CMP_NGE_UQ, isunordered(s1[0], s2[0]) || s1[0] < s2[0]);
68 CMP(_CMP_NGT_UQ, isunordered(s1[0], s2[0]) || s1[0] <= s2[0]);
69 CMP(_CMP_FALSE_OS, 0);
70 CMP(_CMP_NEQ_OS, !isunordered(s1[0], s2[0]) && s1[0] != s2[0]);
71 CMP(_CMP_GE_OQ, !isunordered(s1[0], s2[0]) && s1[0] >= s2[0]);
72 CMP(_CMP_GT_OQ, !isunordered(s1[0], s2[0]) && s1[0] > s2[0]);
73 CMP(_CMP_TRUE_US, 1);
74 }
75