Skip to content

Commit 5e678f7

Browse files
committed
8298824: C2 crash: assert(is_Bool()) failed: invalid node class: ConI
Reviewed-by: roland, kvn, thartmann
1 parent ba942c2 commit 5e678f7

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/hotspot/share/opto/subnode.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,8 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
14671467
(_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
14681468
cmp1_op == Op_CMoveI && cmp2->find_int_con(1) == 0) {
14691469
// 0 should be on the true branch
1470-
if (cmp1->in(CMoveNode::IfTrue)->find_int_con(1) == 0 &&
1470+
if (cmp1->in(CMoveNode::Condition)->is_Bool() &&
1471+
cmp1->in(CMoveNode::IfTrue)->find_int_con(1) == 0 &&
14711472
cmp1->in(CMoveNode::IfFalse)->find_int_con(0) != 0) {
14721473
BoolNode* target = cmp1->in(CMoveNode::Condition)->as_Bool();
14731474
return new BoolNode(target->in(1),
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2022, 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 8298824
27+
* @summary Test BoolNode::Ideal() transformation with CMoveINode that has a Con node as condition.
28+
* @run main/othervm -Xcomp -XX:CompileCommand=compileonly,compiler.c2.TestCMoveIConAsBool::test
29+
* compiler.c2.TestCMoveIConAsBool
30+
*/
31+
32+
package compiler.c2;
33+
34+
public class TestCMoveIConAsBool {
35+
static int x;
36+
37+
public static void main(String[] strArr) {
38+
test();
39+
}
40+
41+
static void test() {
42+
int i = 7;
43+
boolean b = false;
44+
float f = 7.135f;
45+
46+
do {
47+
b = i > f | b || x != 7;
48+
}
49+
while (++i < 0);
50+
}
51+
}

0 commit comments

Comments
 (0)