8202747: C2: assert(mode == ControlAroundStripMined && use == sfpt) failed: missed a node

Reviewed-by: neliasso, kvn
This commit is contained in:
Roland Westrelin 2018-06-11 14:16:43 +02:00
parent 0a2bbf0da1
commit ff2c589b63
2 changed files with 99 additions and 1 deletions

View File

@ -1743,6 +1743,23 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new,
}
}
static void clone_outer_loop_helper(Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop,
const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase,
bool check_old_new) {
for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
Node* u = n->fast_out(j);
assert(check_old_new || old_new[u->_idx] == NULL, "shouldn't have been cloned");
if (!u->is_CFG() && (!check_old_new || old_new[u->_idx] == NULL)) {
Node* c = phase->get_ctrl(u);
IdealLoopTree* u_loop = phase->get_loop(c);
assert(!loop->is_member(u_loop), "can be in outer loop or out of both loops only");
if (outer_loop->is_member(u_loop)) {
wq.push(u);
}
}
}
}
void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealLoopTree *loop,
IdealLoopTree* outer_loop, int dd, Node_List &old_new,
Node_List& extra_data_nodes) {
@ -1847,6 +1864,22 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL
_igvn.register_new_node_with_optimizer(new_sfpt);
_igvn.register_new_node_with_optimizer(new_cle_out);
}
// Some other transformation may have pessimistically assign some
// data nodes to the outer loop. Set their control so they are out
// of the outer loop.
ResourceMark rm;
Unique_Node_List wq;
for (uint i = 0; i < extra_data_nodes.size(); i++) {
Node* old = extra_data_nodes.at(i);
clone_outer_loop_helper(old, loop, outer_loop, old_new, wq, this, true);
}
Node* new_ctrl = cl->outer_loop_exit();
assert(get_loop(new_ctrl) != outer_loop, "must be out of the loop nest");
for (uint i = 0; i < wq.size(); i++) {
Node* n = wq.at(i);
set_ctrl(n, new_ctrl);
clone_outer_loop_helper(n, loop, outer_loop, old_new, wq, this, false);
}
} else {
Node *newhead = old_new[loop->_head->_idx];
set_idom(newhead, newhead->in(LoopNode::EntryControl), dd);
@ -1947,7 +1980,7 @@ void PhaseIdealLoop::clone_loop( IdealLoopTree *loop, Node_List &old_new, int dd
}
ResourceArea *area = Thread::current()->resource_area();
Node_List extra_data_nodes(area);
Node_List extra_data_nodes(area); // data nodes in the outer strip mined loop
clone_outer_loop(head, mode, loop, outer_loop, dd, old_new, extra_data_nodes);
// Step 3: Now fix control uses. Loop varying control uses have already

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2018, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8202747
* @summary C2: assert(mode == ControlAroundStripMined && use == sfpt) failed: missed a node
*
* @run main/othervm -Xcomp -Xbatch -XX:CompileOnly=UnexpectedNodeInOuterLoopWhenCloning -XX:-TieredCompilation UnexpectedNodeInOuterLoopWhenCloning
*
*/
public class UnexpectedNodeInOuterLoopWhenCloning {
public static final int N = 400;
public static double dFld=0.37026;
public static int iArrFld[]=new int[N];
public static void vMeth() {
int i5=6, i6=-42538, i7=-209, i8=163, i10=-4, i11=191;
boolean b=true;
double dArr[]=new double[N];
for (i5 = 3; i5 < 245; i5++) {
i7 = 7;
while (--i7 > 0) {
iArrFld[i7] = -11995;
if (b) continue;
}
for (i8 = 1; i8 < 7; ++i8) {
for (i10 = 1; i10 < 2; i10++) {
dFld -= i6;
i11 += i7;
}
}
}
}
public static void main(String[] strArr) {
UnexpectedNodeInOuterLoopWhenCloning _instance = new UnexpectedNodeInOuterLoopWhenCloning();
_instance.vMeth();
}
}