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