Skip to content

Commit 9def453

Browse files
committed
8314580: PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
Reviewed-by: chagedorn, kvn
1 parent 6c821f5 commit 9def453

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

src/hotspot/share/opto/loopnode.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, Node* x, Ideal
770770
// // inner_incr := AddI(inner_phi, intcon(stride))
771771
// inner_incr = inner_phi + stride;
772772
// if (inner_incr < inner_iters_actual) {
773-
// ... use phi=>(outer_phi+inner_phi) and incr=>(outer_phi+inner_incr) ...
773+
// ... use phi=>(outer_phi+inner_phi) ...
774774
// continue;
775775
// }
776776
// else break;
@@ -980,10 +980,6 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) {
980980
// loop iv phi
981981
Node* iv_add = loop_nest_replace_iv(phi, inner_phi, outer_phi, head, bt);
982982

983-
// Replace inner loop long iv incr with inner loop int incr + outer
984-
// loop iv phi
985-
loop_nest_replace_iv(incr, inner_incr, outer_phi, head, bt);
986-
987983
set_subtree_ctrl(inner_iters_actual_int, body_populated);
988984

989985
LoopNode* inner_head = create_inner_head(loop, head, exit_test);
@@ -1032,7 +1028,7 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) {
10321028
// back_control: fallthrough;
10331029
// else
10341030
// inner_exit_branch: break; //exit_branch->clone()
1035-
// ... use phi=>(outer_phi+inner_phi) and incr=>(outer_phi+inner_incr) ...
1031+
// ... use phi=>(outer_phi+inner_phi) ...
10361032
// inner_phi = inner_phi + stride; // inner_incr
10371033
// }
10381034
// outer_exit_test: //exit_test->clone(), in(0):=inner_exit_branch
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2023, 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 8314580
27+
* @summary PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
28+
* @run main/othervm -XX:-BackgroundCompilation TestLongRCWithLoopIncr
29+
*
30+
*/
31+
32+
import java.util.Objects;
33+
34+
public class TestLongRCWithLoopIncr {
35+
public static void main(String[] args) {
36+
for (int i = 0; i < 20_000; i++) {
37+
test(1001);
38+
}
39+
}
40+
41+
private static void test(long length) {
42+
for (long i = 0; i < 1000; i++) {
43+
Objects.checkIndex(i + 1, length);
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)