2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-2.c
blobe3d652259b642cbef2f9ab60914d2fa1be28fe9b
1 /* Copyright (C) 2002 Free Software Foundation.
3 Verify that built-in math function constant folding doesn't
4 cause any problems for the compiler.
6 Written by Roger Sayle, 16th August 2002. */
8 /* { dg-do compile } */
9 /* { dg-options "-O2 -ffast-math" } */
11 double test1(double x)
13 return log(exp(x));
16 double test2(double x)
18 return exp(log(x));
21 double test3(double x)
23 return sqrt(exp(x));
26 double test4(double x)
28 return log(sqrt(x));
31 double test5(double x, double y)
33 return sqrt(x)*sqrt(y);
36 double test6(double x, double y)
38 return exp(x)*exp(y);
41 double test7(double x, double y)
43 return x/exp(y);
46 double test8(double x)
48 return fabs(sqrt(x));
51 double test9(double x)
53 return fabs(exp(x));
56 double test10(double x)
58 return tan(atan(x));
61 double test11(double x)
63 return fabs(fabs(x));
66 double test12(double x)
68 return fabs(atan(x));
71 double test13(double x)
73 return fabs(pow(2.0,x));
76 float test1f(float x)
78 return logf(expf(x));
81 float test2f(float x)
83 return expf(logf(x));
86 float test3f(float x)
88 return sqrtf(expf(x));
91 float test4f(float x)
93 return logf(sqrtf(x));
96 float test5f(float x, float y)
98 return sqrtf(x)*sqrtf(y);
101 float test6f(float x, float y)
103 return expf(x)*expf(y);
106 float test7f(float x, float y)
108 return x/expf(y);
111 float test8f(float x)
113 return fabsf(sqrtf(x));
116 float test9f(float x)
118 return fabsf(expf(x));
121 float test10f(float x)
123 return tanf(atanf(x));
126 float test11f(float x)
128 return fabsf(fabsf(x));
131 float test12f(float x)
133 return fabsf(atanf(x));
136 float test13f(float x)
138 return fabsf(powf(2.0f,x));
141 long double test1l(long double x)
143 return logl(expl(x));
146 long double test2l(long double x)
148 return expl(logl(x));
151 long double test3l(long double x)
153 return sqrtl(expl(x));
156 long double test4l(long double x)
158 return logl(sqrtl(x));
161 long double test5l(long double x, long double y)
163 return sqrtl(x)*sqrtl(y);
166 long double test6l(long double x, long double y)
168 return expl(x)*expl(y);
171 long double test7l(long double x, long double y)
173 return x/expl(y);
176 long double test8l(long double x)
178 return fabsl(sqrtl(x));
181 long double test9l(long double x)
183 return fabsl(expl(x));
186 long double test10l(long double x)
188 return tanl(atanl(x));
191 long double test11l(long double x)
193 return fabsl(fabsl(x));
196 long double test12l(long double x)
198 return fabsl(atanl(x));
201 long double test13l(long double x)
203 return fabsl(powl(2.0l,x));