Skip to content

Commit cc88f4c

Browse files
committed
8303511: C2: assert(get_ctrl(n) == cle_out) during unrolling
Backport-of: 04eb720d03edc37d7e1cb32c909c31c40485d7a8
1 parent 4dd85cb commit cc88f4c

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed

src/hotspot/share/opto/loopopts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) {
504504
n23_loop == n_loop ) {
505505
Node *add1 = new AddPNode( n->in(1), n->in(2)->in(2), n->in(3) );
506506
// Stuff new AddP in the loop preheader
507-
register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) );
507+
register_new_node( add1, n_loop->_head->as_Loop()->skip_strip_mined(1)->in(LoopNode::EntryControl) );
508508
Node *add2 = new AddPNode( n->in(1), add1, n->in(2)->in(3) );
509509
register_new_node( add2, n_ctrl );
510510
_igvn.replace_node( n, add2 );
@@ -525,7 +525,7 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) {
525525
if (!is_member(n_loop,get_ctrl(I))) {
526526
Node *add1 = new AddPNode(n->in(1), n->in(2), I);
527527
// Stuff new AddP in the loop preheader
528-
register_new_node(add1, n_loop->_head->in(LoopNode::EntryControl));
528+
register_new_node(add1, n_loop->_head->as_Loop()->skip_strip_mined(1)->in(LoopNode::EntryControl));
529529
Node *add2 = new AddPNode(n->in(1), add1, V);
530530
register_new_node(add2, n_ctrl);
531531
_igvn.replace_node(n, add2);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 8303511
27+
* @summary C2: assert(get_ctrl(n) == cle_out) during unrolling
28+
* @requires vm.gc.Parallel
29+
* @run main/othervm -XX:-BackgroundCompilation -XX:+UseParallelGC TestAddPAtOuterLoopHead
30+
*/
31+
32+
33+
import java.util.Arrays;
34+
35+
public class TestAddPAtOuterLoopHead {
36+
public static void main(String[] args) {
37+
boolean[] flags1 = new boolean[1000];
38+
boolean[] flags2 = new boolean[1000];
39+
Arrays.fill(flags2, true);
40+
for (int i = 0; i < 20_000; i++) {
41+
testHelper(42, 42, 43);
42+
test(flags1);
43+
test(flags2);
44+
}
45+
}
46+
47+
private static int test(boolean[] flags) {
48+
int[] array = new int[1000];
49+
50+
int k;
51+
for (k = 0; k < 10; k++) {
52+
for (int i = 0; i < 2; i++) {
53+
}
54+
}
55+
k = k / 10;
56+
int m;
57+
for (m = 0; m < 2; m++) {
58+
for (int i = 0; i < 2; i++) {
59+
for (int j = 0; j < 2; j++) {
60+
}
61+
}
62+
}
63+
64+
65+
int v = 0;
66+
for (int j = 0; j < 2; j++) {
67+
for (int i = 0; i < 998; i += k) {
68+
int l = testHelper(m, j, i);
69+
v = array[i + l];
70+
if (flags[i]) {
71+
return v;
72+
}
73+
}
74+
}
75+
76+
return v;
77+
}
78+
79+
private static int testHelper(int m, int j, int i) {
80+
return m == 2 ? j : i;
81+
}
82+
}

0 commit comments

Comments
 (0)