[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pack01.c
blobfc1dd5059518ad39e0ab5628ce7acf1dcdcad22e
1 /* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target p8vector_hw } */
4 /* { dg-options "-mdejagnu-cpu=power8 -O2" } */
6 #include <stddef.h>
7 #include <stdlib.h>
8 #include <altivec.h>
9 #include <string.h>
11 #ifdef DEBUG
12 #include <stdio.h>
13 #endif
15 typedef __int128_t __attribute__((__vector_size__(16))) vector_128_t;
16 typedef __int128_t scalar_128_t;
17 typedef unsigned long long scalar_64_t;
19 volatile scalar_64_t one = 1;
20 volatile scalar_64_t two = 2;
22 int
23 main (void)
25 scalar_128_t a = (((scalar_128_t)one) << 64) | ((scalar_128_t)two);
26 vector_128_t v1 = (vector_128_t) { a };
27 vector_128_t v2 = __builtin_pack_vector_int128 (one, two);
28 scalar_64_t x0 = __builtin_unpack_vector_int128 (v1, 0);
29 scalar_64_t x1 = __builtin_unpack_vector_int128 (v1, 1);
30 vector_128_t v3 = __builtin_pack_vector_int128 (x0, x1);
32 size_t i;
33 union {
34 scalar_128_t i128;
35 vector_128_t v128;
36 scalar_64_t u64;
37 unsigned char uc[sizeof (scalar_128_t)];
38 char c[sizeof (scalar_128_t)];
39 } u, u2;
41 #ifdef DEBUG
43 printf ("a = 0x");
44 u.i128 = a;
45 for (i = 0; i < sizeof (scalar_128_t); i++)
46 printf ("%.2x", u.uc[i]);
48 printf ("\nv1 = 0x");
49 u.v128 = v1;
50 for (i = 0; i < sizeof (scalar_128_t); i++)
51 printf ("%.2x", u.uc[i]);
53 printf ("\nv2 = 0x");
54 u.v128 = v2;
55 for (i = 0; i < sizeof (scalar_128_t); i++)
56 printf ("%.2x", u.uc[i]);
58 printf ("\nv3 = 0x");
59 u.v128 = v3;
60 for (i = 0; i < sizeof (scalar_128_t); i++)
61 printf ("%.2x", u.uc[i]);
63 printf ("\nx0 = 0x");
64 u.u64 = x0;
65 for (i = 0; i < sizeof (scalar_64_t); i++)
66 printf ("%.2x", u.uc[i]);
68 printf ("\nx1 = 0x");
69 u.u64 = x1;
70 for (i = 0; i < sizeof (scalar_64_t); i++)
71 printf ("%.2x", u.uc[i]);
73 printf ("\n");
75 #endif
77 u2.i128 = a;
78 u.v128 = v1;
79 if (memcmp (u.c, u2.c, sizeof (scalar_128_t)) != 0)
80 abort ();
82 u.v128 = v2;
83 if (memcmp (u.c, u2.c, sizeof (scalar_128_t)) != 0)
84 abort ();
86 u.v128 = v3;
87 if (memcmp (u.c, u2.c, sizeof (scalar_128_t)) != 0)
88 abort ();
90 return 0;