8272574: C2: assert(false) failed: Bad graph detected in build_loop_late
Co-authored-by: Hui Shi <hshi@openjdk.org> Co-authored-by: Christian Hagedorn <chagedorn@openjdk.org> Reviewed-by: thartmann, chagedorn, kvn
This commit is contained in:
parent
e7ab3724e7
commit
16c3ad1ff4
src/hotspot/share/opto
test/hotspot/jtreg/compiler/loopopts
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. 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
|
||||
@ -621,7 +621,7 @@ class Invariance : public StackObj {
|
||||
// Returns true if the predicate of iff is in "scale*iv + offset u< load_range(ptr)" format
|
||||
// Note: this function is particularly designed for loop predication. We require load_range
|
||||
// and offset to be loop invariant computed on the fly by "invar"
|
||||
bool IdealLoopTree::is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar) const {
|
||||
bool IdealLoopTree::is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar DEBUG_ONLY(COMMA ProjNode *predicate_proj)) const {
|
||||
if (!is_loop_exit(iff)) {
|
||||
return false;
|
||||
}
|
||||
@ -662,6 +662,21 @@ bool IdealLoopTree::is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invari
|
||||
if (offset && !invar.is_invariant(offset)) { // offset must be invariant
|
||||
return false;
|
||||
}
|
||||
#ifdef ASSERT
|
||||
if (offset && phase->has_ctrl(offset)) {
|
||||
Node* offset_ctrl = phase->get_ctrl(offset);
|
||||
if (phase->get_loop(predicate_proj) == phase->get_loop(offset_ctrl) &&
|
||||
phase->is_dominator(predicate_proj, offset_ctrl)) {
|
||||
// If the control of offset is loop predication promoted by previous pass,
|
||||
// then it will lead to cyclic dependency.
|
||||
// Previously promoted loop predication is in the same loop of predication
|
||||
// point.
|
||||
// This situation can occur when pinning nodes too conservatively - can we do better?
|
||||
assert(false, "cyclic dependency prevents range check elimination, idx: offset %d, offset_ctrl %d, predicate_proj %d",
|
||||
offset->_idx, offset_ctrl->_idx, predicate_proj->_idx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1141,7 +1156,7 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree *loop, ProjNode*
|
||||
loop->dump_head();
|
||||
}
|
||||
#endif
|
||||
} else if (cl != NULL && loop->is_range_check_if(iff, this, invar)) {
|
||||
} else if (cl != NULL && loop->is_range_check_if(iff, this, invar DEBUG_ONLY(COMMA predicate_proj))) {
|
||||
// Range check for counted loops
|
||||
const Node* cmp = bol->in(1)->as_Cmp();
|
||||
Node* idx = cmp->in(1);
|
||||
|
@ -737,7 +737,7 @@ public:
|
||||
bool policy_range_check( PhaseIdealLoop *phase ) const;
|
||||
|
||||
// Return TRUE if "iff" is a range check.
|
||||
bool is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar) const;
|
||||
bool is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar DEBUG_ONLY(COMMA ProjNode *predicate_proj)) const;
|
||||
|
||||
// Estimate the number of nodes required when cloning a loop (body).
|
||||
uint est_loop_clone_sz(uint factor) const;
|
||||
|
@ -1626,7 +1626,14 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) {
|
||||
the_clone = x; // Remember for possible deletion.
|
||||
// Alter data node to use pre-phi inputs
|
||||
if (this->in(0) == region) {
|
||||
x->set_req(0, in);
|
||||
if (mem->is_Phi() && (mem->in(0) == region) && mem->in(i)->in(0) != NULL &&
|
||||
MemNode::all_controls_dominate(address, region)) {
|
||||
// Enable other optimizations such as loop predication which does not work
|
||||
// if we directly pin the node to node `in`
|
||||
x->set_req(0, mem->in(i)->in(0)); // Use same control as memory
|
||||
} else {
|
||||
x->set_req(0, in);
|
||||
}
|
||||
} else {
|
||||
x->set_req(0, NULL);
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8272574
|
||||
* @summary Crashes in PhaseIdealLoop::build_loop_late_post_work
|
||||
* @requires vm.compiler2.enabled
|
||||
*
|
||||
* @run main TestLoopPredicateDep
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestLoopPredicateDep {
|
||||
public static void getPermutations(byte[] inputArray, byte[][] outputArray) {
|
||||
int[] indexes = new int[]{0, 2};
|
||||
|
||||
for (int a = 0; a < a + 16; a++) {
|
||||
int oneIdx = indexes[0]++;
|
||||
for (int b = a + 1; b < inputArray.length; b++) {
|
||||
int twoIdx = indexes[1]++;
|
||||
outputArray[twoIdx][0] = inputArray[a];
|
||||
outputArray[twoIdx][1] = inputArray[b];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
final byte[] inputArray = new byte[]{0, 1};
|
||||
final byte[][] outputArray = new byte[3][2];
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
getPermutations(inputArray, outputArray);
|
||||
}
|
||||
}
|
||||
});
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user