Skip to content

Commit

Permalink
8286625: C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) f…
Browse files Browse the repository at this point in the history
…ailed: no node with a side effect

Backport-of: 590337e2f229445e353e7c32e0dcff8d93e412d2
  • Loading branch information
GoeLin committed Jul 3, 2022
1 parent 7f40f16 commit f73037d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/hotspot/share/opto/loopPredicate.cpp
Expand Up @@ -26,6 +26,7 @@
#include "opto/loopnode.hpp"
#include "opto/addnode.hpp"
#include "opto/callnode.hpp"
#include "opto/castnode.hpp"
#include "opto/connode.hpp"
#include "opto/convertnode.hpp"
#include "opto/loopnode.hpp"
Expand Down Expand Up @@ -1392,13 +1393,18 @@ ProjNode* PhaseIdealLoop::insert_initial_skeleton_predicate(IfNode* iff, IdealLo
register_new_node(max_value, new_proj);
max_value = new AddINode(opaque_init, max_value);
register_new_node(max_value, new_proj);
// init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
max_value = new CastIINode(max_value, loop->_head->as_CountedLoop()->phi()->bottom_type());
register_new_node(max_value, predicate_proj);

bol = rc_predicate(loop, new_proj, scale, offset, max_value, limit, stride, rng, (stride > 0) != (scale > 0), overflow, negate);
opaque_bol = new Opaque4Node(C, bol, _igvn.intcon(1));
C->add_skeleton_predicate_opaq(opaque_bol);
register_new_node(opaque_bol, new_proj);
new_proj = create_new_if_for_predicate(predicate_proj, NULL, reason, overflow ? Op_If : iff->Opcode());
_igvn.replace_input_of(new_proj->in(0), 1, opaque_bol);
assert(max_value->outcnt() > 0, "should be used");
assert(skeleton_predicate_has_opaque(new_proj->in(0)->as_If()), "unexpected");

return new_proj;
}
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/opto/loopTransform.cpp
Expand Up @@ -1317,7 +1317,8 @@ static bool skeleton_follow_inputs(Node* n, int op) {
op == Op_MulI ||
op == Op_SubL ||
op == Op_SubI ||
op == Op_ConvI2L);
op == Op_ConvI2L ||
op == Op_CastII);
}

bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
Expand Down Expand Up @@ -2839,6 +2840,9 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
register_new_node(max_value, predicate_proj);
max_value = new AddINode(opaque_init, max_value);
register_new_node(max_value, predicate_proj);
// init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
max_value = new CastIINode(max_value, loop->_head->as_CountedLoop()->phi()->bottom_type());
register_new_node(max_value, predicate_proj);
predicate_proj = add_range_check_predicate(loop, cl, predicate_proj, scale_con, int_offset, int_limit, stride_con, max_value);
assert(skeleton_predicate_has_opaque(predicate_proj->in(0)->as_If()), "unexpected");

Expand Down
53 changes: 53 additions & 0 deletions test/hotspot/jtreg/compiler/loopopts/TestOverUnrolling2.java
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2022, 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 8286625
* @key stress
* @summary C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
* @run main/othervm -XX:-BackgroundCompilation -XX:+StressIGVN -XX:StressSeed=4232417824 TestOverUnrolling2
* @run main/othervm -XX:-BackgroundCompilation -XX:+StressIGVN TestOverUnrolling2
*/

public class TestOverUnrolling2 {
public static void main(String[] args) {
final byte[] large = new byte[1000];
final byte[] src = new byte[16];
for (int i = 0; i < 20_000; i++) {
test_helper(large, large);
test(src);
}
}

private static void test(byte[] src) {
byte[] array = new byte[16];
test_helper(src, array);
}

private static void test_helper(byte[] src, byte[] array) {
for (int i = 0; i < src.length; i++) {
array[array.length - 1 - i] = src[i];
}
}
}

1 comment on commit f73037d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.