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>
19 /* Test the 64-bit form */
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
);
29 /* Test the 128-bit form */
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 */
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
;
49 for (i
= 0; i
< 16; i
++)
55 bout
[i
] = b1
[select
& 0x7];
57 bout
[i
] = b1
[8 + (select
& 0x7)];
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
;
70 for (i
= 0; i
< 16; i
++)
76 bout
[i
] = b1
[select
& 0xf];
84 int r
[4] __attribute__ ((aligned(16)));
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
);