Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22f8e21

Browse files
committed
8280799: С2: assert(false) failed: cyclic dependency prevents range check elimination
Backport-of: 1ef45c5bbdeb4e1ca65c6d8f3ac1568a6951f3a7
1 parentbf3438c commit22f8e21

File tree

3 files changed

+319
-26
lines changed

3 files changed

+319
-26
lines changed

‎src/hotspot/share/opto/loopnode.cpp‎

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4452,38 +4452,45 @@ void PhaseIdealLoop::build_loop_late_post( Node *n ) {
44524452
}
44534453
assert(early == legal || legal != C->root(),"bad dominance of inputs");
44544454

4455+
if (least != early) {
4456+
// Move the node above predicates as far up as possible so a
4457+
// following pass of loop predication doesn't hoist a predicate
4458+
// that depends on it above that node.
4459+
Node* new_ctrl = least;
4460+
for (;;) {
4461+
if (!new_ctrl->is_Proj()) {
4462+
break;
4463+
}
4464+
CallStaticJavaNode* call = new_ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
4465+
if (call ==NULL) {
4466+
break;
4467+
}
4468+
int req = call->uncommon_trap_request();
4469+
Deoptimization::DeoptReason trap_reason =Deoptimization::trap_request_reason(req);
4470+
if (trap_reason != Deoptimization::Reason_loop_limit_check &&
4471+
trap_reason != Deoptimization::Reason_predicate &&
4472+
trap_reason != Deoptimization::Reason_profile_predicate) {
4473+
break;
4474+
}
4475+
Node* c = new_ctrl->in(0)->in(0);
4476+
if (is_dominator(c, early) && c != early) {
4477+
break;
4478+
}
4479+
new_ctrl = c;
4480+
}
4481+
least = new_ctrl;
4482+
}
44554483
// Try not to place code on a loop entry projection
44564484
// which can inhibit range check elimination.
44574485
if (least != early) {
44584486
Node* ctrl_out = least->unique_ctrl_out();
44594487
if (ctrl_out && ctrl_out->is_Loop() &&
4460-
least == ctrl_out->in(LoopNode::EntryControl)) {
4461-
// Move the node above predicates as far up as possible so a
4462-
// following pass of loop predication doesn't hoist a predicate
4463-
// that depends on it above that node.
4464-
Node* new_ctrl = least;
4465-
for (;;) {
4466-
if (!new_ctrl->is_Proj()) {
4467-
break;
4468-
}
4469-
CallStaticJavaNode* call = new_ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
4470-
if (call ==NULL) {
4471-
break;
4472-
}
4473-
int req = call->uncommon_trap_request();
4474-
Deoptimization::DeoptReason trap_reason =Deoptimization::trap_request_reason(req);
4475-
if (trap_reason != Deoptimization::Reason_loop_limit_check &&
4476-
trap_reason != Deoptimization::Reason_predicate &&
4477-
trap_reason != Deoptimization::Reason_profile_predicate) {
4478-
break;
4479-
}
4480-
Node* c = new_ctrl->in(0)->in(0);
4481-
if (is_dominator(c, early) && c != early) {
4482-
break;
4483-
}
4484-
new_ctrl = c;
4488+
least == ctrl_out->in(LoopNode::EntryControl) &&
4489+
(ctrl_out->is_CountedLoop() || ctrl_out->is_OuterStripMinedLoop())) {
4490+
Node* least_dom =idom(least);
4491+
if (get_loop(least_dom)->is_member(get_loop(least))) {
4492+
least = least_dom;
44854493
}
4486-
least = new_ctrl;
44874494
}
44884495
}
44894496

‎src/hotspot/share/opto/split_if.cpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,24 @@ bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
201201
returntrue;
202202
}
203203
}
204+
if (n->Opcode() == Op_OpaqueLoopStride || n->Opcode() == Op_OpaqueLoopInit) {
205+
Unique_Node_List wq;
206+
wq.push(n);
207+
for (uint i =0; i < wq.size(); i++) {
208+
Node* m = wq.at(i);
209+
if (m->is_If()) {
210+
assert(skeleton_predicate_has_opaque(m->as_If()),"opaque node not reachable from if?");
211+
Node* bol =clone_skeleton_predicate_bool(m,NULL,NULL, m->in(0));
212+
_igvn.replace_input_of(m,1, bol);
213+
}else {
214+
assert(!m->is_CFG(),"not CFG expected");
215+
for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
216+
Node* u = m->fast_out(j);
217+
wq.push(u);
218+
}
219+
}
220+
}
221+
}
204222

205223
// See if splitting-up a Store. Any anti-dep loads must go up as
206224
// well. An anti-dep load might be in the wrong block, because in
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
/*
2+
* Copyright (c) 2022, 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 8280799
27+
* @summary С2: assert(false) failed: cyclic dependency prevents range check elimination
28+
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseCountedLoopSafepoints TestPredicateInputBelowLoopPredicate
29+
*/
30+
31+
publicclassTestPredicateInputBelowLoopPredicate {
32+
privatestaticfinalObjectobject =newObject();
33+
privatestaticintfieldStop =100;
34+
privatestaticint[]array =newint[200];
35+
privatestaticint[]array2 =newint[200];
36+
privatestaticintfieldStart =0;
37+
38+
publicstaticvoidmain(String[]args) {
39+
for (inti =0;i <20_000;i++) {
40+
test(true);
41+
test(false);
42+
}
43+
}
44+
45+
privatestaticvoidtest(booleanflag) {
46+
if (array ==null) {
47+
}
48+
intstart =fieldStart;
49+
inti =start;
50+
for(;;) {
51+
intj;
52+
for (j = -10;j <0;j++) {
53+
}
54+
intstop =fieldStop;
55+
// bound check becomes candidate for predication once
56+
// loop above is optimized out
57+
array[stop -i +j] =0;
58+
59+
// A bunch of stuff to grow loop body size and prevent peeling:
60+
array2[0] =0;
61+
array2[1] =0;
62+
array2[2] =0;
63+
array2[3] =0;
64+
array2[4] =0;
65+
array2[5] =0;
66+
array2[6] =0;
67+
array2[7] =0;
68+
array2[8] =0;
69+
array2[9] =0;
70+
array2[10] =0;
71+
array2[11] =0;
72+
array2[12] =0;
73+
array2[13] =0;
74+
array2[14] =0;
75+
array2[15] =0;
76+
array2[16] =0;
77+
array2[17] =0;
78+
array2[18] =0;
79+
array2[19] =0;
80+
array2[20] =0;
81+
array2[21] =0;
82+
array2[22] =0;
83+
array2[23] =0;
84+
array2[24] =0;
85+
array2[25] =0;
86+
array2[26] =0;
87+
array2[27] =0;
88+
array2[28] =0;
89+
array2[29] =0;
90+
array2[30] =0;
91+
array2[31] =0;
92+
array2[32] =0;
93+
array2[33] =0;
94+
array2[34] =0;
95+
array2[35] =0;
96+
array2[36] =0;
97+
array2[37] =0;
98+
array2[38] =0;
99+
array2[39] =0;
100+
array2[40] =0;
101+
array2[41] =0;
102+
array2[42] =0;
103+
array2[43] =0;
104+
array2[44] =0;
105+
array2[45] =0;
106+
array2[46] =0;
107+
array2[47] =0;
108+
array2[48] =0;
109+
array2[49] =0;
110+
array2[50] =0;
111+
array2[51] =0;
112+
array2[52] =0;
113+
array2[53] =0;
114+
array2[54] =0;
115+
array2[55] =0;
116+
array2[56] =0;
117+
array2[57] =0;
118+
array2[58] =0;
119+
array2[59] =0;
120+
array2[60] =0;
121+
array2[61] =0;
122+
array2[62] =0;
123+
array2[63] =0;
124+
array2[64] =0;
125+
array2[65] =0;
126+
array2[66] =0;
127+
array2[67] =0;
128+
array2[68] =0;
129+
array2[69] =0;
130+
array2[70] =0;
131+
array2[71] =0;
132+
array2[72] =0;
133+
array2[73] =0;
134+
array2[74] =0;
135+
array2[75] =0;
136+
array2[76] =0;
137+
array2[77] =0;
138+
array2[78] =0;
139+
array2[79] =0;
140+
array2[80] =0;
141+
array2[81] =0;
142+
array2[82] =0;
143+
array2[83] =0;
144+
array2[84] =0;
145+
array2[85] =0;
146+
array2[86] =0;
147+
array2[87] =0;
148+
array2[88] =0;
149+
array2[89] =0;
150+
array2[90] =0;
151+
array2[91] =0;
152+
array2[92] =0;
153+
array2[93] =0;
154+
array2[94] =0;
155+
array2[95] =0;
156+
array2[96] =0;
157+
array2[97] =0;
158+
array2[98] =0;
159+
array2[99] =0;
160+
161+
array2[100] =0;
162+
array2[101] =0;
163+
array2[102] =0;
164+
array2[103] =0;
165+
array2[104] =0;
166+
array2[105] =0;
167+
array2[106] =0;
168+
array2[107] =0;
169+
array2[108] =0;
170+
array2[109] =0;
171+
array2[110] =0;
172+
array2[111] =0;
173+
array2[112] =0;
174+
array2[113] =0;
175+
array2[114] =0;
176+
array2[115] =0;
177+
array2[116] =0;
178+
array2[117] =0;
179+
array2[118] =0;
180+
array2[119] =0;
181+
array2[120] =0;
182+
array2[121] =0;
183+
array2[122] =0;
184+
array2[123] =0;
185+
array2[124] =0;
186+
array2[125] =0;
187+
array2[126] =0;
188+
array2[127] =0;
189+
array2[128] =0;
190+
array2[129] =0;
191+
array2[130] =0;
192+
array2[131] =0;
193+
array2[132] =0;
194+
array2[133] =0;
195+
array2[134] =0;
196+
array2[135] =0;
197+
array2[136] =0;
198+
array2[137] =0;
199+
array2[138] =0;
200+
array2[139] =0;
201+
array2[140] =0;
202+
array2[141] =0;
203+
array2[142] =0;
204+
array2[143] =0;
205+
array2[144] =0;
206+
array2[145] =0;
207+
array2[146] =0;
208+
array2[147] =0;
209+
array2[148] =0;
210+
array2[149] =0;
211+
array2[150] =0;
212+
array2[151] =0;
213+
array2[152] =0;
214+
array2[153] =0;
215+
array2[154] =0;
216+
array2[155] =0;
217+
array2[156] =0;
218+
array2[157] =0;
219+
array2[158] =0;
220+
array2[159] =0;
221+
array2[160] =0;
222+
array2[161] =0;
223+
array2[162] =0;
224+
array2[163] =0;
225+
array2[164] =0;
226+
array2[165] =0;
227+
array2[166] =0;
228+
array2[167] =0;
229+
array2[168] =0;
230+
array2[169] =0;
231+
array2[170] =0;
232+
array2[171] =0;
233+
array2[172] =0;
234+
array2[173] =0;
235+
array2[174] =0;
236+
array2[175] =0;
237+
array2[176] =0;
238+
array2[177] =0;
239+
array2[178] =0;
240+
array2[179] =0;
241+
array2[180] =0;
242+
array2[181] =0;
243+
array2[182] =0;
244+
array2[183] =0;
245+
array2[184] =0;
246+
array2[185] =0;
247+
array2[186] =0;
248+
array2[187] =0;
249+
array2[188] =0;
250+
array2[189] =0;
251+
array2[190] =0;
252+
array2[191] =0;
253+
array2[192] =0;
254+
array2[193] =0;
255+
array2[194] =0;
256+
array2[195] =0;
257+
array2[196] =0;
258+
array2[197] =0;
259+
array2[198] =0;
260+
array2[199] =0;
261+
i++;
262+
263+
if (i ==stop) {// requires a loop limit predicate
264+
break;
265+
}
266+
}
267+
}
268+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp