| 1 |
/* { dg-do run { target c99_runtime } } */ |
| 2 |
/* { dg-options "-Ofast" } */ |
| 3 |
/* { dg-add-options ieee } */ |
| 4 |
|
| 5 |
extern float sinf (float); |
| 6 |
extern float cosf (float); |
| 7 |
extern float atanf (float); |
| 8 |
extern float sqrtf (float); |
| 9 |
extern float nextafterf (float, float); |
| 10 |
extern double sin (double); |
| 11 |
extern double cos (double); |
| 12 |
extern double atan (double); |
| 13 |
extern double sqrt (double); |
| 14 |
extern double nextafter (double, double); |
| 15 |
extern long double sinl (long double); |
| 16 |
extern long double cosl (long double); |
| 17 |
extern long double atanl (long double); |
| 18 |
extern long double sqrtl (long double); |
| 19 |
extern long double nextafterl (long double, long double); |
| 20 |
|
| 21 |
extern void abort (); |
| 22 |
|
| 23 |
double __attribute__ ((noinline, optimize("Ofast"))) |
| 24 |
sinatan (double x) |
| 25 |
{ |
| 26 |
return sin (atan (x)); |
| 27 |
} |
| 28 |
|
| 29 |
double __attribute__ ((noinline, optimize("Ofast"))) |
| 30 |
cosatan (double x) |
| 31 |
{ |
| 32 |
return cos (atan (x)); |
| 33 |
} |
| 34 |
|
| 35 |
float __attribute__ ((noinline, optimize("Ofast"))) |
| 36 |
sinatanf(float x) |
| 37 |
{ |
| 38 |
return sinf (atanf (x)); |
| 39 |
} |
| 40 |
|
| 41 |
float __attribute__ ((noinline, optimize("Ofast"))) |
| 42 |
cosatanf(float x) |
| 43 |
{ |
| 44 |
return cosf (atanf (x)); |
| 45 |
} |
| 46 |
|
| 47 |
long double __attribute__ ((noinline, optimize("Ofast"))) |
| 48 |
sinatanl (long double x) |
| 49 |
{ |
| 50 |
return sinl (atanl (x)); |
| 51 |
} |
| 52 |
|
| 53 |
long double __attribute__ ((noinline, optimize("Ofast"))) |
| 54 |
cosatanl (long double x) |
| 55 |
{ |
| 56 |
return cosl (atanl (x)); |
| 57 |
} |
| 58 |
|
| 59 |
int |
| 60 |
main() |
| 61 |
{ |
| 62 |
/* Get first x such that 1 + x*x will overflow */ |
| 63 |
float fc = nextafterf (sqrtf (__FLT_MAX__ - 1), __FLT_MAX__); |
| 64 |
double c = nextafter (sqrt (__DBL_MAX__ - 1), __DBL_MAX__); |
| 65 |
long double lc = nextafterl (sqrtl (__LDBL_MAX__ - 1), __LDBL_MAX__); |
| 66 |
|
| 67 |
/* Force move from FPU to memory, otherwise comparison may |
| 68 |
fail due to possible more accurate registers (see 387) */ |
| 69 |
volatile float fy; |
| 70 |
volatile double y; |
| 71 |
volatile long double ly; |
| 72 |
|
| 73 |
fy = sinatanf (fc); |
| 74 |
y = sinatan (c); |
| 75 |
ly = sinatanl (lc); |
| 76 |
|
| 77 |
if (fy != 1.f || y != 1 || ly != 1.L) |
| 78 |
abort (); |
| 79 |
|
| 80 |
fy = cosatanf (fc); |
| 81 |
y = cosatan (c); |
| 82 |
ly = cosatanl (lc); |
| 83 |
|
| 84 |
if (fy != 0.f || y != 0. || ly != 0.L) |
| 85 |
abort (); |
| 86 |
|
| 87 |
fy = sinatanf (-fc); |
| 88 |
y = sinatan (-c); |
| 89 |
ly = sinatanl (-lc); |
| 90 |
|
| 91 |
if (fy != -1.f || y != -1. || ly != -1.L) |
| 92 |
abort (); |
| 93 |
|
| 94 |
fy = cosatanf (-fc); |
| 95 |
y = cosatan (-c); |
| 96 |
ly = cosatanl (-lc); |
| 97 |
|
| 98 |
if (fy != 0.f || y != 0. || ly != 0.L) |
| 99 |
abort (); |
| 100 |
|
| 101 |
return 0; |
| 102 |
} |