1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
4 /* { dg-require-effective-target dfp_hw } */
5 /* { dg-options "-O2 -mhard-dfp" } */
6 
7 #include <stddef.h>
8 #include <stdlib.h>
9 #include <math.h>
10 
11 #ifdef DEBUG
12 #include <stdio.h>
13 #endif
14 
15 int
main(void)16 main (void)
17 {
18   _Decimal128 one	= (_Decimal128)1.0;
19   _Decimal128 two	= (_Decimal128)2.0;
20   _Decimal128 ten	= (_Decimal128)10.0;
21   _Decimal128 a		= one;
22   _Decimal128 b;
23   _Decimal128 c;
24   unsigned long long x0;
25   unsigned long long x1;
26   size_t i;
27 
28   for (i = 0; i < 25; i++)
29     a *= ten;
30 
31   a += two;
32 
33   x0 = __builtin_unpack_dec128 (a, 0);
34   x1 = __builtin_unpack_dec128 (a, 1);
35   b = __builtin_pack_dec128 (x0, x1);
36   c = __builtin_dscliq (one, 25) + two;
37 
38 #ifdef DEBUG
39   {
40     union {
41       _Decimal128 d;
42       unsigned long long ull;
43       unsigned char uc[sizeof (_Decimal128)];
44     } u;
45 
46     printf ("a  = 0x");
47     u.d = a;
48     for (i = 0; i < sizeof (_Decimal128); i++)
49       printf ("%.2x", u.uc[i]);
50 
51     printf (", %Lg\n", (long double)a);
52 
53     printf ("b  = 0x");
54     u.d = b;
55     for (i = 0; i < sizeof (_Decimal128); i++)
56       printf ("%.2x", u.uc[i]);
57 
58     printf (", %Lg\n", (long double)b);
59 
60     printf ("c  = 0x");
61     u.d = c;
62     for (i = 0; i < sizeof (_Decimal128); i++)
63       printf ("%.2x", u.uc[i]);
64 
65     printf (", %Lg\n", (long double)c);
66 
67     printf ("x0 = 0x");
68     u.ull = x0;
69     for (i = 0; i < sizeof (unsigned long long); i++)
70       printf ("%.2x", u.uc[i]);
71 
72     printf ("\nx1 = 0x");
73     u.ull = x1;
74     for (i = 0; i < sizeof (unsigned long long); i++)
75       printf ("%.2x", u.uc[i]);
76 
77     printf ("\n");
78   }
79 #endif
80 
81   if (a != b)
82     abort ();
83 
84   if (a != c)
85     abort ();
86 
87   return 0;
88 }
89