Skip to content

Commit 969fcdb

Browse files
author
Quan Anh Mai
committedSep 5, 2023
8314191: C2 compilation fails with "bad AD file"
Reviewed-by: thartmann, chagedorn
1 parent cef9fff commit 969fcdb

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
 

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

+4
Original file line numberDiff line numberDiff line change
@@ -1556,12 +1556,14 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
15561556
// and "cmp (add X min_jint) c" into "cmpu X (c + min_jint)"
15571557
if (cop == Op_CmpI &&
15581558
cmp1_op == Op_AddI &&
1559+
!is_cloop_increment(cmp1) &&
15591560
phase->type(cmp1->in(2)) == TypeInt::MIN) {
15601561
if (cmp2_op == Op_ConI) {
15611562
Node* ncmp2 = phase->intcon(java_add(cmp2->get_int(), min_jint));
15621563
Node* ncmp = phase->transform(new CmpUNode(cmp1->in(1), ncmp2));
15631564
return new BoolNode(ncmp, _test._test);
15641565
} else if (cmp2_op == Op_AddI &&
1566+
!is_cloop_increment(cmp2) &&
15651567
phase->type(cmp2->in(2)) == TypeInt::MIN) {
15661568
Node* ncmp = phase->transform(new CmpUNode(cmp1->in(1), cmp2->in(1)));
15671569
return new BoolNode(ncmp, _test._test);
@@ -1572,12 +1574,14 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
15721574
// and "cmp (add X min_jlong) c" into "cmpu X (c + min_jlong)"
15731575
if (cop == Op_CmpL &&
15741576
cmp1_op == Op_AddL &&
1577+
!is_cloop_increment(cmp1) &&
15751578
phase->type(cmp1->in(2)) == TypeLong::MIN) {
15761579
if (cmp2_op == Op_ConL) {
15771580
Node* ncmp2 = phase->longcon(java_add(cmp2->get_long(), min_jlong));
15781581
Node* ncmp = phase->transform(new CmpULNode(cmp1->in(1), ncmp2));
15791582
return new BoolNode(ncmp, _test._test);
15801583
} else if (cmp2_op == Op_AddL &&
1584+
!is_cloop_increment(cmp2) &&
15811585
phase->type(cmp2->in(2)) == TypeLong::MIN) {
15821586
Node* ncmp = phase->transform(new CmpULNode(cmp1->in(1), cmp2->in(1)));
15831587
return new BoolNode(ncmp, _test._test);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2023, 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+
package compiler.c2;
24+
25+
/*
26+
* @test
27+
* @bug 8314191
28+
* @summary Loop increment should not be transformed into unsigned comparison
29+
*
30+
* @run main/othervm -Xcomp -XX:-TieredCompilation
31+
* -XX:CompileCommand=compileonly,*MinValueStrideCountedLoop::test*
32+
* compiler.c2.MinValueStrideCountedLoop
33+
*/
34+
public class MinValueStrideCountedLoop {
35+
static int limit = 0;
36+
static int res = 0;
37+
38+
static void test() {
39+
for (int i = 0; i >= limit + -2147483647; i += -2147483648) {
40+
res += 42;
41+
}
42+
}
43+
44+
public static void main(String[] args) {
45+
test();
46+
}
47+
}

0 commit comments

Comments
 (0)
Please sign in to comment.