gccrs: Adjust error checks to match name resolution 2.0
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / ssse3-pshufb.c
blob83deb5818191762b0c2de5bd8e8d63372c42ecb0
1 /* { dg-do run } */
2 /* { dg-require-effective-target ssse3 } */
3 /* { dg-options "-O2 -fno-strict-aliasing -mssse3" } */
5 #ifndef CHECK_H
6 #define CHECK_H "ssse3-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST ssse3_test
11 #endif
13 #include CHECK_H
15 #include "ssse3-vals.h"
17 #include <tmmintrin.h>
19 /* Test the 64-bit form */
20 static void
21 ssse3_test_pshufb (int *i1, int *i2, int *r)
23 __m64 t1 = *(__m64 *) i1;
24 __m64 t2 = *(__m64 *) i2;
25 *(__m64 *)r = _mm_shuffle_pi8 (t1, t2);
26 _mm_empty ();
29 /* Test the 128-bit form */
30 static void
31 ssse3_test_pshufb128 (int *i1, int *i2, int *r)
33 /* Assumes incoming pointers are 16-byte aligned */
34 __m128i t1 = *(__m128i *) i1;
35 __m128i t2 = *(__m128i *) i2;
36 *(__m128i *)r = _mm_shuffle_epi8 (t1, t2);
39 /* Routine to manually compute the results */
40 static void
41 compute_correct_result_64 (int *i1, int *i2, int *r)
43 char *b1 = (char *) i1;
44 char *b2 = (char *) i2;
45 char *bout = (char *) r;
46 int i;
47 char select;
49 for (i = 0; i < 16; i++)
51 select = b2[i];
52 if (select & 0x80)
53 bout[i] = 0;
54 else if (i < 8)
55 bout[i] = b1[select & 0x7];
56 else
57 bout[i] = b1[8 + (select & 0x7)];
61 static void
62 compute_correct_result_128 (int *i1, int *i2, int *r)
64 char *b1 = (char *) i1;
65 char *b2 = (char *) i2;
66 char *bout = (char *) r;
67 int i;
68 char select;
70 for (i = 0; i < 16; i++)
72 select = b2[i];
73 if (select & 0x80)
74 bout[i] = 0;
75 else
76 bout[i] = b1[select & 0xf];
80 static void
81 TEST (void)
83 int i;
84 int r [4] __attribute__ ((aligned(16)));
85 int ck [4];
86 int fail = 0;
88 for (i = 0; i < 256; i += 8)
90 /* Manually compute the result */
91 compute_correct_result_64 (&vals[i + 0], &vals[i + 4], ck);
93 /* Run the 64-bit tests */
94 ssse3_test_pshufb (&vals[i + 0], &vals[i + 4], &r[0]);
95 ssse3_test_pshufb (&vals[i + 2], &vals[i + 6], &r[2]);
96 fail += chk_128 (ck, r);
98 /* Recompute the result for 128-bits */
99 compute_correct_result_128 (&vals[i + 0], &vals[i + 4], ck);
101 /* Run the 128-bit tests */
102 ssse3_test_pshufb128 (&vals[i + 0], &vals[i + 4], r);
103 fail += chk_128 (ck, r);
106 if (fail != 0)
107 abort ();