| 1 |
/* Copyright (C) 2009 Free Software Foundation. |
| 2 |
|
| 3 |
Test things that should block GCC from optimizing compile-time |
| 4 |
constants passed to a builtin complex transcendental functions. |
| 5 |
|
| 6 |
Origin: Kaveh R. Ghazi, January 28, 2009. */ |
| 7 |
|
| 8 |
/* { dg-do compile } */ |
| 9 |
/* { dg-require-effective-target inf } */ |
| 10 |
/* { dg-options "-fdump-tree-original" } */ |
| 11 |
|
| 12 |
extern void foof (_Complex float); |
| 13 |
extern void foo (_Complex double); |
| 14 |
extern void fool (_Complex long double); |
| 15 |
|
| 16 |
#define TESTIT(FUNC, ARG) do { \ |
| 17 |
foof (__builtin_##FUNC##f (ARG##F)); \ |
| 18 |
foo (__builtin_##FUNC (ARG)); \ |
| 19 |
fool (__builtin_##FUNC##l (ARG##L)); \ |
| 20 |
} while (0) |
| 21 |
|
| 22 |
#define TESTIT2(FUNC, ARG0, ARG1) do { \ |
| 23 |
foof (__builtin_##FUNC##f (ARG0##F, ARG1##F)); \ |
| 24 |
foo (__builtin_##FUNC (ARG0, ARG1)); \ |
| 25 |
fool (__builtin_##FUNC##l (ARG0##L, ARG1##L)); \ |
| 26 |
} while (0) |
| 27 |
|
| 28 |
void bar() |
| 29 |
{ |
| 30 |
/* An argument of NaN is not evaluated at compile-time. */ |
| 31 |
foof (__builtin_csqrtf (__builtin_nanf(""))); |
| 32 |
foo (__builtin_csqrt (__builtin_nan(""))); |
| 33 |
fool (__builtin_csqrtl (__builtin_nanl(""))); |
| 34 |
|
| 35 |
/* An argument of Inf/-Inf is not evaluated at compile-time. */ |
| 36 |
foof (__builtin_csqrtf (__builtin_inff())); |
| 37 |
foo (__builtin_csqrt (__builtin_inf())); |
| 38 |
fool (__builtin_csqrtl (__builtin_infl())); |
| 39 |
foof (__builtin_csqrtf (-__builtin_inff())); |
| 40 |
foo (__builtin_csqrt (-__builtin_inf())); |
| 41 |
fool (__builtin_csqrtl (-__builtin_infl())); |
| 42 |
|
| 43 |
/* Check for overflow/underflow. */ |
| 44 |
TESTIT (cexp, 1e20); |
| 45 |
TESTIT (cexp, -1e20); |
| 46 |
|
| 47 |
/* An argument of NaN is not evaluated at compile-time. */ |
| 48 |
foof (__builtin_cpowf (__builtin_nanf(""), 2.5F)); |
| 49 |
foo (__builtin_cpow (__builtin_nan(""), 2.5)); |
| 50 |
fool (__builtin_cpowl (__builtin_nanl(""), 2.5L)); |
| 51 |
foof (__builtin_cpowf (2.5F, __builtin_nanf(""))); |
| 52 |
foo (__builtin_cpow (2.5, __builtin_nan(""))); |
| 53 |
fool (__builtin_cpowl (2.5L, __builtin_nanl(""))); |
| 54 |
|
| 55 |
/* An argument of Inf/-Inf is not evaluated at compile-time. */ |
| 56 |
foof (__builtin_cpowf (__builtin_inff(), 2.5F)); |
| 57 |
foo (__builtin_cpow (__builtin_inf(), 2.5)); |
| 58 |
fool (__builtin_cpowl (__builtin_infl(), 2.5L)); |
| 59 |
foof (__builtin_cpowf (-__builtin_inff(), 2.5F)); |
| 60 |
foo (__builtin_cpow (-__builtin_inf(), 2.5)); |
| 61 |
fool (__builtin_cpowl (-__builtin_infl(), 2.5L)); |
| 62 |
foof (__builtin_cpowf (2.5F, __builtin_inff())); |
| 63 |
foo (__builtin_cpow (2.5, __builtin_inf())); |
| 64 |
fool (__builtin_cpowl (2.5L, __builtin_infl())); |
| 65 |
foof (__builtin_cpowf (2.5F, -__builtin_inff())); |
| 66 |
foo (__builtin_cpow (2.5, -__builtin_inf())); |
| 67 |
fool (__builtin_cpowl (2.5L, -__builtin_infl())); |
| 68 |
|
| 69 |
/* Check for Inv/NaN return values. */ |
| 70 |
TESTIT2 (cpow, -0.0, -4.5); /* Returns Inf */ |
| 71 |
TESTIT2 (cpow, 0.0, -4.5); /* Returns Inf */ |
| 72 |
|
| 73 |
/* Check for overflow/underflow. */ |
| 74 |
foof (__builtin_cpowf (__FLT_MAX__, 3.5F)); |
| 75 |
foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, 3.5F)); |
| 76 |
foo (__builtin_cpow (__DBL_MAX__, 3.5)); |
| 77 |
foo (__builtin_cpow (__DBL_MAX__ * 1.I, 3.5)); |
| 78 |
fool (__builtin_cpowl (__LDBL_MAX__, 3.5L)); |
| 79 |
fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, 3.5L)); |
| 80 |
TESTIT2 (cpow, 2.0, 0x1p50); |
| 81 |
TESTIT2 (cpow, 2.0, 0x1p28); |
| 82 |
TESTIT2 (cpow, 2.0, 0x1p24); |
| 83 |
foof (__builtin_cpowf (__FLT_MAX__, -3.5F)); |
| 84 |
foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, -3.5F)); |
| 85 |
foo (__builtin_cpow (__DBL_MAX__, -3.5)); |
| 86 |
foo (__builtin_cpow (__DBL_MAX__ * 1.I, -3.5)); |
| 87 |
fool (__builtin_cpowl (__LDBL_MAX__, -3.5L)); |
| 88 |
fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, -3.5L)); |
| 89 |
TESTIT2 (cpow, 2.0, -0x1p50); |
| 90 |
TESTIT2 (cpow, 2.0, -0x1p28); |
| 91 |
TESTIT2 (cpow, 2.0, -0x1p24); |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
/* { dg-final { scan-tree-dump-times "csqrtf" 3 "original" } } */ |
| 96 |
/* { dg-final { scan-tree-dump-times "csqrt " 3 "original" } } */ |
| 97 |
/* { dg-final { scan-tree-dump-times "csqrtl" 3 "original" } } */ |
| 98 |
/* { dg-final { scan-tree-dump-times "cexpf" 2 "original" } } */ |
| 99 |
/* { dg-final { scan-tree-dump-times "cexp " 2 "original" } } */ |
| 100 |
/* { dg-final { scan-tree-dump-times "cexpl" 2 "original" } } */ |
| 101 |
/* { dg-final { scan-tree-dump-times "cpowf" 18 "original" } } */ |
| 102 |
/* { dg-final { scan-tree-dump-times "cpow " 18 "original" } } */ |
| 103 |
/* { dg-final { scan-tree-dump-times "cpowl" 18 "original" } } */ |