Skip to content

Commit 5448139

Browse files
committedNov 8, 2021
8271056: C2: "assert(no_dead_loop) failed: dead loop detected" due to cmoving identity
Reviewed-by: kvn, thartmann
1 parent 0395e4e commit 5448139

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed
 

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,12 @@ Node* PhiNode::Identity(PhaseGVN* phase) {
13661366
}
13671367

13681368
int true_path = is_diamond_phi();
1369-
if (true_path != 0) {
1369+
// Delay CMove'ing identity if Ideal has not had the chance to handle unsafe cases, yet.
1370+
if (true_path != 0 && !(phase->is_IterGVN() && wait_for_region_igvn(phase))) {
13701371
Node* id = is_cmove_id(phase, true_path);
1371-
if (id != NULL) return id;
1372+
if (id != NULL) {
1373+
return id;
1374+
}
13721375
}
13731376

13741377
// Looking for phis with identical inputs. If we find one that has
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (c) 2021, 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+
* @key stress randomness
27+
* @bug 8271056
28+
* @summary A dead data loop is created when applying an unsafe case of Cmov'ing identity.
29+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,compiler.c2.TestDeadDataLoopCmoveIdentity::*
30+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=359948366 compiler.c2.TestDeadDataLoopCmoveIdentity
31+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,compiler.c2.TestDeadDataLoopCmoveIdentity::*
32+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN compiler.c2.TestDeadDataLoopCmoveIdentity
33+
*/
34+
35+
package compiler.c2;
36+
37+
public class TestDeadDataLoopCmoveIdentity {
38+
static boolean bFld;
39+
40+
public static void main(String[] strArr) {
41+
test();
42+
test2();
43+
}
44+
45+
static void test() {
46+
int i33 = 51925, iArr3[] = new int[10];
47+
if (bFld) {
48+
;
49+
} else if (bFld) {
50+
for (int i = 0; i < 100; i++) { }
51+
do {
52+
if (i33 != 0) {
53+
}
54+
int i34 = 1;
55+
do {
56+
switch (0) {
57+
case 122: { }
58+
}
59+
} while (i34 < 1);
60+
i33 += i33 + 3;
61+
} while (i33 < 5);
62+
}
63+
}
64+
65+
static void test2() {
66+
int i33 = 51925, iArr3[] = new int[10];
67+
if (bFld) {
68+
;
69+
} else if (bFld) {
70+
do {
71+
if (i33 != 0) {
72+
}
73+
int i34 = 1;
74+
do {
75+
switch (0) {
76+
case 122: {}
77+
}
78+
} while (i34 < 1);
79+
} while (++i33 < 5);
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)
Failed to load comments.