| 1 |
/* { dg-do run { target { ! avr_tiny } } } */ |
| 2 |
/* { dg-additional-options "-std=gnu99 -Wno-pedantic" } */ |
| 3 |
|
| 4 |
typedef long double DD; |
| 5 |
|
| 6 |
typedef long long _Fract dq_t; |
| 7 |
typedef long long _Accum ta_t; |
| 8 |
typedef long _Accum da_t; |
| 9 |
typedef unsigned long long _Fract udq_t; |
| 10 |
typedef unsigned long long _Accum uta_t; |
| 11 |
typedef unsigned long _Accum uda_t; |
| 12 |
|
| 13 |
#define NI __attribute__((noipa)) |
| 14 |
|
| 15 |
#define MK_CONV(T) \ |
| 16 |
NI DD T##2d (T##_t x) \ |
| 17 |
{ \ |
| 18 |
__asm ("" : "+r" (x)); \ |
| 19 |
return (DD) x; \ |
| 20 |
} \ |
| 21 |
\ |
| 22 |
NI T##_t d2##T (DD x) \ |
| 23 |
{ \ |
| 24 |
__asm ("" : "+r" (x)); \ |
| 25 |
return (T##_t) x; \ |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
MK_CONV (da) |
| 30 |
MK_CONV (ta) |
| 31 |
MK_CONV (dq) |
| 32 |
|
| 33 |
MK_CONV (uda) |
| 34 |
MK_CONV (uta) |
| 35 |
MK_CONV (udq) |
| 36 |
|
| 37 |
#define TEST(T) \ |
| 38 |
do { \ |
| 39 |
T##_t fx = d2##T (x); \ |
| 40 |
DD y = T##2d (fx); \ |
| 41 |
if (y != x) \ |
| 42 |
__builtin_exit (__LINE__); \ |
| 43 |
} while (0) |
| 44 |
|
| 45 |
|
| 46 |
NI void test_s (DD x) |
| 47 |
{ |
| 48 |
TEST (da); |
| 49 |
TEST (ta); |
| 50 |
|
| 51 |
if (x < 1.0L && x >= -1.0L) |
| 52 |
TEST (dq); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
NI void test_u (long double x) |
| 57 |
{ |
| 58 |
TEST (uda); |
| 59 |
TEST (uta); |
| 60 |
|
| 61 |
if (x < 1.0L) |
| 62 |
TEST (udq); |
| 63 |
} |
| 64 |
|
| 65 |
void test (DD x) |
| 66 |
{ |
| 67 |
if (x >= 0) |
| 68 |
test_u (x); |
| 69 |
|
| 70 |
test_s (x); |
| 71 |
} |
| 72 |
|
| 73 |
int main (void) |
| 74 |
{ |
| 75 |
test (+0.0L); |
| 76 |
test (-0.0L); |
| 77 |
|
| 78 |
test (+1.0L); |
| 79 |
test (-1.0L); |
| 80 |
|
| 81 |
test (-0x0.cafe123p0); |
| 82 |
test (+0x0.cafe123p0); |
| 83 |
|
| 84 |
test (+0x1234.cafe123p0); |
| 85 |
test (-0x1234.cafe123p0); |
| 86 |
|
| 87 |
return 0; |
| 88 |
} |