diagnostics: move output formats from diagnostic.{c,h} to their own files
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ssse3-pshufb.c
blob042a1ee50951d63792c5efdd8f70ede64a46a348
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mvsx -Wno-psabi" } */
3 /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */
4 /* { dg-require-effective-target p8vector_hw } */
6 #ifndef CHECK_H
7 #define CHECK_H "ssse3-check.h"
8 #endif
10 #ifndef TEST
11 #define TEST ssse3_test
12 #endif
14 #include CHECK_H
16 #include "ssse3-vals.h"
18 #include <tmmintrin.h>
20 #ifndef __AVX__
21 /* Test the 64-bit form */
22 static void
23 ssse3_test_pshufb (__m64 *i1, __m64 *i2, __m64 *r)
25 *r = _mm_shuffle_pi8 (*i1, *i2);
26 _mm_empty ();
28 #endif
30 /* Test the 128-bit form */
31 static void
32 ssse3_test_pshufb128 (__m128i *i1, __m128i *i2, __m128i *r)
34 /* Assumes incoming pointers are 16-byte aligned */
35 *r = _mm_shuffle_epi8 (*i1, *i2);
38 #ifndef __AVX__
39 /* Routine to manually compute the results */
40 static void
41 compute_correct_result_64 (signed char *i1, signed char *i2, signed char *r)
43 int i;
44 char select;
46 for (i = 0; i < 16; i++)
48 select = i2[i];
49 if (select & 0x80)
50 r[i] = 0;
51 else if (i < 8)
52 r[i] = i1[select & 0x7];
53 else
54 r[i] = i1[8 + (select & 0x7)];
57 #endif
59 static void
60 compute_correct_result_128 (signed char *i1, signed char *i2, signed char *r)
62 int i;
63 char select;
65 for (i = 0; i < 16; i++)
67 select = i2[i];
68 if (select & 0x80)
69 r[i] = 0;
70 else
71 r[i] = i1[select & 0xf];
75 static void
76 TEST (void)
78 int i;
79 union data r __attribute__ ((aligned(16)));
80 union data ck;
81 int fail = 0;
83 for (i = 0; i < ARRAY_SIZE (vals) - 1; i++)
85 #ifndef __AVX__
86 /* Manually compute the result */
87 compute_correct_result_64 (&vals[i + 0].b[0], &vals[i + 1].b[0], &ck.b[0]);
89 /* Run the 64-bit tests */
90 ssse3_test_pshufb (&vals[i + 0].ll[0], &vals[i + 1].ll[0], &r.ll[0]);
91 ssse3_test_pshufb (&vals[i + 0].ll[1], &vals[i + 1].ll[1], &r.ll[1]);
92 fail += chk_128 (ck.m[0], r.m[0]);
93 #endif
95 /* Recompute the result for 128-bits */
96 compute_correct_result_128 (&vals[i + 0].b[0], &vals[i + 1].b[0], &ck.b[0]);
98 /* Run the 128-bit tests */
99 ssse3_test_pshufb128 (&vals[i + 0].m[0], &vals[i + 1].m[0], &r.m[0]);
100 fail += chk_128 (ck.m[0], r.m[0]);
103 if (fail != 0)
104 abort ();