2 /* { dg-require-effective-target c99_runtime } */
3 /* { dg-skip-if "exp2* missing despite C99 runtime" { alpha*-dec-osf5* } } */
4 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -lm" } */
5 /* { dg-additional-options "-DLARGE_LONG_DOUBLE" { target large_long_double } } */
6 /* { dg-additional-options "-DGNU_EXTENSION" { target pow10 } } */
7 /* { dg-add-options ieee } */
8 /* { dg-final { scan-tree-dump "cdce3.C:93: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
9 /* { dg-final { scan-tree-dump "cdce3.C:94: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
10 /* { dg-final { scan-tree-dump "cdce3.C:96: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
11 /* { dg-final { scan-tree-dump "cdce3.C:97: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
12 /* { dg-final { scan-tree-dump "cdce3.C:98: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
13 /* { dg-final { scan-tree-dump "cdce3.C:99: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
14 /* { dg-final { scan-tree-dump "cdce3.C:100: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
15 /* { dg-final { scan-tree-dump "cdce3.C:101: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
16 /* { dg-final { scan-tree-dump "cdce3.C:102: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
17 /* { dg-final { scan-tree-dump "cdce3.C:103: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
18 /* { dg-final { scan-tree-dump "cdce3.C:104: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
19 /* { dg-final { scan-tree-dump "cdce3.C:105: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
20 /* { dg-final { scan-tree-dump "cdce3.C:106: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
21 /* { dg-final { scan-tree-dump "cdce3.C:107: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
22 /* { dg-final { scan-tree-dump "cdce3.C:108: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
23 /* { dg-final { scan-tree-dump "cdce3.C:109: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
24 /* { dg-final { cleanup-tree-dump "cdce" } } */
32 typedef void (*FP) (int xp);
33 #define NI __attribute__((noinline))
35 #if defined(LARGE_LONG_DOUBLE)
36 typedef long double ldouble;
39 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
41 float yy = name##f ((float) x); \
44 NI void prefix##name (int x) \
46 double yy = name ((double)x); \
49 NI void prefix##name##l (int x) \
51 ldouble yy = name##l ((ldouble)x); \
57 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
59 float yy = name##f ((float) x); \
62 NI void prefix##name (int x) \
64 double yy = name ((double)x); \
70 #define STORE_RESULT result = yy
71 #if defined(GNU_EXTENSION)
72 DEF_MATH_FUNC (m,pow10)
73 DEF_MATH_FUNC (m,exp10)
75 DEF_MATH_FUNC (m,exp2)
77 DEF_MATH_FUNC (m,expm1)
78 DEF_MATH_FUNC (m,cosh)
79 DEF_MATH_FUNC (m,sinh)
80 DEF_MATH_FUNC (m,acos)
81 DEF_MATH_FUNC (m,asin)
82 DEF_MATH_FUNC (m,acosh)
83 DEF_MATH_FUNC (m,atanh)
85 DEF_MATH_FUNC (m,log2)
86 DEF_MATH_FUNC (m,log10)
87 DEF_MATH_FUNC (m,log1p)
88 DEF_MATH_FUNC (m,sqrt)
92 #if defined(GNU_EXTENSION)
93 DEF_MATH_FUNC (o,pow10)
94 DEF_MATH_FUNC (o,exp10)
96 DEF_MATH_FUNC (o,exp2)
98 DEF_MATH_FUNC (o,expm1)
99 DEF_MATH_FUNC (o,cosh)
100 DEF_MATH_FUNC (o,sinh)
101 DEF_MATH_FUNC (o,acos)
102 DEF_MATH_FUNC (o,asin)
103 DEF_MATH_FUNC (o,acosh)
104 DEF_MATH_FUNC (o,atanh)
105 DEF_MATH_FUNC (o,log)
106 DEF_MATH_FUNC (o,log2)
107 DEF_MATH_FUNC (o,log10)
108 DEF_MATH_FUNC (o,log1p)
109 DEF_MATH_FUNC (o,sqrt)
111 #if defined(LARGE_LONG_DOUBLE)
112 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
113 { prefix##name, #name, 0, 0, lb, ub }, \
114 { prefix##name##l, #name "l" , 0, 0, lb, ub },
116 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
117 { prefix##name, #name, 0, 0, lb, ub },
128 } math_func_arr[] = {
129 #if defined(GNU_EXTENSION)
130 INIT_MATH_FUNC (m,pow10, false, true)
131 INIT_MATH_FUNC (m,exp10, false, true)
133 INIT_MATH_FUNC (m,exp2, false, true)
134 INIT_MATH_FUNC (m,expm1, false, true)
135 INIT_MATH_FUNC (m,exp, false, true)
136 INIT_MATH_FUNC (m,cosh, true, true)
137 INIT_MATH_FUNC (m,sinh, true, true)
138 INIT_MATH_FUNC (m,acos, true, true)
139 INIT_MATH_FUNC (m,asin, true, true)
140 INIT_MATH_FUNC (m,acosh, true, false)
141 INIT_MATH_FUNC (m,atanh, true, true)
142 INIT_MATH_FUNC (m,log10, true, false)
143 INIT_MATH_FUNC (m,log, true, false)
144 INIT_MATH_FUNC (m,log2, true, false)
145 INIT_MATH_FUNC (m,log1p, true, false)
146 INIT_MATH_FUNC (m,sqrt, true, false)
147 { 0, 0, 0, 0, 0, 0} };
149 MathFuncInfo opt_math_func_arr[] =
151 #if defined(GNU_EXTENSION)
152 INIT_MATH_FUNC (o,pow10, false, true)
153 INIT_MATH_FUNC (o,exp10, false, true)
155 INIT_MATH_FUNC (o,exp2, false, true)
156 INIT_MATH_FUNC (o,expm1, false, true)
157 INIT_MATH_FUNC (o,exp, false, true)
158 INIT_MATH_FUNC (o,cosh, true, true)
159 INIT_MATH_FUNC (o,sinh, true, true)
160 INIT_MATH_FUNC (o,acos, true, true)
161 INIT_MATH_FUNC (o,asin, true, true)
162 INIT_MATH_FUNC (o,acosh, true, false)
163 INIT_MATH_FUNC (o,atanh, true, true)
164 INIT_MATH_FUNC (o,log10, true, false)
165 INIT_MATH_FUNC (o,log, true, false)
166 INIT_MATH_FUNC (o,log2, true, false)
167 INIT_MATH_FUNC (o,log1p, true, false)
168 INIT_MATH_FUNC (o,sqrt, true, false)
169 { 0, 0, 0, 0, 0, 0} };
171 int test (MathFuncInfo* math_func_infos)
176 for (i = 0; math_func_infos[i].math_func; i++)
178 MathFuncInfo& info = math_func_infos[i];
182 for (j = 0; j > -500000; j--)
197 for (j = 0; j < 500000; j++)
217 te1 = test (&math_func_arr[0]);
218 te2 = test (&opt_math_func_arr[0]);
220 // Now examine the result
223 for (i = 0; math_func_arr[i].math_func; i++)
225 MathFuncInfo& info = math_func_arr[i];
226 MathFuncInfo& opt_info = opt_math_func_arr[i];
228 fprintf (stderr," %s: lb = %d, ub = %d: lb_opt = %d, ub_opt = %d\n",
229 info.name, info.lb, info.ub, opt_info.lb, opt_info.ub);
231 if (info.lb != opt_info.lb) errcnt ++;
232 if (info.ub != opt_info.ub) errcnt ++;