OSDN Git Service

* fold-const.c (fold <ABS_EXPR>): Re-fold the result of folding
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / builtins-2.c
1 /* Copyright (C) 2002  Free Software Foundation.
2
3    Verify that built-in math function constant folding doesn't
4    cause any problems for the compiler.
5
6    Written by Roger Sayle, 16th August 2002.  */
7
8 /* { dg-do compile } */
9 /* { dg-options "-O2 -ffast-math" } */
10
11 double test1(double x)
12 {
13   return log(exp(x));
14 }
15
16 double test2(double x)
17 {
18   return exp(log(x));
19 }
20
21 double test3(double x)
22 {
23   return sqrt(exp(x));
24 }
25
26 double test4(double x)
27 {
28   return log(sqrt(x));
29 }
30
31 double test5(double x, double y)
32 {
33   return sqrt(x)*sqrt(y);
34 }
35
36 double test6(double x, double y)
37 {
38   return exp(x)*exp(y);
39 }
40
41 double test7(double x, double y)
42 {
43   return x/exp(y);
44 }
45
46 double test8(double x)
47 {
48   return fabs(sqrt(x));
49 }
50
51 double test9(double x)
52 {
53   return fabs(exp(x));
54 }
55
56 double test10(double x)
57 {
58   return tan(atan(x));
59 }
60
61 double test11(double x)
62 {
63   return fabs(fabs(x));
64 }
65
66 double test12(double x)
67 {
68   return fabs(atan(x));
69 }
70
71 double test13(double x)
72 {
73   return fabs(pow(2.0,x));
74 }
75
76 float test1f(float x)
77 {
78   return logf(expf(x));
79 }
80
81 float test2f(float x)
82 {
83   return expf(logf(x));
84 }
85
86 float test3f(float x)
87 {
88   return sqrtf(expf(x));
89 }
90
91 float test4f(float x)
92 {
93   return logf(sqrtf(x));
94 }
95
96 float test5f(float x, float y)
97 {
98   return sqrtf(x)*sqrtf(y);
99 }
100
101 float test6f(float x, float y)
102 {
103   return expf(x)*expf(y);
104 }
105
106 float test7f(float x, float y)
107 {
108   return x/expf(y);
109 }
110
111 float test8f(float x)
112 {
113   return fabsf(sqrtf(x));
114 }
115
116 float test9f(float x)
117 {
118   return fabsf(expf(x));
119 }
120
121 float test10f(float x)
122 {
123   return tanf(atanf(x));
124 }
125
126 floatf test11f(float x)
127 {
128   return fabsf(fabsf(x));
129 }
130
131 floatf test12f(float x)
132 {
133   return fabsf(atanf(x));
134 }
135
136 float test13f(float x)
137 {
138   return fabsf(powf(2.0f,x));
139 }
140
141 long double test1l(long double x)
142 {
143   return logl(expl(x));
144 }
145
146 long double test2l(long double x)
147 {
148   return expl(logl(x));
149 }
150
151 long double test3l(long double x)
152 {
153   return sqrtl(expl(x));
154 }
155
156 long double test4l(long double x)
157 {
158   return logl(sqrtl(x));
159 }
160
161 long double test5l(long double x, long double y)
162 {
163   return sqrtl(x)*sqrtl(y);
164 }
165
166 long double test6l(long double x, long double y)
167 {
168   return expl(x)*expl(y);
169 }
170
171 long double test7l(long double x, long double y)
172 {
173   return x/expl(y);
174 }
175
176 long double test8l(long double x)
177 {
178   return fabsl(sqrtl(x));
179 }
180
181 long double test9l(long double x)
182 {
183   return fabsl(expl(x));
184 }
185
186 long double test10l(long double x)
187 {
188   return tanl(atanl(x));
189 }
190
191 long double test11l(long double x)
192 {
193   return fabsl(fabsl(x));
194 }
195
196 long double test12l(long double x)
197 {
198   return fabsl(atanl(x));
199 }
200
201 long double test13l(long double x)
202 {
203   return fabsl(powl(2.0l,x));
204 }
205