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* } } */
12 #include "builtins-config.h"
14 extern double cos (double);
15 extern double sin (double);
16 extern double tan (double);
17 extern float cosf (float);
18 extern float sinf (float);
19 extern float tanf (float);
20 extern long double cosl (long double);
21 extern long double sinl (long double);
22 extern long double tanl (long double);
24 extern void link_error(void);
28 if (cos(x
) != cos(-x
))
31 if (sin(x
)/cos(x
) != tan(x
))
34 if (cos(x
)/sin(x
) != 1.0/tan(x
))
37 if (tan(x
)*cos(x
) != sin(x
))
40 if (cos(x
)*tan(x
) != sin(x
))
44 void test2(double x
, double y
)
46 if (-tan(x
-y
) != tan(y
-x
))
49 if (-sin(x
-y
) != sin(y
-x
))
55 if (cosf(x
) != cosf(-x
))
58 #ifdef HAVE_C99_RUNTIME
59 if (sinf(x
)/cosf(x
) != tanf(x
))
62 if (cosf(x
)/sinf(x
) != 1.0f
/tanf(x
))
65 if (tanf(x
)*cosf(x
) != sinf(x
))
68 if (cosf(x
)*tanf(x
) != sinf(x
))
73 void test2f(float x
, float y
)
75 if (-tanf(x
-y
) != tanf(y
-x
))
78 if (-sinf(x
-y
) != sinf(y
-x
))
83 void test1l(long double x
)
85 if (cosl(x
) != cosl(-x
))
88 #ifdef HAVE_C99_RUNTIME
89 if (sinl(x
)/cosl(x
) != tanl(x
))
92 if (cosl(x
)/sinl(x
) != 1.0l/tanl(x
))
95 if (tanl(x
)*cosl(x
) != sinl(x
))
98 if (cosl(x
)*tanl(x
) != sinl(x
))
103 void test2l(long double x
, long double y
)
105 if (-tanl(x
-y
) != tanl(y
-x
))
108 if (-sinl(x
-y
) != sinl(y
-x
))