OSDN Git Service

* gcc.dg/altivec-21.c: Use dg-error only for ilp32.
[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 extern double atan (double);
12 extern float atanf (float);
13 extern long double atanl (long double);
14 extern double exp (double);
15 extern float expf (float);
16 extern long double expl (long double);
17 extern double fabs (double);
18 extern float fabsf (float);
19 extern long double fabsl (long double);
20 extern double log (double);
21 extern float logf (float);
22 extern long double logl (long double);
23 extern double pow (double, double);
24 extern float powf (float, float);
25 extern long double powl (long double, long double);
26 extern double sqrt (double);
27 extern float sqrtf (float);
28 extern long double sqrtl (long double);
29 extern double tan (double);
30 extern float tanf (float);
31 extern long double tanl (long double);
32
33 double test1(double x)
34 {
35   return log(exp(x));
36 }
37
38 double test2(double x)
39 {
40   return exp(log(x));
41 }
42
43 double test3(double x)
44 {
45   return sqrt(exp(x));
46 }
47
48 double test4(double x)
49 {
50   return log(sqrt(x));
51 }
52
53 double test5(double x, double y)
54 {
55   return sqrt(x)*sqrt(y);
56 }
57
58 double test6(double x, double y)
59 {
60   return exp(x)*exp(y);
61 }
62
63 double test7(double x, double y)
64 {
65   return x/exp(y);
66 }
67
68 double test8(double x)
69 {
70   return fabs(sqrt(x));
71 }
72
73 double test9(double x)
74 {
75   return fabs(exp(x));
76 }
77
78 double test10(double x)
79 {
80   return tan(atan(x));
81 }
82
83 double test11(double x)
84 {
85   return fabs(fabs(x));
86 }
87
88 double test12(double x)
89 {
90   return fabs(atan(x));
91 }
92
93 double test13(double x)
94 {
95   return fabs(pow(2.0,x));
96 }
97
98 float test1f(float x)
99 {
100   return logf(expf(x));
101 }
102
103 float test2f(float x)
104 {
105   return expf(logf(x));
106 }
107
108 float test3f(float x)
109 {
110   return sqrtf(expf(x));
111 }
112
113 float test4f(float x)
114 {
115   return logf(sqrtf(x));
116 }
117
118 float test5f(float x, float y)
119 {
120   return sqrtf(x)*sqrtf(y);
121 }
122
123 float test6f(float x, float y)
124 {
125   return expf(x)*expf(y);
126 }
127
128 float test7f(float x, float y)
129 {
130   return x/expf(y);
131 }
132
133 float test8f(float x)
134 {
135   return fabsf(sqrtf(x));
136 }
137
138 float test9f(float x)
139 {
140   return fabsf(expf(x));
141 }
142
143 float test10f(float x)
144 {
145   return tanf(atanf(x));
146 }
147
148 float test11f(float x)
149 {
150   return fabsf(fabsf(x));
151 }
152
153 float test12f(float x)
154 {
155   return fabsf(atanf(x));
156 }
157
158 float test13f(float x)
159 {
160   return fabsf(powf(2.0f,x));
161 }
162
163 long double test1l(long double x)
164 {
165   return logl(expl(x));
166 }
167
168 long double test2l(long double x)
169 {
170   return expl(logl(x));
171 }
172
173 long double test3l(long double x)
174 {
175   return sqrtl(expl(x));
176 }
177
178 long double test4l(long double x)
179 {
180   return logl(sqrtl(x));
181 }
182
183 long double test5l(long double x, long double y)
184 {
185   return sqrtl(x)*sqrtl(y);
186 }
187
188 long double test6l(long double x, long double y)
189 {
190   return expl(x)*expl(y);
191 }
192
193 long double test7l(long double x, long double y)
194 {
195   return x/expl(y);
196 }
197
198 long double test8l(long double x)
199 {
200   return fabsl(sqrtl(x));
201 }
202
203 long double test9l(long double x)
204 {
205   return fabsl(expl(x));
206 }
207
208 long double test10l(long double x)
209 {
210   return tanl(atanl(x));
211 }
212
213 long double test11l(long double x)
214 {
215   return fabsl(fabsl(x));
216 }
217
218 long double test12l(long double x)
219 {
220   return fabsl(atanl(x));
221 }
222
223 long double test13l(long double x)
224 {
225   return fabsl(powl(2.0l,x));
226 }
227