1 /* Copyright (C) 2003 Free Software Foundation.
3 Check that constant folding of built-in math functions doesn't
4 break anything and produces the expected results.
6 Written by Roger Sayle, 28th June 2003. */
9 /* { dg-options "-O2" } */
11 extern void link_error(void);
13 extern double trunc(double);
14 extern double floor(double);
15 extern double ceil(double);
17 extern float truncf(float);
18 extern float floorf(float);
19 extern float ceilf(float);
21 extern long double truncl(long double);
22 extern long double floorl(long double);
23 extern long double ceill(long double);
27 if (trunc (0.0) != 0.0)
29 if (floor (0.0) != 0.0)
31 if (ceil (0.0) != 0.0)
34 if (trunc (6.0) != 6.0)
36 if (floor (6.0) != 6.0)
38 if (ceil (6.0) != 6.0)
41 if (trunc (-8.0) != -8.0)
43 if (floor (-8.0) != -8.0)
45 if (ceil (-8.0) != -8.0)
48 if (trunc (3.2) != 3.0)
50 if (floor (3.2) != 3.0)
52 if (ceil (3.2) != 4.0)
55 if (trunc (-2.8) != -2.0)
57 if (floor (-2.8) != -3.0)
59 if (ceil (-2.8) != -2.0)
62 if (trunc (0.01) != 0.0)
64 if (floor (0.01) != 0.0)
66 if (ceil (0.01) != 1.0)
69 if (trunc (-0.7) != 0.0)
71 if (floor (-0.7) != -1.0)
73 if (ceil (-0.7) != 0.0)
79 if (truncf (0.0f
) != 0.0f
)
81 if (floorf (0.0f
) != 0.0f
)
83 if (ceilf (0.0f
) != 0.0f
)
86 if (truncf (6.0f
) != 6.0f
)
88 if (floorf (6.0f
) != 6.0f
)
90 if (ceilf (6.0f
) != 6.0f
)
93 if (truncf (-8.0f
) != -8.0f
)
95 if (floorf (-8.0f
) != -8.0f
)
97 if (ceilf (-8.0f
) != -8.0f
)
100 if (truncf (3.2f
) != 3.0f
)
102 if (floorf (3.2f
) != 3.0f
)
104 if (ceilf (3.2f
) != 4.0f
)
107 if (truncf (-2.8f
) != -2.0f
)
109 if (floorf (-2.8f
) != -3.0f
)
111 if (ceilf (-2.8f
) != -2.0f
)
114 if (truncf (0.01f
) != 0.0f
)
116 if (floorf (0.01f
) != 0.0f
)
118 if (ceilf (0.01f
) != 1.0f
)
121 if (truncf (-0.7f
) != 0.0f
)
123 if (floorf (-0.7f
) != -1.0f
)
125 if (ceilf (-0.7f
) != 0.0f
)
131 if (truncl (0.0l) != 0.0l)
133 if (floorl (0.0l) != 0.0l)
135 if (ceill (0.0l) != 0.0l)
138 if (truncl (6.0l) != 6.0l)
140 if (floorl (6.0l) != 6.0l)
142 if (ceill (6.0l) != 6.0l)
145 if (truncl (-8.0l) != -8.0l)
147 if (floorl (-8.0l) != -8.0l)
149 if (ceill (-8.0l) != -8.0l)
152 if (truncl (3.2l) != 3.0l)
154 if (floorl (3.2l) != 3.0l)
156 if (ceill (3.2l) != 4.0l)
159 if (truncl (-2.8l) != -2.0l)
161 if (floorl (-2.8l) != -3.0l)
163 if (ceill (-2.8l) != -2.0l)
166 if (truncl (0.01l) != 0.0l)
168 if (floorl (0.01l) != 0.0l)
170 if (ceill (0.01l) != 1.0l)
173 if (truncl (-0.7l) != 0.0l)
175 if (floorl (-0.7l) != -1.0l)
177 if (ceill (-0.7l) != 0.0l)