Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/hotspot/share/opto/phaseX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,18 @@ void PhaseIterGVN::add_users_to_worklist( Node *n ) {
}
}
if (use_op == Op_CmpI) {
// Put If on worklist to enable fold_compares optimization (see IfNode::cmpi_folds)
if (use->outcnt() > 0) {
for (uint i = 0; i < use->outcnt(); i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use->outcnt() > 0 check is redundant and you could use DUIterator_Fast instead of raw_out. Also, bol could have multiple if users. For an example, see code in countedloop_phi_from_cmp.

Node* bol = use->raw_out(i);
if (bol->outcnt() > 0) {
Node* iff = bol->raw_out(0);
if (iff->Opcode() == Op_If && iff->outcnt() == 2) {
add_users_to_worklist0(bol);
}
}
}
}
Node* phi = countedloop_phi_from_cmp((CmpINode*)use, n);
if (phi != NULL) {
// If an opaque node feeds into the limit condition of a
Expand Down
67 changes: 67 additions & 0 deletions test/hotspot/jtreg/compiler/c2/Test8238812.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8238812
* @summary Fix c2 assert(false) failed: bad AD file
* @run main/othervm -XX:CompileCommand=compileonly,compiler.c2.Test8238812::test
* -XX:CompileCommand=dontinline,compiler.c2.Test8238812::test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the dontinline statement is required if we are only compiling that method anyway, right?

* -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:+UseSwitchProfiling
* compiler.c2.Test8238812
*/

package compiler.c2;

public class Test8238812 {

public static void test() {
int i4, i5=99, i6, i9=89;
for (i4 = 12; i4 < 365; i4++) {
for (i6 = 5; i6 > 1; i6--) {
switch ((i6 * 5) + 11) {
case 13:
case 19:
case 26:
case 31:
case 35:
case 41:
case 43:
case 61:
case 71:
case 83:
case 314:
i9 = i5;
break;
}
}
}
}

public static void main(String[] strArr) {
for (int i = 0; i < 10; i++) {
test();
}
}

}