OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / sse4_2-pcmpestri-1.c
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.2" } */
4
5 #include "sse4_2-check.h"
6 #include "sse4_2-pcmpstr.h"
7
8 #define NUM 1024
9
10 #define IMM_VAL0 \
11   (_SIDD_SBYTE_OPS | _SIDD_CMP_RANGES | _SIDD_MASKED_POSITIVE_POLARITY)
12 #define IMM_VAL1 \
13  (_SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_EACH | _SIDD_NEGATIVE_POLARITY \
14   | _SIDD_MOST_SIGNIFICANT)
15 #define IMM_VAL2 \
16  (_SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_MASKED_NEGATIVE_POLARITY)
17 #define IMM_VAL3 \
18   (_SIDD_SWORD_OPS | _SIDD_CMP_EQUAL_ORDERED \
19    | _SIDD_MASKED_NEGATIVE_POLARITY | _SIDD_LEAST_SIGNIFICANT)
20
21
22 static void
23 sse4_2_test (void)
24 {
25   union
26     {
27       __m128i x[NUM];
28       char c[NUM *16];
29     } src1, src2;
30   int res, correct, l1, l2;
31   int i;
32
33   for (i = 0; i < NUM *16; i++)
34     {
35       src1.c[i] = rand ();
36       src2.c[i] = rand ();
37     }
38
39   for (i = 0; i < NUM; i++)
40     {
41       l1 = rand () % 18;
42       l2 = rand () % 18;
43
44       switch ((rand () % 4))
45         {
46         case 0:
47           res = _mm_cmpestri (src1.x[i], l1, src2.x[i], l2, IMM_VAL0);
48           correct = cmp_ei (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL0,
49                             NULL);
50           break;
51
52         case 1:
53           res = _mm_cmpestri (src1.x[i], l1, src2.x[i], l2, IMM_VAL1);
54           correct = cmp_ei (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL1,
55                             NULL);
56           break;
57
58         case 2:
59           res = _mm_cmpestri (src1.x[i], l1, src2.x[i], l2, IMM_VAL2);
60           correct = cmp_ei (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL2,
61                             NULL);
62           break;
63
64         default:
65           res = _mm_cmpestri (src1.x[i], l1, src2.x[i], l2, IMM_VAL3);
66           correct = cmp_ei (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL3,
67                             NULL);
68           break;
69         }
70
71       if (correct != res)
72         abort ();
73     }
74 }