Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.target / i386 / sse4_1-ptest-2.c
blob2e6df9538e6b02813d39e7eab1075932fbad8875
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
5 #ifndef CHECK_H
6 #define CHECK_H "sse4_1-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST sse4_1_test
11 #endif
13 #include CHECK_H
15 #include <smmintrin.h>
17 static int
18 make_ptestnzc (__m128i m, __m128i v)
20 union
22 __m128i x;
23 unsigned char c[16];
24 } val, mask;
25 int i, z, c;
27 mask.x = m;
28 val.x = v;
30 z = c = 1;
31 for (i = 0; i < 16; i++)
33 if ((mask.c[i] & val.c[i]))
34 z = 0;
35 if ((~mask.c[i] & val.c[i]))
36 c = 0;
39 return (z == 0 && c == 0) ? 1 : 0;
42 static void
43 TEST (void)
45 union
47 __m128i x;
48 unsigned int i[4];
49 } val[4];
50 int i, j, l;
51 int res[32];
53 val[0].i[0] = 0x11111111;
54 val[0].i[1] = 0x00000000;
55 val[0].i[2] = 0x00000000;
56 val[0].i[3] = 0x11111111;
58 val[1].i[0] = 0x00000000;
59 val[1].i[1] = 0x11111111;
60 val[1].i[2] = 0x11111111;
61 val[1].i[3] = 0x00000000;
63 val[2].i[0] = 0;
64 val[2].i[1] = 0;
65 val[2].i[2] = 0;
66 val[2].i[3] = 0;
68 val[3].i[0] = 0xffffffff;
69 val[3].i[1] = 0xffffffff;
70 val[3].i[2] = 0xffffffff;
71 val[3].i[3] = 0xffffffff;
73 l = 0;
74 for(i = 0; i < 4; i++)
75 for(j = 0; j < 4; j++)
77 res[l++] = _mm_testnzc_si128 (val[j].x, val[i].x);
78 res[l++] = _mm_testnzc_si128 (val[j].x, val[i].x);
81 l = 0;
82 for(i = 0; i < 4; i++)
83 for(j = 0; j < 4; j++)
85 if (res[l++] != make_ptestnzc (val[j].x, val[i].x))
86 abort ();
87 if (res[l++] != make_ptestnzc (val[j].x, val[i].x))
88 abort ();
91 if (res[2] != _mm_testnzc_si128 (val[1].x, val[0].x))
92 abort ();
94 if (res[3] != _mm_testnzc_si128 (val[1].x, val[0].x))
95 abort ();