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 } */
7 #define CHECK_H "ssse3-check.h"
11 #define TEST ssse3_test
16 #include "ssse3-vals.h"
18 #include <tmmintrin.h>
21 /* Test the 64-bit form */
23 ssse3_test_phaddsw (__m64
*i1
, __m64
*i2
, __m64
*r
)
25 *r
= _mm_hadds_pi16 (*i1
, *i2
);
30 /* Test the 128-bit form */
32 ssse3_test_phaddsw128 (__m128i
*i1
, __m128i
*i2
, __m128i
*r
)
34 /* Assumes incoming pointers are 16-byte aligned */
35 *(__m128i
*) r
= _mm_hadds_epi16 (*i1
, *i2
);
39 signed_saturate_to_word (int x
)
44 if (x
< (int) 0xffff8000)
50 /* Routine to manually compute the results */
52 compute_correct_result (short *i1
, short *i2
, short *r
)
56 for (i
= 0; i
< 4; i
++)
57 r
[i
+ 0] = signed_saturate_to_word(i1
[2 * i
] + i1
[2 * i
+ 1]);
58 for (i
= 0; i
< 4; i
++)
59 r
[i
+ 4] = signed_saturate_to_word(i2
[2 * i
] + i2
[2 * i
+ 1]);
66 union data r
__attribute__ ((aligned(16)));
70 for (i
= 0; i
< ARRAY_SIZE (vals
) - 1; i
++)
72 /* Manually compute the result */
73 compute_correct_result (&vals
[i
+ 0].h
[0], &vals
[i
+ 1].h
[0], &ck
.h
[0]);
76 /* Run the 64-bit tests */
77 ssse3_test_phaddsw (&vals
[i
+ 0].ll
[0], &vals
[i
+ 0].ll
[1], &r
.ll
[0]);
78 ssse3_test_phaddsw (&vals
[i
+ 1].ll
[0], &vals
[i
+ 1].ll
[1], &r
.ll
[1]);
79 fail
+= chk_128 (ck
.m
[0], r
.m
[0]);
82 /* Run the 128-bit tests */
83 ssse3_test_phaddsw128 (&vals
[i
+ 0].m
[0], &vals
[i
+ 1].m
[0], &r
.m
[0]);
84 fail
+= chk_128 (ck
.m
[0], r
.m
[0]);