Skip to content

Commit 053ff76

Browse files
committed
8308660: C2 compilation hits 'node must be dead' assert
Reviewed-by: chagedorn, kvn
1 parent e1b0af2 commit 053ff76

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/hotspot/share/opto/ifnode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,10 @@ bool IfNode::fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* f
10511051
}
10521052
hook->destruct(igvn);
10531053

1054+
if (adjusted_val->is_top() || adjusted_lim->is_top()) {
1055+
return false;
1056+
}
1057+
10541058
if (igvn->type(adjusted_lim)->is_int()->_lo < 0 &&
10551059
!igvn->C->post_loop_opts_phase()) {
10561060
// If range check elimination applies to this comparison, it includes code to protect from overflows that may
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2024, 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 8308660
27+
* @summary C2 compilation hits 'node must be dead' assert
28+
* @requires vm.compiler2.enabled
29+
* @run main/othervm -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement
30+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=242006623 TestFoldIfRemovesTopNode
31+
* @run main/othervm -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement
32+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN TestFoldIfRemovesTopNode
33+
*
34+
*/
35+
36+
public class TestFoldIfRemovesTopNode {
37+
38+
public static void main(String[] args) {
39+
int[] array = new int[100];
40+
for (int i = 0; i < 20_000; i++) {
41+
test(false, true, 0, array);
42+
test(false, false, 0, array);
43+
testHelper2(false, false, 0, array);
44+
testHelper(0, true, array);
45+
}
46+
}
47+
48+
private static void test(boolean flag, boolean flag2, int k, int[] array) {
49+
if (flag2) {
50+
testHelper2(flag, flag2, k, array);
51+
}
52+
}
53+
54+
private static void testHelper2(boolean flag, boolean flag2, int k, int[] array) {
55+
if (flag2) {
56+
k = -1;
57+
}
58+
testHelper(k, flag, array);
59+
}
60+
61+
private static void testHelper(int k, boolean flag, int[] array) {
62+
if (flag) {
63+
k = new int[k].length;
64+
int j = k + 3;
65+
if (j >= 0 && j <= array.length) {
66+
}
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)