Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/ssse3-pabsw.c

raw
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 } */
5
6 #ifndef CHECK_H
7 #define CHECK_H "ssse3-check.h"
8 #endif
9
10 #ifndef TEST
11 #define TEST ssse3_test
12 #endif
13
14 #include CHECK_H
15
16 #include "ssse3-vals.h"
17
18 #include <tmmintrin.h>
19
20 #ifndef __AVX__
21 /* Test the 64-bit form */
22 static void
23 ssse3_test_pabsw (__m64 *i1, __m64 *r)
24 {
25 *r = _mm_abs_pi16 (*i1);
26 _mm_empty ();
27 }
28 #endif
29
30 /* Test the 128-bit form */
31 static void
32 ssse3_test_pabsw128 (__m128i *i1, __m128i *r)
33 {
34 /* Assumes incoming pointers are 16-byte aligned */
35 *r = _mm_abs_epi16 (*i1);
36 }
37
38 /* Routine to manually compute the results */
39 static void
40 compute_correct_result (short *i1, short *r)
41 {
42 int i;
43
44 for (i = 0; i < 8; i++)
45 if (i1[i] < 0)
46 r[i] = -i1[i];
47 else
48 r[i] = i1[i];
49 }
50
51 static void
52 TEST (void)
53 {
54 int i;
55 union data r __attribute__ ((aligned(16)));
56 union data ck;
57 int fail = 0;
58
59 for (i = 0; i < ARRAY_SIZE (vals); i++)
60 {
61 /* Manually compute the result */
62 compute_correct_result (&vals[i].h[0], &ck.h[0]);
63
64 #ifndef __AVX__
65 /* Run the 64-bit tests */
66 ssse3_test_pabsw (&vals[i].ll[0], &r.ll[0]);
67 ssse3_test_pabsw (&vals[i].ll[1], &r.ll[1]);
68 fail += chk_128 (ck.m[0], r.m[0]);
69 #endif
70
71 /* Run the 128-bit tests */
72 ssse3_test_pabsw128 (&vals[i].m[0], &r.m[0]);
73 fail += chk_128 (ck.m[0], r.m[0]);
74 }
75
76 if (fail != 0)
77 abort ();
78 }