Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit 1a2b122

Browse files
committedMar 4, 2024
8326638: Crash in PhaseIdealLoop::remix_address_expressions due to unexpected Region instead of Loop
Backport-of: 9f0e7da64e21237322e55ca4f0e3639fa5d1c4ed
1 parent aeb85fd commit 1a2b122

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed
 

‎src/hotspot/share/opto/loopopts.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -571,8 +571,8 @@ Node* PhaseIdealLoop::remix_address_expressions(Node* n) {
571571
}
572572

573573
// Replace ((I1 +p V) +p I2) with ((I1 +p I2) +p V),
574-
// but not if I2 is a constant.
575-
if (n_op == Op_AddP) {
574+
// but not if I2 is a constant. Skip for irreducible loops.
575+
if (n_op == Op_AddP && n_loop->_head->is_Loop()) {
576576
if (n2_loop == n_loop && n3_loop != n_loop) {
577577
if (n->in(2)->Opcode() == Op_AddP && !n->in(3)->is_Con()) {
578578
Node* n22_ctrl = get_ctrl(n->in(2)->in(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. 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+
/*
26+
* @test
27+
* @bug 8326638
28+
* @summary Test handling of irreducible loops in PhaseIdealLoop::remix_address_expressions.
29+
* @run main/othervm -XX:-TieredCompilation -Xbatch
30+
* -XX:CompileCommand=compileonly,TestRemixAddressExpressionsWithIrreducibleLoop::test
31+
* TestRemixAddressExpressionsWithIrreducibleLoop
32+
*/
33+
34+
public class TestRemixAddressExpressionsWithIrreducibleLoop {
35+
36+
public static void main(String[] args) {
37+
test("4");
38+
}
39+
40+
public static void test(String arg) {
41+
for (int i = 0; i < 100_000; ++i) {
42+
int j = 0;
43+
while (true) {
44+
boolean tmp = "1\ufff0".startsWith(arg, 2 - arg.length());
45+
if (j++ > 100)
46+
break;
47+
}
48+
loop:
49+
while (i >= 100) {
50+
for (int i2 = 0; i2 < 1; i2 = 1)
51+
if (j > 300)
52+
break loop;
53+
j++;
54+
}
55+
}
56+
}
57+
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Mar 4, 2024

@openjdk-notifier[bot]
This repository has been archived.