17383
|
1 |
/*
|
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 6934604
|
|
27 |
* @summary enable parts of EliminateAutoBox by default
|
|
28 |
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestFloatBoxing
|
|
29 |
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
|
|
30 |
* -XX:CompileCommand=exclude,TestFloatBoxing.dummy -XX:CompileCommand=exclude,TestFloatBoxing.foo -XX:CompileCommand=exclude,TestFloatBoxing.foob TestFloatBoxing
|
|
31 |
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
|
|
32 |
* -XX:CompileCommand=exclude,TestFloatBoxing.dummy -XX:CompileCommand=exclude,TestFloatBoxing.foo -XX:CompileCommand=exclude,TestFloatBoxing.foob TestFloatBoxing
|
|
33 |
*
|
|
34 |
*/
|
|
35 |
|
|
36 |
public class TestFloatBoxing {
|
|
37 |
|
|
38 |
static final Float ibc = new Float(1.f);
|
|
39 |
|
|
40 |
//===============================================
|
|
41 |
// Non-inlined methods to test deoptimization info
|
|
42 |
static void dummy() { }
|
|
43 |
static float foo(float i) { return i; }
|
|
44 |
static Float foob(float i) { return Float.valueOf(i); }
|
|
45 |
|
|
46 |
|
|
47 |
static float simple(float i) {
|
|
48 |
Float ib = new Float(i);
|
|
49 |
return ib;
|
|
50 |
}
|
|
51 |
|
|
52 |
static float simpleb(float i) {
|
|
53 |
Float ib = Float.valueOf(i);
|
|
54 |
return ib;
|
|
55 |
}
|
|
56 |
|
|
57 |
static float simplec() {
|
|
58 |
Float ib = ibc;
|
|
59 |
return ib;
|
|
60 |
}
|
|
61 |
|
|
62 |
static float simplef(float i) {
|
|
63 |
Float ib = foob(i);
|
|
64 |
return ib;
|
|
65 |
}
|
|
66 |
|
|
67 |
static float simplep(Float ib) {
|
|
68 |
return ib;
|
|
69 |
}
|
|
70 |
|
|
71 |
static float simple2(float i) {
|
|
72 |
Float ib1 = new Float(i);
|
|
73 |
Float ib2 = new Float(i+1.f);
|
|
74 |
return ib1 + ib2;
|
|
75 |
}
|
|
76 |
|
|
77 |
static float simpleb2(float i) {
|
|
78 |
Float ib1 = Float.valueOf(i);
|
|
79 |
Float ib2 = Float.valueOf(i+1.f);
|
|
80 |
return ib1 + ib2;
|
|
81 |
}
|
|
82 |
|
|
83 |
static float simplem2(float i) {
|
|
84 |
Float ib1 = new Float(i);
|
|
85 |
Float ib2 = Float.valueOf(i+1.f);
|
|
86 |
return ib1 + ib2;
|
|
87 |
}
|
|
88 |
|
|
89 |
static float simplep2(float i, Float ib1) {
|
|
90 |
Float ib2 = Float.valueOf(i+1.f);
|
|
91 |
return ib1 + ib2;
|
|
92 |
}
|
|
93 |
|
|
94 |
static float simplec2(float i) {
|
|
95 |
Float ib1 = ibc;
|
|
96 |
Float ib2 = Float.valueOf(i+1.f);
|
|
97 |
return ib1 + ib2;
|
|
98 |
}
|
|
99 |
|
|
100 |
//===============================================
|
|
101 |
static float test(float f, int i) {
|
|
102 |
Float ib = new Float(f);
|
|
103 |
if ((i&1) == 0)
|
|
104 |
ib = f+1.f;
|
|
105 |
return ib;
|
|
106 |
}
|
|
107 |
|
|
108 |
static float testb(float f, int i) {
|
|
109 |
Float ib = f;
|
|
110 |
if ((i&1) == 0)
|
|
111 |
ib = (f+1.f);
|
|
112 |
return ib;
|
|
113 |
}
|
|
114 |
|
|
115 |
static float testm(float f, int i) {
|
|
116 |
Float ib = f;
|
|
117 |
if ((i&1) == 0)
|
|
118 |
ib = new Float(f+1.f);
|
|
119 |
return ib;
|
|
120 |
}
|
|
121 |
|
|
122 |
static float testp(float f, int i, Float ib) {
|
|
123 |
if ((i&1) == 0)
|
|
124 |
ib = new Float(f+1.f);
|
|
125 |
return ib;
|
|
126 |
}
|
|
127 |
|
|
128 |
static float testc(float f, int i) {
|
|
129 |
Float ib = ibc;
|
|
130 |
if ((i&1) == 0)
|
|
131 |
ib = new Float(f+1.f);
|
|
132 |
return ib;
|
|
133 |
}
|
|
134 |
|
|
135 |
static float test2(float f, int i) {
|
|
136 |
Float ib1 = new Float(f);
|
|
137 |
Float ib2 = new Float(f+1.f);
|
|
138 |
if ((i&1) == 0) {
|
|
139 |
ib1 = new Float(f+1.f);
|
|
140 |
ib2 = new Float(f+2.f);
|
|
141 |
}
|
|
142 |
return ib1+ib2;
|
|
143 |
}
|
|
144 |
|
|
145 |
static float testb2(float f, int i) {
|
|
146 |
Float ib1 = f;
|
|
147 |
Float ib2 = f+1.f;
|
|
148 |
if ((i&1) == 0) {
|
|
149 |
ib1 = (f+1.f);
|
|
150 |
ib2 = (f+2.f);
|
|
151 |
}
|
|
152 |
return ib1+ib2;
|
|
153 |
}
|
|
154 |
|
|
155 |
static float testm2(float f, int i) {
|
|
156 |
Float ib1 = new Float(f);
|
|
157 |
Float ib2 = f+1.f;
|
|
158 |
if ((i&1) == 0) {
|
|
159 |
ib1 = new Float(f+1.f);
|
|
160 |
ib2 = (f+2.f);
|
|
161 |
}
|
|
162 |
return ib1+ib2;
|
|
163 |
}
|
|
164 |
|
|
165 |
static float testp2(float f, int i, Float ib1) {
|
|
166 |
Float ib2 = f+1.f;
|
|
167 |
if ((i&1) == 0) {
|
|
168 |
ib1 = new Float(f+1.f);
|
|
169 |
ib2 = (f+2.f);
|
|
170 |
}
|
|
171 |
return ib1+ib2;
|
|
172 |
}
|
|
173 |
|
|
174 |
static float testc2(float f, int i) {
|
|
175 |
Float ib1 = ibc;
|
|
176 |
Float ib2 = f+1.f;
|
|
177 |
if ((i&1) == 0) {
|
|
178 |
ib1 = (ibc+1.f);
|
|
179 |
ib2 = (f+2.f);
|
|
180 |
}
|
|
181 |
return ib1+ib2;
|
|
182 |
}
|
|
183 |
|
|
184 |
//===============================================
|
|
185 |
static float sum(float[] a) {
|
|
186 |
float result = 1.f;
|
|
187 |
for (Float i : a)
|
|
188 |
result += i;
|
|
189 |
return result;
|
|
190 |
}
|
|
191 |
|
|
192 |
static float sumb(float[] a) {
|
|
193 |
Float result = 1.f;
|
|
194 |
for (Float i : a)
|
|
195 |
result += i;
|
|
196 |
return result;
|
|
197 |
}
|
|
198 |
|
|
199 |
static float sumc(float[] a) {
|
|
200 |
Float result = ibc;
|
|
201 |
for (Float i : a)
|
|
202 |
result += i;
|
|
203 |
return result;
|
|
204 |
}
|
|
205 |
|
|
206 |
static float sumf(float[] a) {
|
|
207 |
Float result = foob(1.f);
|
|
208 |
for (Float i : a)
|
|
209 |
result += i;
|
|
210 |
return result;
|
|
211 |
}
|
|
212 |
|
|
213 |
static float sump(float[] a, Float result) {
|
|
214 |
for (Float i : a)
|
|
215 |
result += i;
|
|
216 |
return result;
|
|
217 |
}
|
|
218 |
|
|
219 |
static float sum2(float[] a) {
|
|
220 |
float result1 = 1.f;
|
|
221 |
float result2 = 1.f;
|
|
222 |
for (Float i : a) {
|
|
223 |
result1 += i;
|
|
224 |
result2 += i + 1.f;
|
|
225 |
}
|
|
226 |
return result1 + result2;
|
|
227 |
}
|
|
228 |
|
|
229 |
static float sumb2(float[] a) {
|
|
230 |
Float result1 = 1.f;
|
|
231 |
Float result2 = 1.f;
|
|
232 |
for (Float i : a) {
|
|
233 |
result1 += i;
|
|
234 |
result2 += i + 1.f;
|
|
235 |
}
|
|
236 |
return result1 + result2;
|
|
237 |
}
|
|
238 |
|
|
239 |
static float summ2(float[] a) {
|
|
240 |
Float result1 = 1.f;
|
|
241 |
Float result2 = new Float(1.f);
|
|
242 |
for (Float i : a) {
|
|
243 |
result1 += i;
|
|
244 |
result2 += new Float(i + 1.f);
|
|
245 |
}
|
|
246 |
return result1 + result2;
|
|
247 |
}
|
|
248 |
|
|
249 |
static float sump2(float[] a, Float result2) {
|
|
250 |
Float result1 = 1.f;
|
|
251 |
for (Float i : a) {
|
|
252 |
result1 += i;
|
|
253 |
result2 += i + 1.f;
|
|
254 |
}
|
|
255 |
return result1 + result2;
|
|
256 |
}
|
|
257 |
|
|
258 |
static float sumc2(float[] a) {
|
|
259 |
Float result1 = 1.f;
|
|
260 |
Float result2 = ibc;
|
|
261 |
for (Float i : a) {
|
|
262 |
result1 += i;
|
|
263 |
result2 += i + ibc;
|
|
264 |
}
|
|
265 |
return result1 + result2;
|
|
266 |
}
|
|
267 |
|
|
268 |
//===============================================
|
|
269 |
static float remi_sum() {
|
|
270 |
Float j = new Float(1.f);
|
|
271 |
for (int i = 0; i< 1000; i++) {
|
|
272 |
j = new Float(j + 1.f);
|
|
273 |
}
|
|
274 |
return j;
|
|
275 |
}
|
|
276 |
|
|
277 |
static float remi_sumb() {
|
|
278 |
Float j = Float.valueOf(1.f);
|
|
279 |
for (int i = 0; i< 1000; i++) {
|
|
280 |
j = j + 1.f;
|
|
281 |
}
|
|
282 |
return j;
|
|
283 |
}
|
|
284 |
|
|
285 |
static float remi_sumf() {
|
|
286 |
Float j = foob(1.f);
|
|
287 |
for (int i = 0; i< 1000; i++) {
|
|
288 |
j = j + 1.f;
|
|
289 |
}
|
|
290 |
return j;
|
|
291 |
}
|
|
292 |
|
|
293 |
static float remi_sump(Float j) {
|
|
294 |
for (int i = 0; i< 1000; i++) {
|
|
295 |
j = new Float(j + 1.f);
|
|
296 |
}
|
|
297 |
return j;
|
|
298 |
}
|
|
299 |
|
|
300 |
static float remi_sumc() {
|
|
301 |
Float j = ibc;
|
|
302 |
for (int i = 0; i< 1000; i++) {
|
|
303 |
j = j + ibc;
|
|
304 |
}
|
|
305 |
return j;
|
|
306 |
}
|
|
307 |
|
|
308 |
static float remi_sum2() {
|
|
309 |
Float j1 = new Float(1.f);
|
|
310 |
Float j2 = new Float(1.f);
|
|
311 |
for (int i = 0; i< 1000; i++) {
|
|
312 |
j1 = new Float(j1 + 1.f);
|
|
313 |
j2 = new Float(j2 + 2.f);
|
|
314 |
}
|
|
315 |
return j1 + j2;
|
|
316 |
}
|
|
317 |
|
|
318 |
static float remi_sumb2() {
|
|
319 |
Float j1 = Float.valueOf(1.f);
|
|
320 |
Float j2 = Float.valueOf(1.f);
|
|
321 |
for (int i = 0; i< 1000; i++) {
|
|
322 |
j1 = j1 + 1.f;
|
|
323 |
j2 = j2 + 2.f;
|
|
324 |
}
|
|
325 |
return j1 + j2;
|
|
326 |
}
|
|
327 |
|
|
328 |
static float remi_summ2() {
|
|
329 |
Float j1 = new Float(1.f);
|
|
330 |
Float j2 = Float.valueOf(1.f);
|
|
331 |
for (int i = 0; i< 1000; i++) {
|
|
332 |
j1 = new Float(j1 + 1.f);
|
|
333 |
j2 = j2 + 2.f;
|
|
334 |
}
|
|
335 |
return j1 + j2;
|
|
336 |
}
|
|
337 |
|
|
338 |
static float remi_sump2(Float j1) {
|
|
339 |
Float j2 = Float.valueOf(1.f);
|
|
340 |
for (int i = 0; i< 1000; i++) {
|
|
341 |
j1 = new Float(j1 + 1.f);
|
|
342 |
j2 = j2 + 2.f;
|
|
343 |
}
|
|
344 |
return j1 + j2;
|
|
345 |
}
|
|
346 |
|
|
347 |
static float remi_sumc2() {
|
|
348 |
Float j1 = ibc;
|
|
349 |
Float j2 = Float.valueOf(1.f);
|
|
350 |
for (int i = 0; i< 1000; i++) {
|
|
351 |
j1 = j1 + ibc;
|
|
352 |
j2 = j2 + 2.f;
|
|
353 |
}
|
|
354 |
return j1 + j2;
|
|
355 |
}
|
|
356 |
|
|
357 |
|
|
358 |
//===============================================
|
|
359 |
// Safepointa and debug info for deoptimization
|
|
360 |
static float simple_deop(float i) {
|
|
361 |
Float ib = new Float(foo(i));
|
|
362 |
dummy();
|
|
363 |
return ib;
|
|
364 |
}
|
|
365 |
|
|
366 |
static float simpleb_deop(float i) {
|
|
367 |
Float ib = Float.valueOf(foo(i));
|
|
368 |
dummy();
|
|
369 |
return ib;
|
|
370 |
}
|
|
371 |
|
|
372 |
static float simplef_deop(float i) {
|
|
373 |
Float ib = foob(i);
|
|
374 |
dummy();
|
|
375 |
return ib;
|
|
376 |
}
|
|
377 |
|
|
378 |
static float simplep_deop(Float ib) {
|
|
379 |
dummy();
|
|
380 |
return ib;
|
|
381 |
}
|
|
382 |
|
|
383 |
static float simplec_deop(float i) {
|
|
384 |
Float ib = ibc;
|
|
385 |
dummy();
|
|
386 |
return ib;
|
|
387 |
}
|
|
388 |
|
|
389 |
static float test_deop(float f, int i) {
|
|
390 |
Float ib = new Float(foo(f));
|
|
391 |
if ((i&1) == 0)
|
|
392 |
ib = foo(f+1.f);
|
|
393 |
dummy();
|
|
394 |
return ib;
|
|
395 |
}
|
|
396 |
|
|
397 |
static float testb_deop(float f, int i) {
|
|
398 |
Float ib = foo(f);
|
|
399 |
if ((i&1) == 0)
|
|
400 |
ib = foo(f+1.f);
|
|
401 |
dummy();
|
|
402 |
return ib;
|
|
403 |
}
|
|
404 |
|
|
405 |
static float testf_deop(float f, int i) {
|
|
406 |
Float ib = foob(f);
|
|
407 |
if ((i&1) == 0)
|
|
408 |
ib = foo(f+1.f);
|
|
409 |
dummy();
|
|
410 |
return ib;
|
|
411 |
}
|
|
412 |
|
|
413 |
static float testp_deop(float f, int i, Float ib) {
|
|
414 |
if ((i&1) == 0)
|
|
415 |
ib = foo(f+1.f);
|
|
416 |
dummy();
|
|
417 |
return ib;
|
|
418 |
}
|
|
419 |
|
|
420 |
static float testc_deop(float f, int i) {
|
|
421 |
Float ib = ibc;
|
|
422 |
if ((i&1) == 0)
|
|
423 |
ib = foo(f+1.f);
|
|
424 |
dummy();
|
|
425 |
return ib;
|
|
426 |
}
|
|
427 |
|
|
428 |
static float sum_deop(float[] a) {
|
|
429 |
float result = 1.f;
|
|
430 |
for (Float i : a)
|
|
431 |
result += foo(i);
|
|
432 |
dummy();
|
|
433 |
return result;
|
|
434 |
}
|
|
435 |
|
|
436 |
static float sumb_deop(float[] a) {
|
|
437 |
Float result = 1.f;
|
|
438 |
for (Float i : a)
|
|
439 |
result += foo(i);
|
|
440 |
dummy();
|
|
441 |
return result;
|
|
442 |
}
|
|
443 |
|
|
444 |
static float sumf_deop(float[] a) {
|
|
445 |
Float result = 1.f;
|
|
446 |
for (Float i : a)
|
|
447 |
result += foob(i);
|
|
448 |
dummy();
|
|
449 |
return result;
|
|
450 |
}
|
|
451 |
|
|
452 |
static float sump_deop(float[] a, Float result) {
|
|
453 |
for (Float i : a)
|
|
454 |
result += foob(i);
|
|
455 |
dummy();
|
|
456 |
return result;
|
|
457 |
}
|
|
458 |
|
|
459 |
static float sumc_deop(float[] a) {
|
|
460 |
Float result = ibc;
|
|
461 |
for (Float i : a)
|
|
462 |
result += foo(i);
|
|
463 |
dummy();
|
|
464 |
return result;
|
|
465 |
}
|
|
466 |
|
|
467 |
static float remi_sum_deop() {
|
|
468 |
Float j = new Float(foo(1.f));
|
|
469 |
for (int i = 0; i< 1000; i++) {
|
|
470 |
j = new Float(foo(j + 1.f));
|
|
471 |
}
|
|
472 |
dummy();
|
|
473 |
return j;
|
|
474 |
}
|
|
475 |
|
|
476 |
static float remi_sumb_deop() {
|
|
477 |
Float j = Float.valueOf(foo(1.f));
|
|
478 |
for (int i = 0; i< 1000; i++) {
|
|
479 |
j = foo(j + 1.f);
|
|
480 |
}
|
|
481 |
dummy();
|
|
482 |
return j;
|
|
483 |
}
|
|
484 |
|
|
485 |
static float remi_sumf_deop() {
|
|
486 |
Float j = foob(1.f);
|
|
487 |
for (int i = 0; i< 1000; i++) {
|
|
488 |
j = foo(j + 1.f);
|
|
489 |
}
|
|
490 |
dummy();
|
|
491 |
return j;
|
|
492 |
}
|
|
493 |
|
|
494 |
static float remi_sump_deop(Float j) {
|
|
495 |
for (int i = 0; i< 1000; i++) {
|
|
496 |
j = foo(j + 1.f);
|
|
497 |
}
|
|
498 |
dummy();
|
|
499 |
return j;
|
|
500 |
}
|
|
501 |
|
|
502 |
static float remi_sumc_deop() {
|
|
503 |
Float j = ibc;
|
|
504 |
for (int i = 0; i< 1000; i++) {
|
|
505 |
j = foo(j + 1.f);
|
|
506 |
}
|
|
507 |
dummy();
|
|
508 |
return j;
|
|
509 |
}
|
|
510 |
|
|
511 |
//===============================================
|
|
512 |
// Conditional increment
|
|
513 |
static float remi_sum_cond() {
|
|
514 |
Float j = new Float(1.f);
|
|
515 |
for (int i = 0; i< 1000; i++) {
|
|
516 |
if ((i&1) == 0) {
|
|
517 |
j = new Float(j + 1.f);
|
|
518 |
}
|
|
519 |
}
|
|
520 |
return j;
|
|
521 |
}
|
|
522 |
|
|
523 |
static float remi_sumb_cond() {
|
|
524 |
Float j = Float.valueOf(1.f);
|
|
525 |
for (int i = 0; i< 1000; i++) {
|
|
526 |
if ((i&1) == 0) {
|
|
527 |
j = j + 1.f;
|
|
528 |
}
|
|
529 |
}
|
|
530 |
return j;
|
|
531 |
}
|
|
532 |
|
|
533 |
static float remi_sumf_cond() {
|
|
534 |
Float j = foob(1.f);
|
|
535 |
for (int i = 0; i< 1000; i++) {
|
|
536 |
if ((i&1) == 0) {
|
|
537 |
j = j + 1.f;
|
|
538 |
}
|
|
539 |
}
|
|
540 |
return j;
|
|
541 |
}
|
|
542 |
|
|
543 |
static float remi_sump_cond(Float j) {
|
|
544 |
for (int i = 0; i< 1000; i++) {
|
|
545 |
if ((i&1) == 0) {
|
|
546 |
j = j + 1.f;
|
|
547 |
}
|
|
548 |
}
|
|
549 |
return j;
|
|
550 |
}
|
|
551 |
|
|
552 |
static float remi_sumc_cond() {
|
|
553 |
Float j = ibc;
|
|
554 |
for (int i = 0; i< 1000; i++) {
|
|
555 |
if ((i&1) == 0) {
|
|
556 |
j = j + ibc;
|
|
557 |
}
|
|
558 |
}
|
|
559 |
return j;
|
|
560 |
}
|
|
561 |
|
|
562 |
static float remi_sum2_cond() {
|
|
563 |
Float j1 = new Float(1.f);
|
|
564 |
Float j2 = new Float(1.f);
|
|
565 |
for (int i = 0; i< 1000; i++) {
|
|
566 |
if ((i&1) == 0) {
|
|
567 |
j1 = new Float(j1 + 1.f);
|
|
568 |
} else {
|
|
569 |
j2 = new Float(j2 + 2.f);
|
|
570 |
}
|
|
571 |
}
|
|
572 |
return j1 + j2;
|
|
573 |
}
|
|
574 |
|
|
575 |
static float remi_sumb2_cond() {
|
|
576 |
Float j1 = Float.valueOf(1.f);
|
|
577 |
Float j2 = Float.valueOf(1.f);
|
|
578 |
for (int i = 0; i< 1000; i++) {
|
|
579 |
if ((i&1) == 0) {
|
|
580 |
j1 = j1 + 1.f;
|
|
581 |
} else {
|
|
582 |
j2 = j2 + 2.f;
|
|
583 |
}
|
|
584 |
}
|
|
585 |
return j1 + j2;
|
|
586 |
}
|
|
587 |
|
|
588 |
static float remi_summ2_cond() {
|
|
589 |
Float j1 = new Float(1.f);
|
|
590 |
Float j2 = Float.valueOf(1.f);
|
|
591 |
for (int i = 0; i< 1000; i++) {
|
|
592 |
if ((i&1) == 0) {
|
|
593 |
j1 = new Float(j1 + 1.f);
|
|
594 |
} else {
|
|
595 |
j2 = j2 + 2.f;
|
|
596 |
}
|
|
597 |
}
|
|
598 |
return j1 + j2;
|
|
599 |
}
|
|
600 |
|
|
601 |
static float remi_sump2_cond(Float j1) {
|
|
602 |
Float j2 = Float.valueOf(1.f);
|
|
603 |
for (int i = 0; i< 1000; i++) {
|
|
604 |
if ((i&1) == 0) {
|
|
605 |
j1 = new Float(j1 + 1.f);
|
|
606 |
} else {
|
|
607 |
j2 = j2 + 2.f;
|
|
608 |
}
|
|
609 |
}
|
|
610 |
return j1 + j2;
|
|
611 |
}
|
|
612 |
|
|
613 |
static float remi_sumc2_cond() {
|
|
614 |
Float j1 = ibc;
|
|
615 |
Float j2 = Float.valueOf(1.f);
|
|
616 |
for (int i = 0; i< 1000; i++) {
|
|
617 |
if ((i&1) == 0) {
|
|
618 |
j1 = j1 + ibc;
|
|
619 |
} else {
|
|
620 |
j2 = j2 + 2;
|
|
621 |
}
|
|
622 |
}
|
|
623 |
return j1 + j2;
|
|
624 |
}
|
|
625 |
|
|
626 |
|
|
627 |
public static void main(String[] args) {
|
|
628 |
final int ntests = 70;
|
|
629 |
|
|
630 |
String[] test_name = new String[] {
|
|
631 |
"simple", "simpleb", "simplec", "simplef", "simplep",
|
|
632 |
"simple2", "simpleb2", "simplec2", "simplem2", "simplep2",
|
|
633 |
"simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
|
|
634 |
"test", "testb", "testc", "testm", "testp",
|
|
635 |
"test2", "testb2", "testc2", "testm2", "testp2",
|
|
636 |
"test_deop", "testb_deop", "testc_deop", "testf_deop", "testp_deop",
|
|
637 |
"sum", "sumb", "sumc", "sumf", "sump",
|
|
638 |
"sum2", "sumb2", "sumc2", "summ2", "sump2",
|
|
639 |
"sum_deop", "sumb_deop", "sumc_deop", "sumf_deop", "sump_deop",
|
|
640 |
"remi_sum", "remi_sumb", "remi_sumc", "remi_sumf", "remi_sump",
|
|
641 |
"remi_sum2", "remi_sumb2", "remi_sumc2", "remi_summ2", "remi_sump2",
|
|
642 |
"remi_sum_deop", "remi_sumb_deop", "remi_sumc_deop", "remi_sumf_deop", "remi_sump_deop",
|
|
643 |
"remi_sum_cond", "remi_sumb_cond", "remi_sumc_cond", "remi_sumf_cond", "remi_sump_cond",
|
|
644 |
"remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
|
|
645 |
};
|
|
646 |
|
|
647 |
final float[] val = new float[] {
|
|
648 |
71990896.f, 71990896.f, 12000.f, 71990896.f, 71990896.f,
|
|
649 |
144000000.f, 144000000.f, 72014896.f, 144000000.f, 144000000.f,
|
|
650 |
71990896.f, 71990896.f, 12000.f, 71990896.f, 71990896.f,
|
|
651 |
72000000.f, 72000000.f, 36004096.f, 72000000.f, 72000000.f,
|
|
652 |
144012288.f, 144012288.f, 72033096.f, 144012288.f, 144012288.f,
|
|
653 |
72000000.f, 72000000.f, 36004096.f, 72000000.f, 72000000.f,
|
|
654 |
499501.f, 499501.f, 499501.f, 499501.f, 499501.f,
|
|
655 |
1000002.f, 1000002.f, 1000002.f, 1000002.f, 1000002.f,
|
|
656 |
499501.f, 499501.f, 499501.f, 499501.f, 499501.f,
|
|
657 |
1001.f, 1001.f, 1001.f, 1001.f, 1001.f,
|
|
658 |
3002.f, 3002.f, 3002.f, 3002.f, 3002.f,
|
|
659 |
1001.f, 1001.f, 1001.f, 1001.f, 1001.f,
|
|
660 |
501.f, 501.f, 501.f, 501.f, 501.f,
|
|
661 |
1502.f, 1502.f, 1502.f, 1502.f, 1502.f
|
|
662 |
};
|
|
663 |
|
|
664 |
float[] res = new float[ntests];
|
|
665 |
for (int i = 0; i < ntests; i++) {
|
|
666 |
res[i] = 0.f;
|
|
667 |
}
|
|
668 |
|
|
669 |
|
|
670 |
for (int i = 0; i < 12000; i++) {
|
|
671 |
res[0] += simple(i);
|
|
672 |
res[1] += simpleb(i);
|
|
673 |
res[2] += simplec();
|
|
674 |
res[3] += simplef(i);
|
|
675 |
res[4] += simplep((float)i);
|
|
676 |
|
|
677 |
res[5] += simple2((float)i);
|
|
678 |
res[6] += simpleb2((float)i);
|
|
679 |
res[7] += simplec2((float)i);
|
|
680 |
res[8] += simplem2((float)i);
|
|
681 |
res[9] += simplep2((float)i, (float)i);
|
|
682 |
|
|
683 |
res[10] += simple_deop((float)i);
|
|
684 |
res[11] += simpleb_deop((float)i);
|
|
685 |
res[12] += simplec_deop((float)i);
|
|
686 |
res[13] += simplef_deop((float)i);
|
|
687 |
res[14] += simplep_deop((float)i);
|
|
688 |
|
|
689 |
res[15] += test((float)i, i);
|
|
690 |
res[16] += testb((float)i, i);
|
|
691 |
res[17] += testc((float)i, i);
|
|
692 |
res[18] += testm((float)i, i);
|
|
693 |
res[19] += testp((float)i, i, (float)i);
|
|
694 |
|
|
695 |
res[20] += test2((float)i, i);
|
|
696 |
res[21] += testb2((float)i, i);
|
|
697 |
res[22] += testc2((float)i, i);
|
|
698 |
res[23] += testm2((float)i, i);
|
|
699 |
res[24] += testp2((float)i, i, (float)i);
|
|
700 |
|
|
701 |
res[25] += test_deop((float)i, i);
|
|
702 |
res[26] += testb_deop((float)i, i);
|
|
703 |
res[27] += testc_deop((float)i, i);
|
|
704 |
res[28] += testf_deop((float)i, i);
|
|
705 |
res[29] += testp_deop((float)i, i, (float)i);
|
|
706 |
}
|
|
707 |
|
|
708 |
float[] ia = new float[1000];
|
|
709 |
for (int i = 0; i < 1000; i++) {
|
|
710 |
ia[i] = i;
|
|
711 |
}
|
|
712 |
|
|
713 |
for (int i = 0; i < 100; i++) {
|
|
714 |
res[30] = sum(ia);
|
|
715 |
res[31] = sumb(ia);
|
|
716 |
res[32] = sumc(ia);
|
|
717 |
res[33] = sumf(ia);
|
|
718 |
res[34] = sump(ia, 1.f);
|
|
719 |
|
|
720 |
res[35] = sum2(ia);
|
|
721 |
res[36] = sumb2(ia);
|
|
722 |
res[37] = sumc2(ia);
|
|
723 |
res[38] = summ2(ia);
|
|
724 |
res[39] = sump2(ia, 1.f);
|
|
725 |
|
|
726 |
res[40] = sum_deop(ia);
|
|
727 |
res[41] = sumb_deop(ia);
|
|
728 |
res[42] = sumc_deop(ia);
|
|
729 |
res[43] = sumf_deop(ia);
|
|
730 |
res[44] = sump_deop(ia, 1.f);
|
|
731 |
|
|
732 |
res[45] = remi_sum();
|
|
733 |
res[46] = remi_sumb();
|
|
734 |
res[47] = remi_sumc();
|
|
735 |
res[48] = remi_sumf();
|
|
736 |
res[49] = remi_sump(1.f);
|
|
737 |
|
|
738 |
res[50] = remi_sum2();
|
|
739 |
res[51] = remi_sumb2();
|
|
740 |
res[52] = remi_sumc2();
|
|
741 |
res[53] = remi_summ2();
|
|
742 |
res[54] = remi_sump2(1.f);
|
|
743 |
|
|
744 |
res[55] = remi_sum_deop();
|
|
745 |
res[56] = remi_sumb_deop();
|
|
746 |
res[57] = remi_sumc_deop();
|
|
747 |
res[58] = remi_sumf_deop();
|
|
748 |
res[59] = remi_sump_deop(1.f);
|
|
749 |
|
|
750 |
res[60] = remi_sum_cond();
|
|
751 |
res[61] = remi_sumb_cond();
|
|
752 |
res[62] = remi_sumc_cond();
|
|
753 |
res[63] = remi_sumf_cond();
|
|
754 |
res[64] = remi_sump_cond(1.f);
|
|
755 |
|
|
756 |
res[65] = remi_sum2_cond();
|
|
757 |
res[66] = remi_sumb2_cond();
|
|
758 |
res[67] = remi_sumc2_cond();
|
|
759 |
res[68] = remi_summ2_cond();
|
|
760 |
res[69] = remi_sump2_cond(1.f);
|
|
761 |
}
|
|
762 |
|
|
763 |
int failed = 0;
|
|
764 |
for (int i = 0; i < ntests; i++) {
|
|
765 |
if (res[i] != val[i]) {
|
|
766 |
System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
|
|
767 |
failed++;
|
|
768 |
}
|
|
769 |
}
|
|
770 |
if (failed > 0) {
|
|
771 |
System.err.println("Failed " + failed + " tests.");
|
|
772 |
throw new InternalError();
|
|
773 |
} else {
|
|
774 |
System.out.println("Passed.");
|
|
775 |
}
|
|
776 |
}
|
|
777 |
}
|