Skip to content

Commit 625690e

Browse files
committed
8263303: C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint
Reviewed-by: roland Backport-of: d4377af
1 parent 977ca31 commit 625690e

File tree

3 files changed

+75
-28
lines changed

3 files changed

+75
-28
lines changed

src/hotspot/share/opto/loopnode.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -978,33 +978,6 @@ void LoopNode::verify_strip_mined(int expect_skeleton) const {
978978
Node* sfpt = outer_le->in(0);
979979
assert(sfpt->Opcode() == Op_SafePoint, "where's the safepoint?");
980980
Node* inner_out = sfpt->in(0);
981-
if (inner_out->outcnt() != 1) {
982-
ResourceMark rm;
983-
Unique_Node_List wq;
984-
985-
for (DUIterator_Fast imax, i = inner_out->fast_outs(imax); i < imax; i++) {
986-
Node* u = inner_out->fast_out(i);
987-
if (u == sfpt) {
988-
continue;
989-
}
990-
wq.clear();
991-
wq.push(u);
992-
bool found_sfpt = false;
993-
for (uint next = 0; next < wq.size() && !found_sfpt; next++) {
994-
Node *n = wq.at(next);
995-
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax && !found_sfpt; i++) {
996-
Node* u = n->fast_out(i);
997-
if (u == sfpt) {
998-
found_sfpt = true;
999-
}
1000-
if (!u->is_CFG()) {
1001-
wq.push(u);
1002-
}
1003-
}
1004-
}
1005-
assert(found_sfpt, "no node in loop that's not input to safepoint");
1006-
}
1007-
}
1008981
CountedLoopEndNode* cle = inner_out->in(0)->as_CountedLoopEnd();
1009982
assert(cle == inner->loopexit_or_null(), "mismatch");
1010983
bool has_skeleton = outer_le->in(1)->bottom_type()->singleton() && outer_le->in(1)->bottom_type()->is_int()->get_con() == 0;

src/hotspot/share/opto/loopopts.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ static void clone_outer_loop_helper(Node* n, const IdealLoopTree *loop, const Id
18511851
Node* u = n->fast_out(j);
18521852
assert(check_old_new || old_new[u->_idx] == NULL, "shouldn't have been cloned");
18531853
if (!u->is_CFG() && (!check_old_new || old_new[u->_idx] == NULL)) {
1854-
Node* c = phase->get_ctrl(u);
1854+
Node* c = u->in(0) != NULL ? u->in(0) : phase->get_ctrl(u);
18551855
IdealLoopTree* u_loop = phase->get_loop(c);
18561856
assert(!loop->is_member(u_loop), "can be in outer loop or out of both loops only");
18571857
if (outer_loop->is_member(u_loop)) {
@@ -1974,11 +1974,20 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL
19741974
Node* old = extra_data_nodes.at(i);
19751975
clone_outer_loop_helper(old, loop, outer_loop, old_new, wq, this, true);
19761976
}
1977+
1978+
Node* inner_out = sfpt->in(0);
1979+
if (inner_out->outcnt() > 1) {
1980+
clone_outer_loop_helper(inner_out, loop, outer_loop, old_new, wq, this, true);
1981+
}
1982+
19771983
Node* new_ctrl = cl->outer_loop_exit();
19781984
assert(get_loop(new_ctrl) != outer_loop, "must be out of the loop nest");
19791985
for (uint i = 0; i < wq.size(); i++) {
19801986
Node* n = wq.at(i);
19811987
set_ctrl(n, new_ctrl);
1988+
if (n->in(0) != NULL) {
1989+
_igvn.replace_input_of(n, 0, new_ctrl);
1990+
}
19821991
clone_outer_loop_helper(n, loop, outer_loop, old_new, wq, this, false);
19831992
}
19841993
} else {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2021, 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 8263303
27+
* @summary C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint
28+
*
29+
* @run main/othervm -XX:-BackgroundCompilation -XX:LoopUnrollLimit=0 TestPinnedUseInOuterLSMUnusedBySfpt
30+
*
31+
*/
32+
33+
public class TestPinnedUseInOuterLSMUnusedBySfpt {
34+
public static void main(String[] args) {
35+
int[] array = new int[10000];
36+
for (int i = 0; i < 20_000; i++) {
37+
test(100, array, 42);
38+
test(100, array, 0);
39+
}
40+
}
41+
42+
private static float test(int stop, int[] array, int val) {
43+
if (array == null) {
44+
}
45+
int j;
46+
for (j = 0; j < 10; j++) {
47+
48+
}
49+
int i;
50+
int v = 0;
51+
float f = 1;
52+
for (i = 0; i < 10000; i++) {
53+
if ((j - 10) * i + val == 42) {
54+
f *= 2;
55+
} else {
56+
f *= 3;
57+
}
58+
v = (j - 10) * array[i];
59+
if (i % 10001 != i) {
60+
return v;
61+
}
62+
}
63+
return v + array[i-1] + f;
64+
}
65+
}

0 commit comments

Comments
 (0)