* cfgloopmanip.c (duplicate_loop_to_header_edge): Cleanup profile
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-26.c
blobc4d03cd7da6618b4413f5608f8bbe51c69559c24
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. */
8 /* { dg-do link } */
9 /* { dg-options "-O2 -ffast-math" } */
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);
25 void test(double x)
27 if (trunc (trunc (x)) != trunc (x))
28 link_error ();
29 if (trunc (floor (x)) != floor (x))
30 link_error ();
31 if (trunc (ceil (x)) != ceil (x))
32 link_error ();
34 if (floor (trunc (x)) != trunc (x))
35 link_error ();
36 if (floor (floor (x)) != floor (x))
37 link_error ();
38 if (floor (ceil (x)) != ceil (x))
39 link_error ();
41 if (ceil (trunc (x)) != trunc (x))
42 link_error ();
43 if (ceil (floor (x)) != floor (x))
44 link_error ();
45 if (ceil (ceil (x)) != ceil (x))
46 link_error ();
49 void testf(float x)
51 if (truncf (truncf (x)) != truncf (x))
52 link_error ();
53 if (truncf (floorf (x)) != floorf (x))
54 link_error ();
55 if (truncf (ceilf (x)) != ceilf (x))
56 link_error ();
58 if (floorf (truncf (x)) != truncf (x))
59 link_error ();
60 if (floorf (floorf (x)) != floorf (x))
61 link_error ();
62 if (floorf (ceilf (x)) != ceilf (x))
63 link_error ();
65 if (ceilf (truncf (x)) != truncf (x))
66 link_error ();
67 if (ceilf (floorf (x)) != floorf (x))
68 link_error ();
69 if (ceilf (ceilf (x)) != ceilf (x))
70 link_error ();
73 void testl(long double x)
75 if (truncl (truncl (x)) != truncl (x))
76 link_error ();
77 if (truncl (floorl (x)) != floorl (x))
78 link_error ();
79 if (truncl (ceill (x)) != ceill (x))
80 link_error ();
82 if (floorl (truncl (x)) != truncl (x))
83 link_error ();
84 if (floorl (floorl (x)) != floorl (x))
85 link_error ();
86 if (floorl (ceill (x)) != ceill (x))
87 link_error ();
89 if (ceill (truncl (x)) != truncl (x))
90 link_error ();
91 if (ceill (floorl (x)) != floorl (x))
92 link_error ();
93 if (ceill (ceill (x)) != ceill (x))
94 link_error ();
98 int main()
100 test (3.2);
101 testf (3.2f);
102 testl (3.2l);
103 return 0;