10011
|
1 |
/*
|
|
2 |
* Copyright (c) 2011, 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 |
/**
|
|
26 |
* @test
|
|
27 |
* @bug 7044738
|
|
28 |
* @summary Loop unroll optimization causes incorrect result
|
|
29 |
*
|
|
30 |
* @run main/othervm -Xbatch Test7044738
|
|
31 |
*/
|
|
32 |
|
|
33 |
public class Test7044738 {
|
|
34 |
|
|
35 |
private static final int INITSIZE = 10000;
|
|
36 |
public int d[] = { 1, 2, 3, 4 };
|
|
37 |
public int i, size;
|
|
38 |
|
|
39 |
private static int iter = 5;
|
|
40 |
|
|
41 |
boolean done() { return (--iter > 0); }
|
|
42 |
|
|
43 |
public static void main(String args[]) {
|
|
44 |
Test7044738 t = new Test7044738();
|
|
45 |
t.test();
|
|
46 |
}
|
|
47 |
|
|
48 |
int test() {
|
|
49 |
|
|
50 |
while (done()) {
|
|
51 |
size = INITSIZE;
|
|
52 |
|
|
53 |
for (i = 0; i < size; i++) {
|
|
54 |
d[0] = d[1]; // 2
|
|
55 |
d[1] = d[2]; // 3
|
|
56 |
d[2] = d[3]; // 4
|
|
57 |
d[3] = d[0]; // 2
|
|
58 |
|
|
59 |
d[0] = d[1]; // 3
|
|
60 |
d[1] = d[2]; // 4
|
|
61 |
d[2] = d[3]; // 2
|
|
62 |
d[3] = d[0]; // 3
|
|
63 |
|
|
64 |
d[0] = d[1]; // 4
|
|
65 |
d[1] = d[2]; // 2
|
|
66 |
d[2] = d[3]; // 3
|
|
67 |
d[3] = d[0]; // 4
|
|
68 |
|
|
69 |
d[0] = d[1]; // 2
|
|
70 |
d[1] = d[2]; // 3
|
|
71 |
d[2] = d[3]; // 4
|
|
72 |
d[3] = d[0]; // 2
|
|
73 |
|
|
74 |
d[0] = d[1]; // 3
|
|
75 |
d[1] = d[2]; // 4
|
|
76 |
d[2] = d[3]; // 2
|
|
77 |
d[3] = d[0]; // 3
|
|
78 |
|
|
79 |
d[0] = d[1]; // 4
|
|
80 |
d[1] = d[2]; // 2
|
|
81 |
d[2] = d[3]; // 3
|
|
82 |
d[3] = d[0]; // 4
|
|
83 |
|
|
84 |
d[0] = d[1]; // 2
|
|
85 |
d[1] = d[2]; // 3
|
|
86 |
d[2] = d[3]; // 4
|
|
87 |
d[3] = d[0]; // 2
|
|
88 |
|
|
89 |
d[0] = d[1]; // 3
|
|
90 |
d[1] = d[2]; // 4
|
|
91 |
d[2] = d[3]; // 2
|
|
92 |
d[3] = d[0]; // 3
|
|
93 |
}
|
|
94 |
|
|
95 |
// try to defeat dead code elimination
|
|
96 |
if (d[0] == d[1]) {
|
|
97 |
System.out.println("test failed: iter=" + iter + " i=" + i + " d[] = { " + d[0] + ", " + d[1] + ", " + d[2] + ", " + d[3] + " } ");
|
|
98 |
System.exit(97);
|
|
99 |
}
|
|
100 |
}
|
|
101 |
return d[3];
|
|
102 |
}
|
|
103 |
|
|
104 |
}
|