Skip to content

Commit 0a92dc7

Browse files
author
Xin Liu
committed
8229450: C2 compilation fails with assert(found_sfpt) failed
Reviewed-by: roland, thartmann
1 parent ea43611 commit 0a92dc7

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

src/hotspot/share/opto/loopopts.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,22 @@ bool PhaseIdealLoop::can_split_if(Node* n_ctrl) {
11911191
return true;
11921192
}
11931193

1194+
// Detect if the node is the inner strip-mined loop
1195+
// Return: NULL if it's not the case, or the exit of outer strip-mined loop
1196+
static Node* is_inner_of_stripmined_loop(const Node* out) {
1197+
Node* out_le = NULL;
1198+
1199+
if (out->is_CountedLoopEnd()) {
1200+
const CountedLoopNode* loop = out->as_CountedLoopEnd()->loopnode();
1201+
1202+
if (loop != NULL && loop->is_strip_mined()) {
1203+
out_le = loop->in(LoopNode::EntryControl)->as_OuterStripMinedLoop()->outer_loop_exit();
1204+
}
1205+
}
1206+
1207+
return out_le;
1208+
}
1209+
11941210
//------------------------------split_if_with_blocks_post----------------------
11951211
// Do the real work in a non-recursive function. CFG hackery wants to be
11961212
// in the post-order, so it can dirty the I-DOM info and not use the dirtied
@@ -1324,6 +1340,15 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) {
13241340
Node *dom = idom(prevdom);
13251341
while (dom != cutoff) {
13261342
if (dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom) {
1343+
// It's invalid to move control dependent data nodes in the inner
1344+
// strip-mined loop, because:
1345+
// 1) break validation of LoopNode::verify_strip_mined()
1346+
// 2) move code with side-effect in strip-mined loop
1347+
// Move to the exit of outer strip-mined loop in that case.
1348+
Node* out_le = is_inner_of_stripmined_loop(dom);
1349+
if (out_le != NULL) {
1350+
prevdom = out_le;
1351+
}
13271352
// Replace the dominated test with an obvious true or false.
13281353
// Place it on the IGVN worklist for later cleanup.
13291354
C->set_major_progress();
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2019, 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 8229450
27+
* @summary shared an identical bool node with a strip-mined loop
28+
*
29+
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:LoopMaxUnroll=0 -XX:CompileCommand=dontinline,LoadDependsOnIfIdenticalToLoopExit::not_inlined -XX:CompileCommand=compileonly,LoadDependsOnIfIdenticalToLoopExit::test1 LoadDependsOnIfIdenticalToLoopExit
30+
*
31+
*/
32+
33+
public class LoadDependsOnIfIdenticalToLoopExit {
34+
public static void main(String[] args) {
35+
for (int i = 0; i < 20_000; i++) {
36+
test1(false, false);
37+
test1(true, true);
38+
}
39+
}
40+
41+
private static int test1(boolean flag1, boolean flag2) {
42+
int res = 1;
43+
int[] array = new int[10];
44+
not_inlined(array);
45+
int i;
46+
for (i = 0; i < 2000; i++) {
47+
res *= i;
48+
}
49+
50+
if (flag1) {
51+
if (flag2) {
52+
res++;
53+
}
54+
}
55+
56+
if (i >= 2000) {
57+
res *= array[0];
58+
}
59+
return res;
60+
}
61+
62+
private static void not_inlined(int[] array) {
63+
}
64+
}

0 commit comments

Comments
 (0)