2 /* { dg-require-effective-target ssse3 } */
3 /* { dg-options "-O2 -fno-strict-aliasing -mssse3" } */
6 #define CHECK_H "ssse3-check.h"
10 #define TEST ssse3_test
15 #include "ssse3-vals.h"
17 #include <tmmintrin.h>
20 /* Test the 64-bit form */
22 ssse3_test_pshufb (int *i1, int *i2, int *r)
24 __m64 t1 = *(__m64 *) i1;
25 __m64 t2 = *(__m64 *) i2;
26 *(__m64 *)r = _mm_shuffle_pi8 (t1, t2);
31 /* Test the 128-bit form */
33 ssse3_test_pshufb128 (int *i1, int *i2, int *r)
35 /* Assumes incoming pointers are 16-byte aligned */
36 __m128i t1 = *(__m128i *) i1;
37 __m128i t2 = *(__m128i *) i2;
38 *(__m128i *)r = _mm_shuffle_epi8 (t1, t2);
42 /* Routine to manually compute the results */
44 compute_correct_result_64 (int *i1, int *i2, int *r)
46 char *b1 = (char *) i1;
47 char *b2 = (char *) i2;
48 char *bout = (char *) r;
52 for (i = 0; i < 16; i++)
58 bout[i] = b1[select & 0x7];
60 bout[i] = b1[8 + (select & 0x7)];
66 compute_correct_result_128 (int *i1, int *i2, int *r)
68 char *b1 = (char *) i1;
69 char *b2 = (char *) i2;
70 char *bout = (char *) r;
74 for (i = 0; i < 16; i++)
80 bout[i] = b1[select & 0xf];
88 int r [4] __attribute__ ((aligned(16)));
92 for (i = 0; i < 256; i += 8)
95 /* Manually compute the result */
96 compute_correct_result_64 (&vals[i + 0], &vals[i + 4], ck);
98 /* Run the 64-bit tests */
99 ssse3_test_pshufb (&vals[i + 0], &vals[i + 4], &r[0]);
100 ssse3_test_pshufb (&vals[i + 2], &vals[i + 6], &r[2]);
101 fail += chk_128 (ck, r);
104 /* Recompute the result for 128-bits */
105 compute_correct_result_128 (&vals[i + 0], &vals[i + 4], ck);
107 /* Run the 128-bit tests */
108 ssse3_test_pshufb128 (&vals[i + 0], &vals[i + 4], r);
109 fail += chk_128 (ck, r);