annotate gcc/testsuite/g++.dg/cdce3.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do run } */
kono
parents:
diff changeset
2 /* { dg-require-effective-target c99_runtime } */
kono
parents:
diff changeset
3 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -lm" } */
kono
parents:
diff changeset
4 /* { dg-additional-options "-DLARGE_LONG_DOUBLE" { target large_long_double } } */
kono
parents:
diff changeset
5 /* { dg-additional-options "-DGNU_EXTENSION" { target pow10 } } */
kono
parents:
diff changeset
6 /* { dg-add-options ieee } */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
7 /* { dg-final { scan-tree-dump "cdce3.C:91: .* function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
8 /* { dg-final { scan-tree-dump "cdce3.C:92: .* function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 /* { dg-final { scan-tree-dump "cdce3.C:94: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
10 /* { dg-final { scan-tree-dump "cdce3.C:95: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
11 /* { dg-final { scan-tree-dump "cdce3.C:96: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
12 /* { dg-final { scan-tree-dump "cdce3.C:97: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
13 /* { dg-final { scan-tree-dump "cdce3.C:98: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
14 /* { dg-final { scan-tree-dump "cdce3.C:99: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
15 /* { dg-final { scan-tree-dump "cdce3.C:100: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
16 /* { dg-final { scan-tree-dump "cdce3.C:101: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
17 /* { dg-final { scan-tree-dump "cdce3.C:102: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
18 /* { dg-final { scan-tree-dump "cdce3.C:103: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
19 /* { dg-final { scan-tree-dump "cdce3.C:104: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
20 /* { dg-final { scan-tree-dump "cdce3.C:105: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
21 /* { dg-final { scan-tree-dump "cdce3.C:106: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
22 /* { dg-final { scan-tree-dump "cdce3.C:107: .* function call is shrink-wrapped into error conditions\." "cdce" } } */
111
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 #include <stdlib.h>
kono
parents:
diff changeset
25 #include <math.h>
kono
parents:
diff changeset
26 #ifdef DEBUG
kono
parents:
diff changeset
27 #include <stdio.h>
kono
parents:
diff changeset
28 #endif
kono
parents:
diff changeset
29 #include <errno.h>
kono
parents:
diff changeset
30 typedef void (*FP) (int xp);
kono
parents:
diff changeset
31 #define NI __attribute__((noinline))
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 #if defined(LARGE_LONG_DOUBLE)
kono
parents:
diff changeset
34 typedef long double ldouble;
kono
parents:
diff changeset
35 ldouble result;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
kono
parents:
diff changeset
38 { \
kono
parents:
diff changeset
39 float yy = name##f ((float) x); \
kono
parents:
diff changeset
40 STORE_RESULT; \
kono
parents:
diff changeset
41 } \
kono
parents:
diff changeset
42 NI void prefix##name (int x) \
kono
parents:
diff changeset
43 { \
kono
parents:
diff changeset
44 double yy = name ((double)x); \
kono
parents:
diff changeset
45 STORE_RESULT; \
kono
parents:
diff changeset
46 } \
kono
parents:
diff changeset
47 NI void prefix##name##l (int x) \
kono
parents:
diff changeset
48 { \
kono
parents:
diff changeset
49 ldouble yy = name##l ((ldouble)x); \
kono
parents:
diff changeset
50 STORE_RESULT; \
kono
parents:
diff changeset
51 }
kono
parents:
diff changeset
52 #else
kono
parents:
diff changeset
53 double result;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 #define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
kono
parents:
diff changeset
56 { \
kono
parents:
diff changeset
57 float yy = name##f ((float) x); \
kono
parents:
diff changeset
58 STORE_RESULT; \
kono
parents:
diff changeset
59 } \
kono
parents:
diff changeset
60 NI void prefix##name (int x) \
kono
parents:
diff changeset
61 { \
kono
parents:
diff changeset
62 double yy = name ((double)x); \
kono
parents:
diff changeset
63 STORE_RESULT; \
kono
parents:
diff changeset
64 }
kono
parents:
diff changeset
65 #endif
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 #undef STORE_RESULT
kono
parents:
diff changeset
68 #define STORE_RESULT result = yy
kono
parents:
diff changeset
69 #if defined(GNU_EXTENSION)
kono
parents:
diff changeset
70 DEF_MATH_FUNC (m,pow10)
kono
parents:
diff changeset
71 DEF_MATH_FUNC (m,exp10)
kono
parents:
diff changeset
72 #endif
kono
parents:
diff changeset
73 DEF_MATH_FUNC (m,exp2)
kono
parents:
diff changeset
74 DEF_MATH_FUNC (m,exp)
kono
parents:
diff changeset
75 DEF_MATH_FUNC (m,expm1)
kono
parents:
diff changeset
76 DEF_MATH_FUNC (m,cosh)
kono
parents:
diff changeset
77 DEF_MATH_FUNC (m,sinh)
kono
parents:
diff changeset
78 DEF_MATH_FUNC (m,acos)
kono
parents:
diff changeset
79 DEF_MATH_FUNC (m,asin)
kono
parents:
diff changeset
80 DEF_MATH_FUNC (m,acosh)
kono
parents:
diff changeset
81 DEF_MATH_FUNC (m,atanh)
kono
parents:
diff changeset
82 DEF_MATH_FUNC (m,log)
kono
parents:
diff changeset
83 DEF_MATH_FUNC (m,log2)
kono
parents:
diff changeset
84 DEF_MATH_FUNC (m,log10)
kono
parents:
diff changeset
85 DEF_MATH_FUNC (m,log1p)
kono
parents:
diff changeset
86 DEF_MATH_FUNC (m,sqrt)
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 #undef STORE_RESULT
kono
parents:
diff changeset
89 #define STORE_RESULT
kono
parents:
diff changeset
90 #if defined(GNU_EXTENSION)
kono
parents:
diff changeset
91 DEF_MATH_FUNC (o,pow10)
kono
parents:
diff changeset
92 DEF_MATH_FUNC (o,exp10)
kono
parents:
diff changeset
93 #endif
kono
parents:
diff changeset
94 DEF_MATH_FUNC (o,exp2)
kono
parents:
diff changeset
95 DEF_MATH_FUNC (o,exp)
kono
parents:
diff changeset
96 DEF_MATH_FUNC (o,expm1)
kono
parents:
diff changeset
97 DEF_MATH_FUNC (o,cosh)
kono
parents:
diff changeset
98 DEF_MATH_FUNC (o,sinh)
kono
parents:
diff changeset
99 DEF_MATH_FUNC (o,acos)
kono
parents:
diff changeset
100 DEF_MATH_FUNC (o,asin)
kono
parents:
diff changeset
101 DEF_MATH_FUNC (o,acosh)
kono
parents:
diff changeset
102 DEF_MATH_FUNC (o,atanh)
kono
parents:
diff changeset
103 DEF_MATH_FUNC (o,log)
kono
parents:
diff changeset
104 DEF_MATH_FUNC (o,log2)
kono
parents:
diff changeset
105 DEF_MATH_FUNC (o,log10)
kono
parents:
diff changeset
106 DEF_MATH_FUNC (o,log1p)
kono
parents:
diff changeset
107 DEF_MATH_FUNC (o,sqrt)
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 #if defined(LARGE_LONG_DOUBLE)
kono
parents:
diff changeset
110 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
kono
parents:
diff changeset
111 { prefix##name, #name, 0, 0, lb, ub }, \
kono
parents:
diff changeset
112 { prefix##name##l, #name "l" , 0, 0, lb, ub },
kono
parents:
diff changeset
113 #else
kono
parents:
diff changeset
114 #define INIT_MATH_FUNC(prefix, name, lb, ub) { prefix##name##f, #name "f", 0, 0, lb, ub }, \
kono
parents:
diff changeset
115 { prefix##name, #name, 0, 0, lb, ub },
kono
parents:
diff changeset
116 #endif
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 struct MathFuncInfo
kono
parents:
diff changeset
119 {
kono
parents:
diff changeset
120 FP math_func;
kono
parents:
diff changeset
121 const char* name;
kono
parents:
diff changeset
122 int lb;
kono
parents:
diff changeset
123 int ub;
kono
parents:
diff changeset
124 bool has_lb;
kono
parents:
diff changeset
125 bool has_ub;
kono
parents:
diff changeset
126 } math_func_arr[] = {
kono
parents:
diff changeset
127 #if defined(GNU_EXTENSION)
kono
parents:
diff changeset
128 INIT_MATH_FUNC (m,pow10, false, true)
kono
parents:
diff changeset
129 INIT_MATH_FUNC (m,exp10, false, true)
kono
parents:
diff changeset
130 #endif
kono
parents:
diff changeset
131 INIT_MATH_FUNC (m,exp2, false, true)
kono
parents:
diff changeset
132 INIT_MATH_FUNC (m,expm1, false, true)
kono
parents:
diff changeset
133 INIT_MATH_FUNC (m,exp, false, true)
kono
parents:
diff changeset
134 INIT_MATH_FUNC (m,cosh, true, true)
kono
parents:
diff changeset
135 INIT_MATH_FUNC (m,sinh, true, true)
kono
parents:
diff changeset
136 INIT_MATH_FUNC (m,acos, true, true)
kono
parents:
diff changeset
137 INIT_MATH_FUNC (m,asin, true, true)
kono
parents:
diff changeset
138 INIT_MATH_FUNC (m,acosh, true, false)
kono
parents:
diff changeset
139 INIT_MATH_FUNC (m,atanh, true, true)
kono
parents:
diff changeset
140 INIT_MATH_FUNC (m,log10, true, false)
kono
parents:
diff changeset
141 INIT_MATH_FUNC (m,log, true, false)
kono
parents:
diff changeset
142 INIT_MATH_FUNC (m,log2, true, false)
kono
parents:
diff changeset
143 INIT_MATH_FUNC (m,log1p, true, false)
kono
parents:
diff changeset
144 INIT_MATH_FUNC (m,sqrt, true, false)
kono
parents:
diff changeset
145 { 0, 0, 0, 0, 0, 0} };
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 MathFuncInfo opt_math_func_arr[] =
kono
parents:
diff changeset
148 {
kono
parents:
diff changeset
149 #if defined(GNU_EXTENSION)
kono
parents:
diff changeset
150 INIT_MATH_FUNC (o,pow10, false, true)
kono
parents:
diff changeset
151 INIT_MATH_FUNC (o,exp10, false, true)
kono
parents:
diff changeset
152 #endif
kono
parents:
diff changeset
153 INIT_MATH_FUNC (o,exp2, false, true)
kono
parents:
diff changeset
154 INIT_MATH_FUNC (o,expm1, false, true)
kono
parents:
diff changeset
155 INIT_MATH_FUNC (o,exp, false, true)
kono
parents:
diff changeset
156 INIT_MATH_FUNC (o,cosh, true, true)
kono
parents:
diff changeset
157 INIT_MATH_FUNC (o,sinh, true, true)
kono
parents:
diff changeset
158 INIT_MATH_FUNC (o,acos, true, true)
kono
parents:
diff changeset
159 INIT_MATH_FUNC (o,asin, true, true)
kono
parents:
diff changeset
160 INIT_MATH_FUNC (o,acosh, true, false)
kono
parents:
diff changeset
161 INIT_MATH_FUNC (o,atanh, true, true)
kono
parents:
diff changeset
162 INIT_MATH_FUNC (o,log10, true, false)
kono
parents:
diff changeset
163 INIT_MATH_FUNC (o,log, true, false)
kono
parents:
diff changeset
164 INIT_MATH_FUNC (o,log2, true, false)
kono
parents:
diff changeset
165 INIT_MATH_FUNC (o,log1p, true, false)
kono
parents:
diff changeset
166 INIT_MATH_FUNC (o,sqrt, true, false)
kono
parents:
diff changeset
167 { 0, 0, 0, 0, 0, 0} };
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 int test (MathFuncInfo* math_func_infos)
kono
parents:
diff changeset
170 {
kono
parents:
diff changeset
171 int i = 0;
kono
parents:
diff changeset
172 int te = 0;
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 for (i = 0; math_func_infos[i].math_func; i++)
kono
parents:
diff changeset
175 {
kono
parents:
diff changeset
176 MathFuncInfo& info = math_func_infos[i];
kono
parents:
diff changeset
177 int j;
kono
parents:
diff changeset
178 if (info.has_lb)
kono
parents:
diff changeset
179 {
kono
parents:
diff changeset
180 for (j = 0; j > -500000; j--)
kono
parents:
diff changeset
181 {
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 errno = 0;
kono
parents:
diff changeset
184 info.math_func (j);
kono
parents:
diff changeset
185 if (errno != 0)
kono
parents:
diff changeset
186 {
kono
parents:
diff changeset
187 te++;
kono
parents:
diff changeset
188 info.lb = j ;
kono
parents:
diff changeset
189 break;
kono
parents:
diff changeset
190 }
kono
parents:
diff changeset
191 }
kono
parents:
diff changeset
192 }
kono
parents:
diff changeset
193 if (info.has_ub)
kono
parents:
diff changeset
194 {
kono
parents:
diff changeset
195 for (j = 0; j < 500000; j++)
kono
parents:
diff changeset
196 {
kono
parents:
diff changeset
197 errno = 0;
kono
parents:
diff changeset
198 info.math_func (j);
kono
parents:
diff changeset
199 if (errno != 0)
kono
parents:
diff changeset
200 {
kono
parents:
diff changeset
201 te++;
kono
parents:
diff changeset
202 info.ub = j ;
kono
parents:
diff changeset
203 break;
kono
parents:
diff changeset
204 }
kono
parents:
diff changeset
205 }
kono
parents:
diff changeset
206 }
kono
parents:
diff changeset
207 }
kono
parents:
diff changeset
208 return te;
kono
parents:
diff changeset
209 }
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 int main()
kono
parents:
diff changeset
212 {
kono
parents:
diff changeset
213 int te1, te2;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 te1 = test (&math_func_arr[0]);
kono
parents:
diff changeset
216 te2 = test (&opt_math_func_arr[0]);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 // Now examine the result
kono
parents:
diff changeset
219 int i = 0;
kono
parents:
diff changeset
220 int errcnt = 0;
kono
parents:
diff changeset
221 for (i = 0; math_func_arr[i].math_func; i++)
kono
parents:
diff changeset
222 {
kono
parents:
diff changeset
223 MathFuncInfo& info = math_func_arr[i];
kono
parents:
diff changeset
224 MathFuncInfo& opt_info = opt_math_func_arr[i];
kono
parents:
diff changeset
225 #ifdef DEBUG
kono
parents:
diff changeset
226 fprintf (stderr," %s: lb = %d, ub = %d: lb_opt = %d, ub_opt = %d\n",
kono
parents:
diff changeset
227 info.name, info.lb, info.ub, opt_info.lb, opt_info.ub);
kono
parents:
diff changeset
228 #endif
kono
parents:
diff changeset
229 if (info.lb != opt_info.lb) errcnt ++;
kono
parents:
diff changeset
230 if (info.ub != opt_info.ub) errcnt ++;
kono
parents:
diff changeset
231 }
kono
parents:
diff changeset
232 if (errcnt) abort();
kono
parents:
diff changeset
233 return 0;
kono
parents:
diff changeset
234 }