Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_2-pcmpestrm-1.c
blob1c75a9b2e4dbdd294f42a0eb57543643278e1723
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_BIT_MASK)
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_UNIT_MASK)
22 static void
23 sse4_2_test (void)
25 union
27 __m128i x[NUM];
28 char c[NUM *16];
29 } src1, src2;
30 __m128i res, correct;
31 int l1, l2;
32 int i;
34 for (i = 0; i < NUM *16; i++)
36 src1.c[i] = rand ();
37 src2.c[i] = rand ();
40 for (i = 0; i < NUM; i++)
42 l1 = rand () % 18;
43 l2 = rand () % 18;
45 switch((rand() % 4))
47 case 0:
48 res = _mm_cmpestrm (src1.x[i], l1, src2.x[i], l2, IMM_VAL0);
49 correct = cmp_em (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL0,
50 NULL);
51 break;
53 case 1:
54 res = _mm_cmpestrm (src1.x[i], l1, src2.x[i], l2, IMM_VAL1);
55 correct = cmp_em (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL1,
56 NULL);
57 break;
59 case 2:
60 res = _mm_cmpestrm (src1.x[i], l1, src2.x[i], l2, IMM_VAL2);
61 correct = cmp_em (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL2,
62 NULL);
63 break;
65 default:
66 res = _mm_cmpestrm (src1.x[i], l1, src2.x[i], l2, IMM_VAL3);
67 correct = cmp_em (&src1.x[i], l1, &src2.x[i], l2, IMM_VAL3,
68 NULL);
69 break;
72 if (memcmp (&correct, &res, sizeof (res)))
73 abort ();