2 /* { dg-require-effective-target c99_runtime } */
3 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -lm" } */
4 /* { dg-additional-options "-DLARGE_LONG_DOUBLE" { target large_long_double } } */
5 /* { dg-additional-options "-DGNU_EXTENSION" { target pow10 } } */
6 /* { dg-add-options ieee } */
7 /* { dg-final { scan-tree-dump "cdce3.C:91: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
8 /* { dg-final { scan-tree-dump "cdce3.C:92: 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" } } */
10 /* { dg-final { scan-tree-dump "cdce3.C:95: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
11 /* { dg-final { scan-tree-dump "cdce3.C:96: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
12 /* { dg-final { scan-tree-dump "cdce3.C:97: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
13 /* { dg-final { scan-tree-dump "cdce3.C:98: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
14 /* { dg-final { scan-tree-dump "cdce3.C:99: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
15 /* { dg-final { scan-tree-dump "cdce3.C:100: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
16 /* { dg-final { scan-tree-dump "cdce3.C:101: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
17 /* { dg-final { scan-tree-dump "cdce3.C:102: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
18 /* { dg-final { scan-tree-dump "cdce3.C:103: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
19 /* { dg-final { scan-tree-dump "cdce3.C:104: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
20 /* { dg-final { scan-tree-dump "cdce3.C:105: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
21 /* { dg-final { scan-tree-dump "cdce3.C:106: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
22 /* { dg-final { scan-tree-dump "cdce3.C:107: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
30 typedef void (*FP) (int xp);
31 #define NI __attribute__((noinline))
33 #if defined(LARGE_LONG_DOUBLE)
34 typedef long double ldouble;
37 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
39 float yy = name##f ((float) x); \
42 NI void prefix##name (int x) \
44 double yy = name ((double)x); \
47 NI void prefix##name##l (int x) \
49 ldouble yy = name##l ((ldouble)x); \
55 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
57 float yy = name##f ((float) x); \
60 NI void prefix##name (int x) \
62 double yy = name ((double)x); \
68 #define STORE_RESULT result = yy
69 #if defined(GNU_EXTENSION)
70 DEF_MATH_FUNC (m,pow10)
71 DEF_MATH_FUNC (m,exp10)
73 DEF_MATH_FUNC (m,exp2)
75 DEF_MATH_FUNC (m,expm1)
76 DEF_MATH_FUNC (m,cosh)
77 DEF_MATH_FUNC (m,sinh)
78 DEF_MATH_FUNC (m,acos)
79 DEF_MATH_FUNC (m,asin)
80 DEF_MATH_FUNC (m,acosh)
81 DEF_MATH_FUNC (m,atanh)
83 DEF_MATH_FUNC (m,log2)
84 DEF_MATH_FUNC (m,log10)
85 DEF_MATH_FUNC (m,log1p)
86 DEF_MATH_FUNC (m,sqrt)
90 #if defined(GNU_EXTENSION)
91 DEF_MATH_FUNC (o,pow10)
92 DEF_MATH_FUNC (o,exp10)
94 DEF_MATH_FUNC (o,exp2)
96 DEF_MATH_FUNC (o,expm1)
97 DEF_MATH_FUNC (o,cosh)
98 DEF_MATH_FUNC (o,sinh)
99 DEF_MATH_FUNC (o,acos)
100 DEF_MATH_FUNC (o,asin)
101 DEF_MATH_FUNC (o,acosh)
102 DEF_MATH_FUNC (o,atanh)
103 DEF_MATH_FUNC (o,log)
104 DEF_MATH_FUNC (o,log2)
105 DEF_MATH_FUNC (o,log10)
106 DEF_MATH_FUNC (o,log1p)
107 DEF_MATH_FUNC (o,sqrt)
109 #if defined(LARGE_LONG_DOUBLE)
110 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
111 { prefix##name, #name, 0, 0, lb, ub }, \
112 { prefix##name##l, #name "l" , 0, 0, lb, ub },
114 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
115 { prefix##name, #name, 0, 0, lb, ub },
126 } math_func_arr[] = {
127 #if defined(GNU_EXTENSION)
128 INIT_MATH_FUNC (m,pow10, false, true)
129 INIT_MATH_FUNC (m,exp10, false, true)
131 INIT_MATH_FUNC (m,exp2, false, true)
132 INIT_MATH_FUNC (m,expm1, false, true)
133 INIT_MATH_FUNC (m,exp, false, true)
134 INIT_MATH_FUNC (m,cosh, true, true)
135 INIT_MATH_FUNC (m,sinh, true, true)
136 INIT_MATH_FUNC (m,acos, true, true)
137 INIT_MATH_FUNC (m,asin, true, true)
138 INIT_MATH_FUNC (m,acosh, true, false)
139 INIT_MATH_FUNC (m,atanh, true, true)
140 INIT_MATH_FUNC (m,log10, true, false)
141 INIT_MATH_FUNC (m,log, true, false)
142 INIT_MATH_FUNC (m,log2, true, false)
143 INIT_MATH_FUNC (m,log1p, true, false)
144 INIT_MATH_FUNC (m,sqrt, true, false)
145 { 0, 0, 0, 0, 0, 0} };
147 MathFuncInfo opt_math_func_arr[] =
149 #if defined(GNU_EXTENSION)
150 INIT_MATH_FUNC (o,pow10, false, true)
151 INIT_MATH_FUNC (o,exp10, false, true)
153 INIT_MATH_FUNC (o,exp2, false, true)
154 INIT_MATH_FUNC (o,expm1, false, true)
155 INIT_MATH_FUNC (o,exp, false, true)
156 INIT_MATH_FUNC (o,cosh, true, true)
157 INIT_MATH_FUNC (o,sinh, true, true)
158 INIT_MATH_FUNC (o,acos, true, true)
159 INIT_MATH_FUNC (o,asin, true, true)
160 INIT_MATH_FUNC (o,acosh, true, false)
161 INIT_MATH_FUNC (o,atanh, true, true)
162 INIT_MATH_FUNC (o,log10, true, false)
163 INIT_MATH_FUNC (o,log, true, false)
164 INIT_MATH_FUNC (o,log2, true, false)
165 INIT_MATH_FUNC (o,log1p, true, false)
166 INIT_MATH_FUNC (o,sqrt, true, false)
167 { 0, 0, 0, 0, 0, 0} };
169 int test (MathFuncInfo* math_func_infos)
174 for (i = 0; math_func_infos[i].math_func; i++)
176 MathFuncInfo& info = math_func_infos[i];
180 for (j = 0; j > -500000; j--)
195 for (j = 0; j < 500000; j++)
215 te1 = test (&math_func_arr[0]);
216 te2 = test (&opt_math_func_arr[0]);
218 // Now examine the result
221 for (i = 0; math_func_arr[i].math_func; i++)
223 MathFuncInfo& info = math_func_arr[i];
224 MathFuncInfo& opt_info = opt_math_func_arr[i];
226 fprintf (stderr," %s: lb = %d, ub = %d: lb_opt = %d, ub_opt = %d\n",
227 info.name, info.lb, info.ub, opt_info.lb, opt_info.ub);
229 if (info.lb != opt_info.lb) errcnt ++;
230 if (info.ub != opt_info.ub) errcnt ++;