]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/sinatan-1.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / sinatan-1.c
CommitLineData
5f054b17 1/* { dg-do run { target c99_runtime } } */
121ef08b 2/* { dg-options "-Ofast" } */
35b89510 3/* { dg-add-options ieee } */
121ef08b
GB
4
5extern float sinf (float);
6extern float cosf (float);
7extern float atanf (float);
8extern float sqrtf (float);
9extern float nextafterf (float, float);
10extern double sin (double);
11extern double cos (double);
12extern double atan (double);
13extern double sqrt (double);
14extern double nextafter (double, double);
15extern long double sinl (long double);
16extern long double cosl (long double);
17extern long double atanl (long double);
18extern long double sqrtl (long double);
19extern long double nextafterl (long double, long double);
20
21extern void abort ();
22
23double __attribute__ ((noinline, optimize("Ofast")))
24sinatan (double x)
25{
26 return sin (atan (x));
27}
28
29double __attribute__ ((noinline, optimize("Ofast")))
30cosatan (double x)
31{
32 return cos (atan (x));
33}
34
35float __attribute__ ((noinline, optimize("Ofast")))
36sinatanf(float x)
37{
38 return sinf (atanf (x));
39}
40
41float __attribute__ ((noinline, optimize("Ofast")))
42cosatanf(float x)
43{
44 return cosf (atanf (x));
45}
46
47long double __attribute__ ((noinline, optimize("Ofast")))
48sinatanl (long double x)
49{
50 return sinl (atanl (x));
51}
52
53long double __attribute__ ((noinline, optimize("Ofast")))
54cosatanl (long double x)
55{
56 return cosl (atanl (x));
57}
58
59int
60main()
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__);
5f054b17 65 long double lc = nextafterl (sqrtl (__LDBL_MAX__ - 1), __LDBL_MAX__);
121ef08b
GB
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}