Skip to content

Commit f73037d

Browse files
committed
8286625: C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
Backport-of: 590337e2f229445e353e7c32e0dcff8d93e412d2
1 parent 7f40f16 commit f73037d

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

src/hotspot/share/opto/loopPredicate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "opto/loopnode.hpp"
2727
#include "opto/addnode.hpp"
2828
#include "opto/callnode.hpp"
29+
#include "opto/castnode.hpp"
2930
#include "opto/connode.hpp"
3031
#include "opto/convertnode.hpp"
3132
#include "opto/loopnode.hpp"
@@ -1392,13 +1393,18 @@ ProjNode* PhaseIdealLoop::insert_initial_skeleton_predicate(IfNode* iff, IdealLo
13921393
register_new_node(max_value, new_proj);
13931394
max_value = new AddINode(opaque_init, max_value);
13941395
register_new_node(max_value, new_proj);
1396+
// init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
1397+
max_value = new CastIINode(max_value, loop->_head->as_CountedLoop()->phi()->bottom_type());
1398+
register_new_node(max_value, predicate_proj);
1399+
13951400
bol = rc_predicate(loop, new_proj, scale, offset, max_value, limit, stride, rng, (stride > 0) != (scale > 0), overflow, negate);
13961401
opaque_bol = new Opaque4Node(C, bol, _igvn.intcon(1));
13971402
C->add_skeleton_predicate_opaq(opaque_bol);
13981403
register_new_node(opaque_bol, new_proj);
13991404
new_proj = create_new_if_for_predicate(predicate_proj, NULL, reason, overflow ? Op_If : iff->Opcode());
14001405
_igvn.replace_input_of(new_proj->in(0), 1, opaque_bol);
14011406
assert(max_value->outcnt() > 0, "should be used");
1407+
assert(skeleton_predicate_has_opaque(new_proj->in(0)->as_If()), "unexpected");
14021408

14031409
return new_proj;
14041410
}

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,8 @@ static bool skeleton_follow_inputs(Node* n, int op) {
13171317
op == Op_MulI ||
13181318
op == Op_SubL ||
13191319
op == Op_SubI ||
1320-
op == Op_ConvI2L);
1320+
op == Op_ConvI2L ||
1321+
op == Op_CastII);
13211322
}
13221323

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2022, 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 8286625
27+
* @key stress
28+
* @summary C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
29+
* @run main/othervm -XX:-BackgroundCompilation -XX:+StressIGVN -XX:StressSeed=4232417824 TestOverUnrolling2
30+
* @run main/othervm -XX:-BackgroundCompilation -XX:+StressIGVN TestOverUnrolling2
31+
*/
32+
33+
public class TestOverUnrolling2 {
34+
public static void main(String[] args) {
35+
final byte[] large = new byte[1000];
36+
final byte[] src = new byte[16];
37+
for (int i = 0; i < 20_000; i++) {
38+
test_helper(large, large);
39+
test(src);
40+
}
41+
}
42+
43+
private static void test(byte[] src) {
44+
byte[] array = new byte[16];
45+
test_helper(src, array);
46+
}
47+
48+
private static void test_helper(byte[] src, byte[] array) {
49+
for (int i = 0; i < src.length; i++) {
50+
array[array.length - 1 - i] = src[i];
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)