Skip to content

Commit 3e638bf

Browse files
committed
8316361: C2: assert(!failure) failed: Missed optimization opportunity in PhaseIterGVN with -XX:VerifyIterativeGVN=10
Backport-of: eeb63cd0fad9de1f7182ab97d0f25ac67745aa9e
1 parent b48b8e1 commit 3e638bf

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,8 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
23322332
// can edit it's inputs directly. Hammer in the new limit for the
23332333
// minimum-trip guard.
23342334
assert(opaq->outcnt() == 1, "");
2335+
// Notify limit -> opaq -> CmpI, it may constant fold.
2336+
_igvn.add_users_to_worklist(opaq->in(1));
23352337
_igvn.replace_input_of(opaq, 1, new_limit);
23362338
}
23372339

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
24+
/*
25+
* @test
26+
* @bug 8316361
27+
* @summary Test that if input to OpaqueZeroTripGuard changes, we notify down to CmpI.
28+
* @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:VerifyIterativeGVN=10
29+
* -XX:CompileCommand=compileonly,compiler.loopopts.TestNotifyOpaqueZeroTripGuardToCmpI::test
30+
* compiler.loopopts.TestNotifyOpaqueZeroTripGuardToCmpI
31+
*/
32+
package compiler.loopopts;
33+
34+
public class TestNotifyOpaqueZeroTripGuardToCmpI {
35+
static int x, y;
36+
37+
public static void main(String[] strArr) {
38+
test();
39+
}
40+
41+
static void test() {
42+
for (int i = 6; i < 43; i++) {
43+
for (int j = i; j < 11; j++) {
44+
x = y;
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)