1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
/* Copyright (C) 2006, 2007 Free Software Foundation.
Test things that should block GCC from optimizing compile-time
constants passed to a builtin transcendental function.
Origin: Kaveh R. Ghazi, October 22, 2006. */
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
extern void foof (float);
extern void foo (double);
extern void fool (long double);
#define TESTIT(FUNC, ARG) do { \
foof (__builtin_##FUNC##f (ARG##F)); \
foo (__builtin_##FUNC (ARG)); \
fool (__builtin_##FUNC##l (ARG##L)); \
} while (0)
#define TESTIT2(FUNC, ARG1, ARG2) do { \
foof (__builtin_##FUNC##f (ARG1##F, ARG2##F)); \
foo (__builtin_##FUNC (ARG1, ARG2)); \
fool (__builtin_##FUNC##l (ARG1##L, ARG2##L)); \
} while (0)
#define TESTIT2_I1(FUNC, ARG1, ARG2) do { \
foof (__builtin_##FUNC##f (ARG1, ARG2##F)); \
foo (__builtin_##FUNC (ARG1, ARG2)); \
fool (__builtin_##FUNC##l (ARG1, ARG2##L)); \
} while (0)
#define TESTIT2_I2ALL(FUNC, ARGF, MAXF, ARGD, MAXD, ARGLD, MAXLD) do { \
foof (__builtin_##FUNC##f (ARGF, MAXF)); \
foo (__builtin_##FUNC (ARGD, MAXD)); \
fool (__builtin_##FUNC##l (ARGLD, MAXLD)); \
} while (0)
#define TESTIT2_I2(FUNC, ARG1, ARG2) do { \
foof (__builtin_##FUNC##f (ARG1##F, ARG2)); \
foo (__builtin_##FUNC (ARG1, ARG2)); \
fool (__builtin_##FUNC##l (ARG1##L, ARG2)); \
} while (0)
#define TESTIT_REMQUO(ARG1, ARG2) do { \
int quo; \
foof (__builtin_remquof (ARG1##F, ARG2##F, &quo)); \
foo (__builtin_remquo (ARG1, ARG2, &quo)); \
fool (__builtin_remquol (ARG1##L, ARG2##L, &quo)); \
} while (0)
#define TESTIT_REENT(FUNC,ARG1) do { \
int sg; \
foof (__builtin_##FUNC##f_r (ARG1##F, &sg)); \
foo (__builtin_##FUNC##_r (ARG1, &sg)); \
fool (__builtin_##FUNC##l_r (ARG1##L, &sg)); \
} while (0)
void bar()
{
/* An argument of NaN is not evaluated at compile-time. */
#ifndef __SPU__
foof (__builtin_exp2f (__builtin_nanf("")));
#endif
foo (__builtin_exp2 (__builtin_nan("")));
fool (__builtin_exp2l (__builtin_nanl("")));
/* An argument of Inf/-Inf is not evaluated at compile-time. */
#ifndef __SPU__
foof (__builtin_exp2f (__builtin_inff()));
#endif
foo (__builtin_exp2 (__builtin_inf()));
fool (__builtin_exp2l (__builtin_infl()));
#ifndef __SPU__
foof (__builtin_exp2f (-__builtin_inff()));
#endif
foo (__builtin_exp2 (-__builtin_inf()));
fool (__builtin_exp2l (-__builtin_infl()));
/* Result overflows MPFR, which in version 2.2.x has 30 exponent bits. */
TESTIT (exp2, 0x1p50);
/* Result underflows MPFR, which in version 2.2.x has 30 exponent bits. */
TESTIT (exp2, -0x1p50);
/* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
TESTIT (exp2, 0x1p28);
/* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */
TESTIT (exp2, -0x1p28);
/* Result overflows (even an extended) C double's mode. */
TESTIT (exp2, 0x1p24);
/* Result underflows (even an extended) C double's mode. */
TESTIT (exp2, -0x1p24);
/* Ensure that normal arguments/results are folded. */
TESTIT (exp2, 1.5);
TESTIT (exp2, -1.5);
/* The asin arg must be [-1 ... 1] inclusive. */
TESTIT (asin, -1.5);
TESTIT (asin, 1.5);
/* The acos arg must be [-1 ... 1] inclusive. */
TESTIT (acos, -1.5);
TESTIT (acos, 1.5);
/* The acosh arg must be [1 ... Inf] inclusive. */
TESTIT (acosh, 0.5);
/* The atanh arg must be [-1 ... 1] EXclusive. */
TESTIT (atanh, -1.0);
TESTIT (atanh, 1.0);
/* The log* arg must be [0 ... Inf] EXclusive. */
TESTIT (log, -1.0);
TESTIT (log, 0.0);
TESTIT (log, -0.0);
TESTIT (log2, -1.0);
TESTIT (log2, 0.0);
TESTIT (log2, -0.0);
TESTIT (log10, -1.0);
TESTIT (log10, 0.0);
TESTIT (log10, -0.0);
/* The log1p arg must be [-1 ... Inf] EXclusive. */
TESTIT (log1p, -2.0);
TESTIT (log1p, -1.0);
/* The tgamma arg errors with zero or negative integers. */
TESTIT (tgamma, 0.0);
TESTIT (tgamma, -0.0);
TESTIT (tgamma, -1.0);
TESTIT (tgamma, -2.0);
TESTIT (tgamma, -3.0);
/* An argument of NaN is not evaluated at compile-time. */
#ifndef __SPU__
foof (__builtin_powf (__builtin_nanf(""), 2.5F));
#endif
foo (__builtin_pow (__builtin_nan(""), 2.5));
fool (__builtin_powl (__builtin_nanl(""), 2.5L));
#ifndef __SPU__
foof (__builtin_powf (2.5F, __builtin_nanf("")));
#endif
foo (__builtin_pow (2.5, __builtin_nan("")));
fool (__builtin_powl (2.5L, __builtin_nanl("")));
/* An argument of Inf/-Inf is not evaluated at compile-time. */
#ifndef __SPU__
foof (__builtin_powf (__builtin_inff(), 2.5F));
#endif
foo (__builtin_pow (__builtin_inf(), 2.5));
fool (__builtin_powl (__builtin_infl(), 2.5L));
#ifndef __SPU__
foof (__builtin_powf (-__builtin_inff(), 2.5F));
#endif
foo (__builtin_pow (-__builtin_inf(), 2.5));
fool (__builtin_powl (-__builtin_infl(), 2.5L));
#ifndef __SPU__
foof (__builtin_powf (2.5F, __builtin_inff()));
#endif
foo (__builtin_pow (2.5, __builtin_inf()));
fool (__builtin_powl (2.5L, __builtin_infl()));
#ifndef __SPU__
foof (__builtin_powf (2.5F, -__builtin_inff()));
#endif
foo (__builtin_pow (2.5, -__builtin_inf()));
fool (__builtin_powl (2.5L, -__builtin_infl()));
/* Check for Inv/NaN return values. */
TESTIT2 (pow, -0.0, -4.5); /* Returns Inf */
TESTIT2 (pow, 0.0, -4.5); /* Returns Inf */
TESTIT2 (pow, -3.0, -4.5); /* Returns NaN */
/* Check for overflow/underflow. */
foof (__builtin_powf (__FLT_MAX__, 3.5F));
foo (__builtin_pow (__DBL_MAX__, 3.5));
fool (__builtin_powl (__LDBL_MAX__, 3.5L));
TESTIT2 (pow, 2.0, 0x1p50);
foof (__builtin_powf (__FLT_MAX__, -3.5F));
foo (__builtin_pow (__DBL_MAX__, -3.5));
fool (__builtin_powl (__LDBL_MAX__, -3.5L));
TESTIT2 (pow, 2.0, -0x1p50);
/* The sqrt arg must be [0 ... Inf] inclusive. */
TESTIT (sqrt, -0.5);
TESTIT (sqrt, -0.0);
TESTIT (sqrt, 0.0);
/* Check for overflow/underflow. */
/* These adjustments are too big. */
#define FLT_EXP_ADJ (2*(__FLT_MAX_EXP__-__FLT_MIN_EXP__)+1)
#define DBL_EXP_ADJ (2*(__DBL_MAX_EXP__-__DBL_MIN_EXP__)+1)
#define LDBL_EXP_ADJ (2*(__LDBL_MAX_EXP__-__LDBL_MIN_EXP__)+1)
TESTIT2_I2 (ldexp, 1.0, __INT_MAX__);
TESTIT2_I2 (ldexp, 1.0, -__INT_MAX__-1);
TESTIT2_I2 (ldexp, -1.0, __INT_MAX__);
TESTIT2_I2 (ldexp, -1.0, -__INT_MAX__-1);
TESTIT2_I2ALL (ldexp, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
TESTIT2_I2ALL (ldexp, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
-DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
TESTIT2_I2ALL (ldexp, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
__DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
TESTIT2_I2ALL (ldexp, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
__DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
TESTIT2_I2 (scalbn, 1.0, __INT_MAX__);
TESTIT2_I2 (scalbn, 1.0, -__INT_MAX__-1);
TESTIT2_I2 (scalbn, -1.0, __INT_MAX__);
TESTIT2_I2 (scalbn, -1.0, -__INT_MAX__-1);
TESTIT2_I2ALL (scalbn, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
TESTIT2_I2ALL (scalbn, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
-DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
TESTIT2_I2ALL (scalbn, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
__DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
TESTIT2_I2ALL (scalbn, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
__DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
TESTIT2_I2 (scalbln, 1.0, __LONG_MAX__);
TESTIT2_I2 (scalbln, 1.0, -__LONG_MAX__-1);
TESTIT2_I2 (scalbln, -1.0, __LONG_MAX__);
TESTIT2_I2 (scalbln, -1.0, -__LONG_MAX__-1);
TESTIT2_I2ALL (scalbln, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
TESTIT2_I2ALL (scalbln, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
-DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
TESTIT2_I2ALL (scalbln, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
__DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
TESTIT2_I2ALL (scalbln, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
__DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);
TESTIT (logb, 0.0);
TESTIT (logb, -0.0);
TESTIT (ilogb, 0.0);
TESTIT (ilogb, -0.0);
#ifndef __SPU__
foof (__builtin_ilogbf (__builtin_inff()));
#endif
foo (__builtin_ilogb (__builtin_inf()));
fool (__builtin_ilogbl (__builtin_infl()));
#ifndef __SPU__
foof (__builtin_ilogbf (-__builtin_inff()));
#endif
foo (__builtin_ilogb (-__builtin_inf()));
fool (__builtin_ilogbl (-__builtin_infl()));
#ifndef __SPU__
foof (__builtin_ilogbf (__builtin_nanf("")));
#endif
foo (__builtin_ilogb (__builtin_nan("")));
fool (__builtin_ilogbl (__builtin_nanl("")));
#ifndef __SPU__
foof (__builtin_ilogbf (-__builtin_nanf("")));
#endif
foo (__builtin_ilogb (-__builtin_nan("")));
fool (__builtin_ilogbl (-__builtin_nanl("")));
/* The y* arg must be [0 ... Inf] EXclusive. */
TESTIT (y0, -1.0);
TESTIT (y0, 0.0);
TESTIT (y0, -0.0);
TESTIT (y1, -1.0);
TESTIT (y1, 0.0);
TESTIT (y1, -0.0);
TESTIT2_I1 (yn, 2, -1.0);
TESTIT2_I1 (yn, 2, 0.0);
TESTIT2_I1 (yn, 2, -0.0);
TESTIT2_I1 (yn, -3, -1.0);
TESTIT2_I1 (yn, -3, 0.0);
TESTIT2_I1 (yn, -3, -0.0);
/* The second argument of remquo/remainder/drem must not be 0. */
TESTIT_REMQUO (1.0, 0.0);
TESTIT_REMQUO (1.0, -0.0);
TESTIT2 (remainder, 1.0, 0.0);
TESTIT2 (remainder, 1.0, -0.0);
TESTIT2 (drem, 1.0, 0.0);
TESTIT2 (drem, 1.0, -0.0);
/* The argument to lgamma* cannot be zero or a negative integer. */
TESTIT_REENT (lgamma, -4.0); /* lgamma_r */
TESTIT_REENT (lgamma, -3.0); /* lgamma_r */
TESTIT_REENT (lgamma, -2.0); /* lgamma_r */
TESTIT_REENT (lgamma, -1.0); /* lgamma_r */
TESTIT_REENT (lgamma, -0.0); /* lgamma_r */
TESTIT_REENT (lgamma, 0.0); /* lgamma_r */
TESTIT_REENT (gamma, -4.0); /* gamma_r */
TESTIT_REENT (gamma, -3.0); /* gamma_r */
TESTIT_REENT (gamma, -2.0); /* gamma_r */
TESTIT_REENT (gamma, -1.0); /* gamma_r */
TESTIT_REENT (gamma, -0.0); /* gamma_r */
TESTIT_REENT (gamma, 0.0); /* gamma_r */
}
/* { dg-final { scan-tree-dump-times "exp2 " 9 "original" } } */
/* { dg-final { scan-tree-dump-times "exp2f" 9 "original" { target { ! { spu*-*-* } } } } } */
/* { dg-final { scan-tree-dump-times "exp2f" 6 "original" { target { spu*-*-* } } } } */
/* { dg-final { scan-tree-dump-times "exp2l" 9 "original" } } */
/* { dg-final { scan-tree-dump-times "asin " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "asinf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "asinl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "acos " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "acosf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "acosl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "acosh " 1 "original" } } */
/* { dg-final { scan-tree-dump-times "acoshf" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "acoshl" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "atanh " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "atanhf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "atanhl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "log " 3 "original" } } */
/* { dg-final { scan-tree-dump-times "logf" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "logl" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log2 " 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log2f" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log2l" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log10 " 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log10f" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log10l" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "log1p " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "log1pf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "log1pl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "tgamma " 5 "original" } } */
/* { dg-final { scan-tree-dump-times "tgammaf" 5 "original" } } */
/* { dg-final { scan-tree-dump-times "tgammal" 5 "original" } } */
/* { dg-final { scan-tree-dump-times "pow " 13 "original" } } */
/* { dg-final { scan-tree-dump-times "powf" 13 "original" { target { ! { spu*-*-* } } } } } */
/* { dg-final { scan-tree-dump-times "powf" 7 "original" { target { spu*-*-* } } } } */
/* { dg-final { scan-tree-dump-times "powl" 13 "original" } } */
/* { dg-final { scan-tree-dump-times "sqrt " 1 "original" } } */
/* { dg-final { scan-tree-dump-times "sqrtf" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "sqrtl" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "ldexp " 8 "original" } } */
/* { dg-final { scan-tree-dump-times "ldexpf" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "ldexpl" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalbn " 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalbnf" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalbnl" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalbln " 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalblnf" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "scalblnl" 8 "original" } } */
/* { dg-final { scan-tree-dump-times "_logb " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "_logbf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "_logbl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "ilogb " 6 "original" } } */
/* { dg-final { scan-tree-dump-times "ilogbf" 6 "original" { target { ! { spu*-*-* } } } } } */
/* { dg-final { scan-tree-dump-times "ilogbf" 2 "original" { target { spu*-*-* } } } } */
/* { dg-final { scan-tree-dump-times "ilogbl" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "y0 " 3 "original" } } */
/* { dg-final { scan-tree-dump-times "y0f" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "y0l" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "y1 " 3 "original" } } */
/* { dg-final { scan-tree-dump-times "y1f" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "y1l" 3 "original" } } */
/* { dg-final { scan-tree-dump-times "yn " 6 "original" } } */
/* { dg-final { scan-tree-dump-times "ynf" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "ynl" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "remquo " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "remquof" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "remquol" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "remainder " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "remainderf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "remainderl" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "drem " 2 "original" } } */
/* { dg-final { scan-tree-dump-times "dremf" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "dreml" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "lgamma_r " 6 "original" } } */
/* { dg-final { scan-tree-dump-times "lgammaf_r" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "lgammal_r" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "_gamma_r " 6 "original" } } */
/* { dg-final { scan-tree-dump-times "_gammaf_r" 6 "original" } } */
/* { dg-final { scan-tree-dump-times "_gammal_r" 6 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */
|