[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ssse3-phsubsw.c
blob7a642e26ebb1a9a4a8dd23b843f7ca8217eb4491
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_phsubsw (__m64 *i1, __m64 *i2, __m64 *r)
25 *(__m64 *) r = _mm_hsubs_pi16 (*i1, *i2);
26 _mm_empty ();
28 #endif
30 /* Test the 128-bit form */
31 static void
32 ssse3_test_phsubsw128 (__m128i *i1, __m128i *i2, __m128i *r)
34 /* Assumes incoming pointers are 16-byte aligned */
35 *r = _mm_hsubs_epi16 (*i1, *i2);
38 static short
39 signed_saturate_to_word (int x)
41 if (x > (int )0x7fff)
42 return 0x7fff;
44 if (x < (int) 0xffff8000)
45 return 0x8000;
47 return (short)x;
50 /* Routine to manually compute the results */
51 static void
52 compute_correct_result (short *i1, short *i2, short *r)
54 int i;
56 for (i = 0; i < 4; i++)
57 r[i] = signed_saturate_to_word (i1[2 * i] - i1[2 * i + 1]);
59 for (i = 0; i < 4; i++)
60 r[i + 4] = signed_saturate_to_word (i2[2 * i] - i2[2 * i + 1]);
63 static void
64 TEST (void)
66 int i;
67 union data r __attribute__ ((aligned(16)));
68 union data ck;
69 int fail = 0;
71 for (i = 0; i < ARRAY_SIZE (vals) - 1; i++)
73 /* Manually compute the result */
74 compute_correct_result (&vals[i + 0].h[0], &vals[i + 1].h[0], &ck.h[0]);
76 #ifndef __AVX__
77 /* Run the 64-bit tests */
78 ssse3_test_phsubsw (&vals[i + 0].ll[0], &vals[i + 0].ll[1], &r.ll[0]);
79 ssse3_test_phsubsw (&vals[i + 1].ll[0], &vals[i + 1].ll[1], &r.ll[1]);
80 fail += chk_128 (ck.m[0], r.m[0]);
81 #endif
83 /* Run the 128-bit tests */
84 ssse3_test_phsubsw128 (&vals[i + 0].m[0], &vals[i + 1].m[0], &r.m[0]);
85 fail += chk_128 (ck.m[0], r.m[0]);
88 if (fail != 0)
89 abort ();