Skip to content

Commit a03767c

Browse files
jaskartheme64
authored andcommittedOct 20, 2023
8318049: C2: assert(!failure) failed: Missed optimization opportunity in PhaseIterGVN
Reviewed-by: epeter, thartmann
1 parent 848ecc1 commit a03767c

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed
 

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -1594,17 +1594,18 @@ void PhaseIterGVN::add_users_to_worklist( Node *n ) {
15941594
}
15951595
}
15961596

1597-
// If changed Cast input, notify down for Phi and Sub - both do "uncast"
1597+
// If changed Cast input, notify down for Phi, Sub, and Xor - all do "uncast"
15981598
// Patterns:
15991599
// ConstraintCast+ -> Sub
16001600
// ConstraintCast+ -> Phi
1601+
// ConstraintCast+ -> Xor
16011602
if (use->is_ConstraintCast()) {
1602-
auto push_phi_or_sub_uses_to_worklist = [&](Node* n){
1603-
if (n->is_Phi() || n->is_Sub()) {
1603+
auto push_the_uses_to_worklist = [&](Node* n){
1604+
if (n->is_Phi() || n->is_Sub() || n->Opcode() == Op_XorI || n->Opcode() == Op_XorL) {
16041605
_worklist.push(n);
16051606
}
16061607
};
1607-
ConstraintCastNode::visit_uncasted_uses(use, push_phi_or_sub_uses_to_worklist);
1608+
ConstraintCastNode::visit_uncasted_uses(use, push_the_uses_to_worklist);
16081609
}
16091610
// If changed LShift inputs, check RShift users for useless sign-ext
16101611
if( use_op == Op_LShiftI ) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 8318049
27+
* @summary Test that xor nodes are properly notified when constraint casts change.
28+
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler.c2.TestNotifyCastToXor::test
29+
-XX:+IgnoreUnrecognizedVMOptions -XX:VerifyIterativeGVN=10 compiler.c2.TestNotifyCastToXor
30+
*/
31+
32+
package compiler.c2;
33+
34+
public class TestNotifyCastToXor {
35+
public static long longField = 0L;
36+
37+
public static void test() {
38+
int ind = -15;
39+
40+
ind %= ind;
41+
for (int i = 0; i < 40; ++i) {
42+
int j = 1;
43+
44+
do {
45+
ind ^= (int)longField;
46+
47+
// Dead loop
48+
for (int k = 1; k < 1; k++) {
49+
}
50+
} while (j++ < 10);
51+
}
52+
}
53+
54+
public static void main(String[] args) {
55+
test();
56+
}
57+
}

0 commit comments

Comments
 (0)
Please sign in to comment.