Skip to content

Commit

Permalink
8314580: PhaseIdealLoop::transform_long_range_checks fails with asser…
Browse files Browse the repository at this point in the history
…t "was tested before"

Backport-of: 9def4538ab5456d689fd289bdef66fd1655773bc
  • Loading branch information
shipilev committed Nov 8, 2023
1 parent b93d884 commit 243142c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/hotspot/share/opto/loopnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, Node* x, Ideal
// // inner_incr := AddI(inner_phi, intcon(stride))
// inner_incr = inner_phi + stride;
// if (inner_incr < inner_iters_actual) {
// ... use phi=>(outer_phi+inner_phi) and incr=>(outer_phi+inner_incr) ...
// ... use phi=>(outer_phi+inner_phi) ...
// continue;
// }
// else break;
Expand Down Expand Up @@ -977,10 +977,6 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) {
// loop iv phi
Node* iv_add = loop_nest_replace_iv(phi, inner_phi, outer_phi, head, bt);

// Replace inner loop long iv incr with inner loop int incr + outer
// loop iv phi
loop_nest_replace_iv(incr, inner_incr, outer_phi, head, bt);

set_subtree_ctrl(inner_iters_actual_int, body_populated);

LoopNode* inner_head = create_inner_head(loop, head, exit_test);
Expand Down Expand Up @@ -1029,7 +1025,7 @@ bool PhaseIdealLoop::create_loop_nest(IdealLoopTree* loop, Node_List &old_new) {
// back_control: fallthrough;
// else
// inner_exit_branch: break; //exit_branch->clone()
// ... use phi=>(outer_phi+inner_phi) and incr=>(outer_phi+inner_incr) ...
// ... use phi=>(outer_phi+inner_phi) ...
// inner_phi = inner_phi + stride; // inner_incr
// }
// outer_exit_test: //exit_test->clone(), in(0):=inner_exit_branch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2023, 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 8314580
* @summary PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
* @run main/othervm -XX:-BackgroundCompilation TestLongRCWithLoopIncr
*
*/

import java.util.Objects;

public class TestLongRCWithLoopIncr {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test(1001);
}
}

private static void test(long length) {
for (long i = 0; i < 1000; i++) {
Objects.checkIndex(i + 1, length);
}
}
}

1 comment on commit 243142c

@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.