1 /* Copyright (C) 2002, 2003, 2004 Free Software Foundation.
3 Verify that built-in math function constant folding of constant
4 arguments is correctly performed by the compiler.
6 Written by Roger Sayle, 16th August 2002. */
9 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
11 extern double atan (double);
12 extern float atanf (float);
13 extern long double atanl (long double);
14 extern double cbrt (double);
15 extern float cbrtf (float);
16 extern long double cbrtl (long double);
17 extern double cos (double);
18 extern float cosf (float);
19 extern long double cosl (long double);
20 extern double exp (double);
21 extern float expf (float);
22 extern long double expl (long double);
23 extern double log (double);
24 extern float logf (float);
25 extern long double logl (long double);
26 extern double pow (double, double);
27 extern float powf (float, float);
28 extern long double powl (long double, long double);
29 extern double sin (double);
30 extern float sinf (float);
31 extern long double sinl (long double);
32 extern double sqrt (double);
33 extern float sqrtf (float);
34 extern long double sqrtl (long double);
35 extern double tan (double);
36 extern float tanf (float);
37 extern long double tanl (long double);
39 /* All references to link_error should go away at compile-time. */
40 extern void link_error(void);
42 void test (float f
, double d
, long double ld
)
44 if (sqrt (0.0) != 0.0)
47 if (sqrt (1.0) != 1.0)
50 if (cbrt (0.0) != 0.0)
53 if (cbrt (1.0) != 1.0)
56 if (cbrt (-1.0) != -1.0)
62 if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
77 if (atan (0.0) != 0.0)
80 if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
83 if (pow (d
, 0.0) != 1.0)
86 if (pow (1.0, d
) != 1.0)
90 if (sqrtf (0.0F
) != 0.0F
)
93 if (sqrtf (1.0F
) != 1.0F
)
96 if (cbrtf (0.0F
) != 0.0F
)
99 if (cbrtf (1.0F
) != 1.0F
)
102 if (cbrtf (-1.0F
) != -1.0F
)
105 if (expf (0.0F
) != 1.0F
)
108 if (expf (1.0F
) <= 2.71F
|| expf (1.0F
) >= 2.72F
)
111 if (logf (1.0F
) != 0.0F
)
114 if (sinf (0.0F
) != 0.0F
)
117 if (cosf (0.0F
) != 1.0F
)
120 if (tanf (0.0F
) != 0.0F
)
123 if (atanf (0.0F
) != 0.0F
)
126 if (4.0F
*atanf (1.0F
) <= 3.14F
|| 4.0F
*atanf (1.0F
) >= 3.15F
)
129 if (powf (f
, 0.0F
) != 1.0F
)
132 if (powf (1.0F
, f
) != 1.0F
)
136 if (sqrtl (0.0L) != 0.0L)
139 if (sqrtl (1.0L) != 1.0L)
142 if (cbrtl (0.0L) != 0.0L)
145 if (cbrtl (1.0L) != 1.0L)
148 if (cbrtl (-1.0L) != -1.0L)
151 if (expl (0.0L) != 1.0L)
154 if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
157 if (logl (1.0L) != 0.0L)
160 if (sinl (0.0L) != 0.0L)
163 if (cosl (0.0L) != 1.0L)
166 if (tanl (0.0L) != 0.0L)
169 if (atanl (0.0) != 0.0L)
172 if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
175 if (powl (ld
, 0.0L) != 1.0L)
178 if (powl (1.0L, ld
) != 1.0L)
184 test (3.0, 3.0F
, 3.0L);