2007-06-02 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_2-pcmpestrm-1.c
blob51bab00e4d878f39851ad4ae9bd0a677b53a2926
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
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 ();