Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit ddd550a

Browse files
committedMar 1, 2021
8261308: C2: assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed
Reviewed-by: chagedorn, kvn
1 parent 03d888f commit ddd550a

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed
 

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ void IdealLoopTree::compute_trip_count(PhaseIdealLoop* phase) {
124124
jlong limit_con = (stride_con > 0) ? limit_type->_hi : limit_type->_lo;
125125
int stride_m = stride_con - (stride_con > 0 ? 1 : -1);
126126
jlong trip_count = (limit_con - init_con + stride_m)/stride_con;
127-
if (trip_count > 0 && (julong)trip_count < (julong)max_juint) {
127+
// The loop body is always executed at least once even if init >= limit (for stride_con > 0) or
128+
// init <= limit (for stride_con < 0).
129+
trip_count = MAX2(trip_count, (jlong)1);
130+
if (trip_count < (jlong)max_juint) {
128131
if (init_n->is_Con() && limit_n->is_Con()) {
129132
// Set exact trip count.
130133
cl->set_exact_trip_count((uint)trip_count);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 8261308
27+
* @summary C2: assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed
28+
*
29+
* @run main/othervm -Xcomp -XX:CompileOnly=TestCountedLoopZeroIter TestCountedLoopZeroIter
30+
*
31+
*/
32+
33+
34+
public class TestCountedLoopZeroIter {
35+
static int N = 400;
36+
static boolean b;
37+
static long lArrFld[] = new long[N];
38+
static int iArrFld[] = new int[N];
39+
40+
static void test() {
41+
int i19 = 9, i21 = 8;
42+
long l1;
43+
do
44+
if (!b) {
45+
iArrFld[1] /= l1 = 1;
46+
do {
47+
int i22 = 1;
48+
do {
49+
iArrFld[0] = (int)l1;
50+
iArrFld[i22 - 1] = i21;
51+
} while (++i22 < 1);
52+
lArrFld[1] = i21;
53+
} while (++l1 < 145);
54+
}
55+
while (++i19 < 173);
56+
System.out.println();
57+
}
58+
59+
public static void main(String[] strArr) {
60+
for (int i = 0; i < 10; i++) {
61+
test();
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)