[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ssse3-phaddd.c
blob4040ffab1d78e65b916a7ac28f2f6b765728b010
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_phaddd (__m64 *i1, __m64 *i2, __m64 *r)
25 *r = _mm_hadd_pi32 (*i1, *i2);
26 _mm_empty();
28 #endif
30 /* Test the 128-bit form */
31 static void
32 ssse3_test_phaddd128 (__m128i *i1, __m128i *i2, __m128i *r)
34 /* Assumes incoming pointers are 16-byte aligned */
35 *r = _mm_hadd_epi32 (*i1, *i2);
38 /* Routine to manually compute the results */
39 static void
40 compute_correct_result(int *i1, int *i2, int *r)
42 int i;
44 for (i = 0; i < 2; i++)
45 r[i] = i1[2 * i] + i1[2 * i + 1];
46 for (i = 0; i < 2; i++)
47 r[i + 2] = i2[2 * i] + i2[2 * i + 1];
50 static void
51 TEST (void)
53 int i;
54 union data r __attribute__ ((aligned(16)));
55 union data ck;
56 int fail = 0;
58 for (i = 0; i < ARRAY_SIZE (vals) - 1; i++)
60 /* Manually compute the result */
61 compute_correct_result (&vals[i + 0].w[0], &vals[i + 1].w[0], &ck.w[0]);
63 #ifndef __AVX__
64 /* Run the 64-bit tests */
65 ssse3_test_phaddd (&vals[i + 0].ll[0], &vals[i + 0].ll[1], &r.ll[0]);
66 ssse3_test_phaddd (&vals[i + 1].ll[0], &vals[i + 1].ll[1], &r.ll[1]);
67 fail += chk_128 (ck.m[0], r.m[0]);
68 #endif
70 /* Run the 128-bit tests */
71 ssse3_test_phaddd128 (&vals[i + 0].m[0], &vals[i + 1].m[0], &r.m[0]);
72 fail += chk_128 (ck.m[0], r.m[0]);
75 if (fail != 0)
76 abort ();