Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.
/ jdk17 Public archive

Commit 578c55b

Browse files
committed
8267399: C2: java/text/Normalizer/ConformanceTest.java test failed with assertion
Reviewed-by: kvn, neliasso
1 parent 8fa2520 commit 578c55b

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,16 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
28512851
register_new_node(main_cmp, main_cle->in(0));
28522852
_igvn.replace_input_of(main_bol, 1, main_cmp);
28532853
}
2854+
assert(main_limit == cl->limit() || get_ctrl(main_limit) == pre_ctrl, "wrong control for added limit");
2855+
const TypeInt* orig_limit_t = _igvn.type(orig_limit)->is_int();
2856+
bool upward = cl->stride_con() > 0;
2857+
// The new loop limit is <= (for an upward loop) >= (for a downward loop) than the orig limit.
2858+
// The expression that computes the new limit may be too complicated and the computed type of the new limit
2859+
// may be too pessimistic. A CastII here guarantees it's not lost.
2860+
main_limit = new CastIINode(main_limit, TypeInt::make(upward ? min_jint : orig_limit_t->_lo,
2861+
upward ? orig_limit_t->_hi : max_jint, Type::WidenMax));
2862+
main_limit->init_req(0, pre_ctrl);
2863+
register_new_node(main_limit, pre_ctrl);
28542864
// Hack the now-private loop bounds
28552865
_igvn.replace_input_of(main_cmp, 2, main_limit);
28562866
// The OpaqueNode is unshared by design
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2021, 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 8267399
27+
* @summary C2: java/text/Normalizer/ConformanceTest.java test failed with assertion
28+
*
29+
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestDeadCountedLoop
30+
*
31+
*/
32+
33+
public class TestDeadCountedLoop {
34+
public static void main(String[] args) {
35+
for (int i = 0; i < 20_000; i++) {
36+
test(true, new int[10], false, 0, 1);
37+
test(false, new int[10], false, 0, 1);
38+
}
39+
}
40+
41+
private static int test(boolean flag, int[] array2, boolean flag2, int start, int stop) {
42+
if (array2 == null) {
43+
}
44+
int[] array;
45+
if (flag) {
46+
array = new int[1];
47+
} else {
48+
array = new int[2];
49+
}
50+
int len = array.length;
51+
int v = 1;
52+
for (int j = start; j < stop; j++) {
53+
for (int i = 0; i < len; i++) {
54+
if (i > 0) {
55+
if (flag2) {
56+
break;
57+
}
58+
v *= array2[i + j];
59+
}
60+
}
61+
}
62+
63+
return v;
64+
}
65+
}

0 commit comments

Comments
 (0)