2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / sse2-pshufhw-1.c
bloba92302178307d33f4e910472c3aa046b6a9b403a
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mpower8-vector -Wno-psabi" } */
3 /* { dg-require-effective-target lp64 } */
4 /* { dg-require-effective-target p8vector_hw } */
6 #ifndef CHECK_H
7 #define CHECK_H "sse2-check.h"
8 #endif
10 #include CHECK_H
12 #ifndef TEST
13 #define TEST sse2_test_pshufhw_1
14 #endif
16 #define N 0xec
18 #include <emmintrin.h>
20 static __m128i
21 __attribute__((noinline, unused))
22 test (__m128i s1)
24 return _mm_shufflehi_epi16 (s1, N);
27 static void
28 TEST (void)
30 union128i_q s1;
31 union128i_w u;
32 short e[8] = { 0 };
33 int i;
34 int m1[4] = { 0x3, 0x3<<2, 0x3<<4, 0x3<<6 };
35 int m2[4];
37 s1.x = _mm_set_epi64x (0xabcde,0xef58a234);
38 u.x = test (s1.x);
40 for (i = 0; i < 4; i++)
41 e[i] = (s1.a[0]>>(16 * i)) & 0xffff;
43 for (i = 0; i < 4; i++)
44 m2[i] = (N & m1[i])>>(2*i);
46 for (i = 0; i < 4; i++)
47 e[i+4] = (s1.a[1] >> (16 * m2[i])) & 0xffff;
49 if (check_union128i_w(u, e))
50 #if DEBUG
52 union128i_w s;
53 s.x = s1.x;
54 printf ("sse2_test_pshufhw_1; check_union128i_w failed\n");
55 printf ("\t ([%hx,%hx,%hx,%hx, %hx,%hx,%hx,%hx])\n", s.a[0], s.a[1],
56 s.a[2], s.a[3], s.a[4], s.a[5], s.a[6], s.a[7]);
57 printf ("\t\t -> [%hx,%hx,%hx,%hx, %hx,%hx,%hx,%hx]\n", u.a[0], u.a[1],
58 u.a[2], u.a[3], u.a[4], u.a[5], u.a[6], u.a[7]);
59 printf ("\t expect [%hx,%hx,%hx,%hx, %hx,%hx,%hx,%hx]\n", e[0], e[1],
60 e[2], e[3], e[4], e[5], e[6], e[7]);
62 #else
63 abort ();
64 #endif