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" } */
10 /* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
11 /* { dg-options "-O2 -ffast-math -std=c99" { target *-*-solaris2* } } */
13 #include "builtins-config.h"
15 extern double cos (double);
16 extern double sin (double);
17 extern double tan (double);
18 extern float cosf (float);
19 extern float sinf (float);
20 extern float tanf (float);
21 extern long double cosl (long double);
22 extern long double sinl (long double);
23 extern long double tanl (long double);
25 extern void link_error(void);
29 if (cos(x) != cos(-x))
32 if (sin(x)/cos(x) != tan(x))
35 if (cos(x)/sin(x) != 1.0/tan(x))
38 if (tan(x)*cos(x) != sin(x))
41 if (cos(x)*tan(x) != sin(x))
44 if (sin(x)/tan(x) != cos(x))
47 if (tan(x)/sin(x) != 1.0/cos(x))
51 void test2(double x, double y)
53 if (-tan(x-y) != tan(y-x))
56 if (-sin(x-y) != sin(y-x))
62 if (cosf(x) != cosf(-x))
65 #ifdef HAVE_C99_RUNTIME
66 if (sinf(x)/cosf(x) != tanf(x))
69 if (cosf(x)/sinf(x) != 1.0f/tanf(x))
72 if (tanf(x)*cosf(x) != sinf(x))
75 if (cosf(x)*tanf(x) != sinf(x))
78 if (sinf(x)/tanf(x) != cosf(x))
81 if (tanf(x)/sinf(x) != 1.0f/cosf(x))
86 void test2f(float x, float y)
88 if (-tanf(x-y) != tanf(y-x))
91 if (-sinf(x-y) != sinf(y-x))
96 void test1l(long double x)
98 if (cosl(x) != cosl(-x))
101 #ifdef HAVE_C99_RUNTIME
102 if (sinl(x)/cosl(x) != tanl(x))
105 if (cosl(x)/sinl(x) != 1.0l/tanl(x))
108 if (tanl(x)*cosl(x) != sinl(x))
111 if (cosl(x)*tanl(x) != sinl(x))
114 if (sinl(x)/tanl(x) != cosl(x))
117 if (tanl(x)/sinl(x) != 1.0l/cosl(x))
122 void test2l(long double x, long double y)
124 if (-tanl(x-y) != tanl(y-x))
127 if (-sinl(x-y) != sinl(y-x))