Skip to content

Commit 4631f4a

Browse files
committed
8275854: C2: assert(stride_con != 0) failed: missed some peephole opt
Backport-of: aea096770e74b9c0e1556467705ffdd6cf843d9d
1 parent 4017351 commit 4631f4a

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

src/hotspot/share/opto/ifnode.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,16 @@ Node* IfProjNode::Identity(PhaseGVN* phase) {
17211721
// will cause this node to be reprocessed once the dead branch is killed.
17221722
in(0)->outcnt() == 1))) {
17231723
// IfNode control
1724+
if (in(0)->is_BaseCountedLoopEnd()) {
1725+
// CountedLoopEndNode may be eliminated by if subsuming, replace CountedLoopNode with LoopNode to
1726+
// avoid mismatching between CountedLoopNode and CountedLoopEndNode in the following optimization.
1727+
Node* head = unique_ctrl_out();
1728+
if (head != NULL && head->is_BaseCountedLoop() && head->in(LoopNode::LoopBackControl) == this) {
1729+
Node* new_head = new LoopNode(head->in(LoopNode::EntryControl), this);
1730+
phase->is_IterGVN()->register_new_node_with_optimizer(new_head);
1731+
phase->is_IterGVN()->replace_node(head, new_head);
1732+
}
1733+
}
17241734
return in(0)->in(0);
17251735
}
17261736
// no progress
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8275854
27+
* @summary Crashes in PhaseIdealLoop::transform_long_counted_loop
28+
* @requires vm.compiler2.enabled
29+
*
30+
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,TestLoopEndNodeEliminate::lMeth TestLoopEndNodeEliminate
31+
*
32+
*/
33+
34+
public class TestLoopEndNodeEliminate {
35+
public volatile boolean bFld=true;
36+
public volatile byte byFld=0;
37+
public volatile short sArrFld[]=new short[N];
38+
public int iArrFld[]=new int[N];
39+
public boolean bArrFld[]=new boolean[N];
40+
41+
public static int iFld=10;
42+
public static final int N = 400;
43+
public static long instanceCount=0L;
44+
public static long lMeth_check_sum = 0;
45+
46+
public long lMeth() {
47+
long l1=-33582180L;
48+
int i14=-5, i15=-14, i16=0, i17=25699, i18=97, i19=-3, i20=0, i21=0, i22=42, i23=0, i24=25699, i25=97;
49+
50+
for (l1 = 286; l1 > 16; l1 -= 3) {
51+
for (i15 = 17; i15 > l1; --i15) {
52+
switch (((iArrFld[i15] >>> 1) % 7) + 101) {
53+
case 101:
54+
case 102:
55+
case 103:
56+
case 104:
57+
for (i17 = (int)(l1); i17 < 1; i17++) {
58+
bArrFld[i17] = bFld;
59+
}
60+
break;
61+
case 105:
62+
case 106:
63+
case 107:
64+
}
65+
}
66+
for (i19 = 1; i19 < 270; ++i19) {
67+
TestLoopEndNodeEliminate.iFld += byFld;
68+
i21 = 1;
69+
while (++i21 < 2) {
70+
bFld = true;
71+
}
72+
for (i22 = 1; 2 > i22; ++i22) {
73+
bFld = true;
74+
}
75+
for (i24 = 1; 2 > i24; ++i24) {
76+
bFld = true;
77+
}
78+
bArrFld[(int)(l1) % N] = bFld;
79+
sArrFld[i19 - 1] ^= (short)(++TestLoopEndNodeEliminate.instanceCount);
80+
}
81+
}
82+
long meth_res = l1 + i14 + i15 + i16 + i17 + i18 + i19 + i20 + i21 + i22 + i23 + i24 + i25;
83+
lMeth_check_sum += meth_res;
84+
return (long)meth_res;
85+
}
86+
87+
public static void main(String[] strArr) {
88+
TestLoopEndNodeEliminate _instance = new TestLoopEndNodeEliminate();
89+
for (int i = 0; i < 10000; i++ ) {
90+
_instance.lMeth();
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)