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