Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/AntiDependentLoadInOuterStripMinedLoop.java
41152 views
1
/*
2
* Copyright (c) 2019, Red Hat, Inc. 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 8229483
27
* @summary Sinking load out of loop may trigger: assert(found_sfpt) failed: no node in loop that's not input to safepoint
28
*
29
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:LoopMaxUnroll=0 AntiDependentLoadInOuterStripMinedLoop
30
*
31
*/
32
33
public class AntiDependentLoadInOuterStripMinedLoop {
34
private static int field;
35
private static volatile int barrier;
36
37
public static void main(String[] args) {
38
int[] array = new int[1];
39
A a = new A();
40
for (int i = 0; i < 20_000; i++) {
41
test1(array);
42
test2(a, array);
43
test2_helper(array, 0, 0);
44
}
45
}
46
47
private static int test1(int[] array) {
48
int res = 1;
49
50
for (int i = 0; i < 10; i++) {
51
barrier = 1;
52
// field load doesn't float higher than here
53
54
for (int j = 0; j < 2000; j++) {
55
array[0] = j; // seen as anti dependence by C2 during loop opts, sunk out of loop
56
res *= j;
57
}
58
}
59
60
return field + res + field * 2;
61
}
62
63
private static int test2(A a, int[] array) {
64
int ignore = a.field;
65
int res = 1;
66
67
int k = 0;
68
for (k = 0; k < 2; k++) {
69
}
70
71
for (int i = 0; i < 10; i++) {
72
barrier = 1;
73
74
for (int j = 0; j < 2000; j++) {
75
test2_helper(array, k, j);
76
res *= j;
77
}
78
}
79
80
return a.field + res + a.field * 2;
81
}
82
83
private static void test2_helper(int[] array, int k, int j) {
84
if (k == 2) {
85
array[0] = j;
86
}
87
}
88
89
private static class A {
90
public int field;
91
}
92
}
93
94