Skip to content

Commit fe4f900

Browse files
committed
8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty
Reviewed-by: thartmann, chagedorn
1 parent 8bbebbb commit fe4f900

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3530,7 +3530,7 @@ void IdealLoopTree::enqueue_data_nodes(PhaseIdealLoop* phase, Unique_Node_List&
35303530
void IdealLoopTree::collect_loop_core_nodes(PhaseIdealLoop* phase, Unique_Node_List& wq) const {
35313531
uint before = wq.size();
35323532
wq.push(_head->in(LoopNode::LoopBackControl));
3533-
for (uint i = 0; i < wq.size(); ++i) {
3533+
for (uint i = before; i < wq.size(); ++i) {
35343534
Node* n = wq.at(i);
35353535
for (uint j = 0; j < n->req(); ++j) {
35363536
Node* in = n->in(j);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2023, 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 8315088
27+
* @requires vm.compiler2.enabled
28+
* @summary C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty
29+
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,TestBrokenEmptyLoopLogic::* -XX:-TieredCompilation TestBrokenEmptyLoopLogic
30+
*
31+
*/
32+
33+
public class TestBrokenEmptyLoopLogic {
34+
35+
public static void main(String[] strArr) {
36+
for (int i = 0; i < 10000; i++) {
37+
test();
38+
}
39+
}
40+
41+
static void test() {
42+
int i8 = 209, i = 1, i12 = 1;
43+
while (++i < 8) {
44+
for (int j = 5; j > 1; j -= 2) {
45+
i12 = 1;
46+
do {
47+
} while (++i12 < 3);
48+
}
49+
for (int j = i; j < 5; ++j) {
50+
i8 += i12;
51+
}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)