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