Debian Codegraph @

gcc/testsuite/gcc.target/i386/sse-cmp-2.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse2 } */
3 /* { dg-require-effective-target c99_runtime } */
4 /* { dg-options "-O2 -msse2 -std=c99" } */
5
6 #include "sse2-check.h"
7 #include "emmintrin.h"
8 #include <math.h>
9
10 double sd1[2]={2134.3343,6678.346};
11 double sd2[2]={41124.234,6678.346};
12
13 float ss1[4]={2134.3343,6678.346,453.345635,54646.464356};
14 float ss2[4]={41124.234,6678.346,8653.65635,856.43576};
15
16 union
17 {
18 double x[2];
19 long long a[2];
20 }dd, ed;
21
22 union
23 {
24 float x[4];
25 int a[4];
26 }ds, es;
27
28 #define CHECK(INTSIZE, SIZE, NUNITS, SUFFIX) \
29 void check##SUFFIX(unsigned imm, char *id) \
30 { \
31 if(checkV##INTSIZE(d##SIZE.a, e##SIZE.a, NUNITS)){ \
32 printf("mm_cmp_" #SUFFIX "(%s: 0x%x) FAILED\n", id, imm);\
33 abort(); \
34 } \
35 }
36
37 CHECK (l, d, 2, pd)
38 CHECK (i, s, 4, ps)
39 CHECK (l, d, 2, sd)
40 CHECK (i, s, 4, ss)
41
42 #define CMP(imm, rel, SIZE, NUNITS, SUFFIX) \
43 for (i = 0; i < NUNITS; i++) e##SIZE.a[i] = rel ? -1 : 0; \
44 source##SIZE##1 = _mm_loadu_p##SIZE(s##SIZE##1); \
45 source##SIZE##2 = _mm_loadu_p##SIZE(s##SIZE##2); \
46 dest##SIZE = _mm_cmp_##SUFFIX(source##SIZE##1, source##SIZE##2, imm); \
47 _mm_storeu_p##SIZE(d##SIZE.x, dest##SIZE); \
48 check##SUFFIX(imm, "" #imm "");
49
50 static void
51 sse2_test ()
52 {
53 __m128d sourced1, sourced2, destd;
54 __m128 sources1, sources2, dests;
55 int i;
56
57 CMP(_CMP_EQ_OQ, !isunordered(sd1[i], sd2[i]) && sd1[i] == sd2[i], d, 2, pd);
58 CMP(_CMP_LT_OS, !isunordered(sd1[i], sd2[i]) && sd1[i] < sd2[i], d, 2, pd);
59 CMP(_CMP_LE_OS, !isunordered(sd1[i], sd2[i]) && sd1[i] <= sd2[i], d, 2, pd);
60 CMP(_CMP_UNORD_Q, isunordered(sd1[i], sd2[i]), d, 2, pd);
61 CMP(_CMP_NEQ_UQ, isunordered(sd1[i], sd2[i]) || sd1[i] != sd2[i], d, 2, pd);
62 CMP(_CMP_NLT_US, isunordered(sd1[i], sd2[i]) || sd1[i] >= sd2[i], d, 2, pd);
63 CMP(_CMP_NLE_US, isunordered(sd1[i], sd2[i]) || sd1[i] > sd2[i], d, 2, pd);
64 CMP(_CMP_ORD_Q, !isunordered(sd1[i], sd2[i]), d, 2, pd);
65
66 CMP(_CMP_EQ_OQ, !isunordered(ss1[i], ss2[i]) && ss1[i] == ss2[i], s, 4, ps);
67 CMP(_CMP_LT_OS, !isunordered(ss1[i], ss2[i]) && ss1[i] < ss2[i], s, 4, ps);
68 CMP(_CMP_LE_OS, !isunordered(ss1[i], ss2[i]) && ss1[i] <= ss2[i], s, 4, ps);
69 CMP(_CMP_UNORD_Q, isunordered(ss1[i], ss2[i]), s, 4, ps);
70 CMP(_CMP_NEQ_UQ, isunordered(ss1[i], ss2[i]) || ss1[i] != ss2[i], s, 4, ps);
71 CMP(_CMP_NLT_US, isunordered(ss1[i], ss2[i]) || ss1[i] >= ss2[i], s, 4, ps);
72 CMP(_CMP_NLE_US, isunordered(ss1[i], ss2[i]) || ss1[i] > ss2[i], s, 4, ps);
73 CMP(_CMP_ORD_Q, !isunordered(ss1[i], ss2[i]), s, 4, ps);
74
75 dd.x[1] = ed.x[1] = sd1[1];
76
77 CMP(_CMP_EQ_OQ, !isunordered(sd1[0], sd2[0]) && sd1[0] == sd2[0], d, 1, sd);
78 CMP(_CMP_LT_OS, !isunordered(sd1[0], sd2[0]) && sd1[0] < sd2[0], d, 1, sd);
79 CMP(_CMP_LE_OS, !isunordered(sd1[0], sd2[0]) && sd1[0] <= sd2[0], d, 1, sd);
80 CMP(_CMP_UNORD_Q, isunordered(sd1[0], sd2[0]), d, 1, sd);
81 CMP(_CMP_NEQ_UQ, isunordered(sd1[0], sd2[0]) || sd1[0] != sd2[0], d, 1, sd);
82 CMP(_CMP_NLT_US, isunordered(sd1[0], sd2[0]) || sd1[0] >= sd2[0], d, 1, sd);
83 CMP(_CMP_NLE_US, isunordered(sd1[0], sd2[0]) || sd1[0] > sd2[0], d, 1, sd);
84 CMP(_CMP_ORD_Q, !isunordered(sd1[0], sd2[0]), d, 1, sd);
85
86 for(i = 1; i < 4; i++) ds.x[i] = es.x[i] = ss1[i];
87
88 CMP(_CMP_EQ_OQ, !isunordered(ss1[0], ss2[0]) && ss1[0] == ss2[0], s, 1, ss);
89 CMP(_CMP_LT_OS, !isunordered(ss1[0], ss2[0]) && ss1[0] < ss2[0], s, 1, ss);
90 CMP(_CMP_LE_OS, !isunordered(ss1[0], ss2[0]) && ss1[0] <= ss2[0], s, 1, ss);
91 CMP(_CMP_UNORD_Q, isunordered(ss1[0], ss2[0]), s, 1, ss);
92 CMP(_CMP_NEQ_UQ, isunordered(ss1[0], ss2[0]) || ss1[0] != ss2[0], s, 1, ss);
93 CMP(_CMP_NLT_US, isunordered(ss1[0], ss2[0]) || ss1[0] >= ss2[0], s, 1, ss);
94 CMP(_CMP_NLE_US, isunordered(ss1[0], ss2[0]) || ss1[0] > ss2[0], s, 1, ss);
95 CMP(_CMP_ORD_Q, !isunordered(ss1[0], ss2[0]), s, 1, ss);
96 }