Merged with mainline at revision 128810.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_2-pcmpestri-1.c
blobc66719f04fd7b84d5eac72cc0106a175d1fd2f2b
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.2" } */
5 #include "sse4_2-check.h"
6 #include "sse4_2-pcmpstr.h"
8 #define NUM 1024
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)
22 static void
23 sse4_2_test (void)
25 union
27 __m128i x[NUM];
28 char c[NUM *16];
29 } src1, src2;
30 int res, correct, l1, l2;
31 int i;
33 for (i = 0; i < NUM *16; i++)
35 src1.c[i] = rand ();
36 src2.c[i] = rand ();
39 for (i = 0; i < NUM; i++)
41 l1 = rand () % 18;
42 l2 = rand () % 18;
44 switch ((rand () % 4))
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;
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;
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;
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;
71 if (correct != res)
72 abort ();