Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestDepBetweenLoopAndPredicate.java
64478 views
1
/*
2
* Copyright (c) 2021, 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 8277529
27
* @summary RangeCheck should not be moved out of a loop if a node on the data input chain for the bool is dependent
28
* on the projection into the loop (after the predicates).
29
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.loopopts.TestDepBetweenLoopAndPredicate::test*
30
* compiler.loopopts.TestDepBetweenLoopAndPredicate
31
*/
32
33
package compiler.loopopts;
34
35
public class TestDepBetweenLoopAndPredicate {
36
static int x, y, z;
37
static boolean flag;
38
static int[] iArrFld = new int[25];
39
static int[] iArrFld2 = new int[5];
40
static int limit = 5;
41
42
public static void main(String[] args) {
43
for (int i = 0; i < 10000; i++) {
44
flag = !flag;
45
test();
46
}
47
48
for (int i = 0; i < 5000; i++) {
49
flag = !flag;
50
test2();
51
test3();
52
test4();
53
test5();
54
}
55
}
56
57
public static void test() {
58
int[] iArr = new int[20];
59
System.arraycopy(iArrFld, x, iArr, y, 18);
60
61
if (flag) {
62
return;
63
}
64
65
for (int i = 0; i < limit; i++) {
66
iArr[19]++;
67
}
68
}
69
70
public static void test2() {
71
for (int i = 0; i < limit; i++) {
72
int[] iArr = new int[20];
73
System.arraycopy(iArrFld, x, iArr, y, 18);
74
75
if (flag) {
76
return;
77
}
78
79
for (int j = i; j < limit; j++) {
80
x = iArrFld[iArr[19]]; // No new offset node created
81
iArr[19]++;
82
}
83
}
84
}
85
86
public static void test3() {
87
for (int i = 0; i < limit; i++) {
88
int[] iArr = new int[20];
89
System.arraycopy(iArrFld, x, iArr, y, 18);
90
91
if (flag) {
92
return;
93
}
94
95
for (int j = i + 1; j < limit; j++) {
96
x = iArrFld[iArr[19]]; // New offset node created
97
iArr[19]++;
98
}
99
}
100
}
101
102
public static void test4() {
103
for (int i = 0; i < limit; i++) {
104
int[] iArr = new int[20];
105
System.arraycopy(iArrFld, x, iArr, y, 18);
106
107
if (flag) {
108
return;
109
}
110
111
for (int j = i + 1 + z; j < limit; j++) {
112
x = iArrFld[iArr[19]]; // New offset node created
113
iArr[19]++;
114
}
115
}
116
}
117
118
public static void test5() {
119
for (int i = 0; i < limit; i++) {
120
int[] iArr = new int[20];
121
System.arraycopy(iArrFld, x, iArr, y, 18);
122
123
if (flag) {
124
return;
125
}
126
127
for (int j = i + 1 + z; j < limit; j++) {
128
x = iArrFld[iArr[19]]; // New offset node created
129
iArr[19]++;
130
y += iArrFld2[3]; // Range check removed because not dependent on projection into the loop
131
}
132
}
133
}
134
}
135
136