Skip to content

Commit f398cd2

Browse files
committed
8331575: C2: crash when ConvL2I is split thru phi at LongCountedLoop
Reviewed-by: chagedorn, epeter
1 parent 96c5c3f commit f398cd2

File tree

3 files changed

+129
-2
lines changed

3 files changed

+129
-2
lines changed

src/hotspot/share/opto/loopopts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
//------------------------------split_thru_phi---------------------------------
5050
// Split Node 'n' through merge point if there is enough win.
5151
Node* PhaseIdealLoop::split_thru_phi(Node* n, Node* region, int policy) {
52-
if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::LONG) {
53-
// ConvI2L may have type information on it which is unsafe to push up
52+
if ((n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::LONG) ||
53+
(n->Opcode() == Op_ConvL2I && n->bottom_type() != TypeInt::INT)) {
54+
// ConvI2L/ConvL2I may have type information on it which is unsafe to push up
5455
// so disable this for now
5556
return nullptr;
5657
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2024, 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 8331575
27+
* @summary C2: crash when ConvL2I is split thru phi at LongCountedLoop
28+
* @run main/othervm -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement
29+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=92643864 TestLongCountedLoopConvL2I
30+
* @run main/othervm -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement
31+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM TestLongCountedLoopConvL2I
32+
* @run main/othervm -XX:-BackgroundCompilation -XX:-TieredCompilation
33+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM TestLongCountedLoopConvL2I
34+
*/
35+
36+
public class TestLongCountedLoopConvL2I {
37+
private static volatile int volatileField;
38+
39+
public static void main(String[] args) {
40+
for (int i = 0; i < 20_000; i++) {
41+
testHelper1(42);
42+
test1(0);
43+
}
44+
}
45+
46+
private static int test1(int res) {
47+
int k = 1;
48+
for (; k < 2; k *= 2) {
49+
}
50+
long i = testHelper1(k);
51+
for (; i > 0; i--) {
52+
res += 42 / ((int) i);
53+
for (int j = 1; j < 10; j *= 2) {
54+
55+
}
56+
}
57+
return res;
58+
}
59+
60+
private static long testHelper1(int k) {
61+
if (k == 2) {
62+
return 100;
63+
} else {
64+
return 99;
65+
}
66+
}
67+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2024, 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 8331575
27+
* @summary C2: crash when ConvL2I is split thru phi at LongCountedLoop
28+
* @run main/othervm -Xcomp -XX:CompileOnly=TestLongCountedLoopConvL2I2.* TestLongCountedLoopConvL2I2
29+
*/
30+
31+
public class TestLongCountedLoopConvL2I2 {
32+
static int x = 34;
33+
34+
public static void main(String[] strArr) {
35+
for (int i = 0; i < 2; i++) {
36+
test();
37+
}
38+
}
39+
40+
static int test() {
41+
int a = 5, b = 6;
42+
long lArr[] = new long[2];
43+
44+
for (long i = 159; i > 1; i -= 3) {
45+
a += 3;
46+
for (int j = 1; j < 4; j++) {
47+
if (a == 9) {
48+
if (x == 73) {
49+
try {
50+
b = 10 / (int) i;
51+
} catch (ArithmeticException a_e) {
52+
}
53+
}
54+
}
55+
}
56+
}
57+
return b;
58+
}
59+
}

0 commit comments

Comments
 (0)