gcc/ChangeLog:
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pack03.c
blobf6e994388c0b4e64baa6e33fb520b319af1df570
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" } */
7 #include <stddef.h>
8 #include <stdlib.h>
9 #include <math.h>
11 #ifdef DEBUG
12 #include <stdio.h>
13 #endif
15 int
16 main (void)
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;
28 for (i = 0; i < 25; i++)
29 a *= ten;
31 a += two;
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;
38 #ifdef DEBUG
40 union {
41 _Decimal128 d;
42 unsigned long long ull;
43 unsigned char uc[sizeof (_Decimal128)];
44 } u;
46 printf ("a = 0x");
47 u.d = a;
48 for (i = 0; i < sizeof (_Decimal128); i++)
49 printf ("%.2x", u.uc[i]);
51 printf (", %Lg\n", (long double)a);
53 printf ("b = 0x");
54 u.d = b;
55 for (i = 0; i < sizeof (_Decimal128); i++)
56 printf ("%.2x", u.uc[i]);
58 printf (", %Lg\n", (long double)b);
60 printf ("c = 0x");
61 u.d = c;
62 for (i = 0; i < sizeof (_Decimal128); i++)
63 printf ("%.2x", u.uc[i]);
65 printf (", %Lg\n", (long double)c);
67 printf ("x0 = 0x");
68 u.ull = x0;
69 for (i = 0; i < sizeof (unsigned long long); i++)
70 printf ("%.2x", u.uc[i]);
72 printf ("\nx1 = 0x");
73 u.ull = x1;
74 for (i = 0; i < sizeof (unsigned long long); i++)
75 printf ("%.2x", u.uc[i]);
77 printf ("\n");
79 #endif
81 if (a != b)
82 abort ();
84 if (a != c)
85 abort ();
87 return 0;