Skip to content

Commit 0c14579

Browse files
rwestreleme64
andcommittedAug 26, 2024
8336830: C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop
Co-authored-by: Emanuel Peter <epeter@openjdk.org> Reviewed-by: thartmann, chagedorn, epeter
1 parent 5671f83 commit 0c14579

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed
 

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ void PhaseIdealLoop::try_move_store_after_loop(Node* n) {
10691069
#endif
10701070
lca = place_outside_loop(lca, n_loop);
10711071
assert(!n_loop->is_member(get_loop(lca)), "control must not be back in the loop");
1072-
assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch(), "must not be moved into inner loop");
1072+
assert(get_loop(lca)->_nest < n_loop->_nest || get_loop(lca)->_head->as_Loop()->is_in_infinite_subgraph(), "must not be moved into inner loop");
10731073

10741074
// Move store out of the loop
10751075
_igvn.replace_node(hook, n->in(MemNode::Memory));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2024, 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 8336830
27+
* @summary C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop
28+
* @library /test/lib
29+
* @run main/othervm -XX:CompileCommand=compileonly,TestSunkNodeInInfiniteLoop::* -Xcomp TestSunkNodeInInfiniteLoop
30+
*
31+
*/
32+
33+
import jdk.test.lib.Utils;
34+
35+
public class TestSunkNodeInInfiniteLoop {
36+
public static void main(String[] args) throws InterruptedException {
37+
byte[] a = new byte[1];
38+
Thread thread = new Thread(() -> test(a));
39+
thread.setDaemon(true);
40+
thread.start();
41+
Thread.sleep(Utils.adjustTimeout(4000));
42+
}
43+
44+
static void test(byte[] a) {
45+
// L0:
46+
while(true) {
47+
int i1 = a.length;
48+
// L3:
49+
while(true) {
50+
int i2 = 0;
51+
if ((i1--) <= 0) { break; /* ifle L0 */}
52+
a[i2++] = -1;
53+
// goto L3
54+
}
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)
Failed to load comments.