1 /* Copyright (C) 2003 Free Software Foundation.
3 Verify that built-in math function constant folding doesn't break
4 anything and produces the expected results.
6 Written by Roger Sayle, 8th June 2003. */
9 /* { dg-options "-O2 -ffast-math" } */
11 #include "builtins-config.h"
13 extern double cos (double);
14 extern double sin (double);
15 extern double tan (double);
16 extern float cosf (float);
17 extern float sinf (float);
18 extern float tanf (float);
19 extern long double cosl (long double);
20 extern long double sinl (long double);
21 extern long double tanl (long double);
23 extern void link_error(void);
27 if (cos(x
) != cos(-x
))
30 if (sin(x
)/cos(x
) != tan(x
))
33 if (cos(x
)/sin(x
) != 1.0/tan(x
))
36 if (tan(x
)*cos(x
) != sin(x
))
39 if (cos(x
)*tan(x
) != sin(x
))
43 void test2(double x
, double y
)
45 if (-tan(x
-y
) != tan(y
-x
))
48 if (-sin(x
-y
) != sin(y
-x
))
54 if (cosf(x
) != cosf(-x
))
57 #ifdef HAVE_C99_RUNTIME
58 if (sinf(x
)/cosf(x
) != tanf(x
))
61 if (cosf(x
)/sinf(x
) != 1.0f
/tanf(x
))
64 if (tanf(x
)*cosf(x
) != sinf(x
))
67 if (cosf(x
)*tanf(x
) != sinf(x
))
72 void test2f(float x
, float y
)
74 if (-tanf(x
-y
) != tanf(y
-x
))
77 if (-sinf(x
-y
) != sinf(y
-x
))
82 void test1l(long double x
)
84 if (cosl(x
) != cosl(-x
))
87 #ifdef HAVE_C99_RUNTIME
88 if (sinl(x
)/cosl(x
) != tanl(x
))
91 if (cosl(x
)/sinl(x
) != 1.0l/tanl(x
))
94 if (tanl(x
)*cosl(x
) != sinl(x
))
97 if (cosl(x
)*tanl(x
) != sinl(x
))
102 void test2l(long double x
, long double y
)
104 if (-tanl(x
-y
) != tanl(y
-x
))
107 if (-sinl(x
-y
) != sinl(y
-x
))