2007-06-02 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_2-pcmpistri-1.c
blob033c07c4589f8ed0f6285298739171c32694973d
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_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_MOST_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;
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 switch ((rand () % 4))
43 case 0:
44 res = _mm_cmpistri (src1.x[i], src2.x[i], IMM_VAL0);
45 correct = cmp_ii (&src1.x[i], &src2.x[i], IMM_VAL0, NULL);
46 break;
48 case 1:
49 res = _mm_cmpistri (src1.x[i], src2.x[i], IMM_VAL1);
50 correct = cmp_ii (&src1.x[i], &src2.x[i], IMM_VAL1, NULL);
51 break;
53 case 2:
54 res = _mm_cmpistri (src1.x[i], src2.x[i], IMM_VAL2);
55 correct = cmp_ii (&src1.x[i], &src2.x[i], IMM_VAL2, NULL);
56 break;
58 default:
59 res = _mm_cmpistri (src1.x[i], src2.x[i], IMM_VAL3);
60 correct = cmp_ii (&src1.x[i], &src2.x[i], IMM_VAL3, NULL);
61 break;
64 if (correct != res)
65 abort ();