2018-11-28 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / sinatan-1.c
blob194926ce8d4c7e8cda332e5a7648e43054ba4714
1 /* { dg-do run } */
2 /* { dg-options "-Ofast" } */
4 extern float sinf (float);
5 extern float cosf (float);
6 extern float atanf (float);
7 extern float sqrtf (float);
8 extern float nextafterf (float, float);
9 extern double sin (double);
10 extern double cos (double);
11 extern double atan (double);
12 extern double sqrt (double);
13 extern double nextafter (double, double);
14 extern long double sinl (long double);
15 extern long double cosl (long double);
16 extern long double atanl (long double);
17 extern long double sqrtl (long double);
18 extern long double nextafterl (long double, long double);
20 extern void abort ();
22 double __attribute__ ((noinline, optimize("Ofast")))
23 sinatan (double x)
25 return sin (atan (x));
28 double __attribute__ ((noinline, optimize("Ofast")))
29 cosatan (double x)
31 return cos (atan (x));
34 float __attribute__ ((noinline, optimize("Ofast")))
35 sinatanf(float x)
37 return sinf (atanf (x));
40 float __attribute__ ((noinline, optimize("Ofast")))
41 cosatanf(float x)
43 return cosf (atanf (x));
46 long double __attribute__ ((noinline, optimize("Ofast")))
47 sinatanl (long double x)
49 return sinl (atanl (x));
52 long double __attribute__ ((noinline, optimize("Ofast")))
53 cosatanl (long double x)
55 return cosl (atanl (x));
58 int
59 main()
61 /* Get first x such that 1 + x*x will overflow */
62 float fc = nextafterf (sqrtf (__FLT_MAX__ - 1), __FLT_MAX__);
63 double c = nextafter (sqrt (__DBL_MAX__ - 1), __DBL_MAX__);
64 long double lc = nextafter (sqrtl (__LDBL_MAX__ - 1), __LDBL_MAX__);
66 /* Force move from FPU to memory, otherwise comparison may
67 fail due to possible more accurate registers (see 387) */
68 volatile float fy;
69 volatile double y;
70 volatile long double ly;
72 fy = sinatanf (fc);
73 y = sinatan (c);
74 ly = sinatanl (lc);
76 if (fy != 1.f || y != 1 || ly != 1.L)
77 abort ();
79 fy = cosatanf (fc);
80 y = cosatan (c);
81 ly = cosatanl (lc);
83 if (fy != 0.f || y != 0. || ly != 0.L)
84 abort ();
86 fy = sinatanf (-fc);
87 y = sinatan (-c);
88 ly = sinatanl (-lc);
90 if (fy != -1.f || y != -1. || ly != -1.L)
91 abort ();
93 fy = cosatanf (-fc);
94 y = cosatan (-c);
95 ly = cosatanl (-lc);
97 if (fy != 0.f || y != 0. || ly != 0.L)
98 abort ();
100 return 0;