Skip to content

Commit e389f82

Browse files
committed
8343137: C2: VerifyLoopOptimizations fails with "Was reachable in only one"
Reviewed-by: thartmann, kvn
1 parent 0abfa3b commit e389f82

File tree

5 files changed

+69
-9
lines changed

5 files changed

+69
-9
lines changed

src/hotspot/share/opto/loopnode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4488,7 +4488,9 @@ void PhaseIdealLoop::eliminate_useless_template_assertion_predicates(Unique_Node
44884488
OpaqueTemplateAssertionPredicateNode* opaque_node =
44894489
C->template_assertion_predicate_opaq_node(i - 1)->as_OpaqueTemplateAssertionPredicate();
44904490
if (!useful_predicates.member(opaque_node)) { // not in the useful list
4491-
_igvn.replace_node(opaque_node, _igvn.intcon(1));
4491+
ConINode* one = _igvn.intcon(1);
4492+
set_ctrl(one, C->root());
4493+
_igvn.replace_node(opaque_node, one);
44924494
}
44934495
}
44944496
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2024, 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+
/*
26+
* @test
27+
* @bug 8343137
28+
* @requires vm.debug == true & vm.compiler2.enabled
29+
* @summary Test that set_ctrl() is properly set for true constant when folding useless Template Assertion Predicate.
30+
* @run main/othervm -Xcomp -XX:+VerifyLoopOptimizations
31+
* -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestMissingSetCtrlForTrueConstant::test
32+
* compiler.predicates.assertion.TestMissingSetCtrlForTrueConstant
33+
*/
34+
35+
package compiler.predicates.assertion;
36+
37+
public class TestMissingSetCtrlForTrueConstant {
38+
static long iFld;
39+
static int[] iArrFld = new int[100];
40+
static double[] dArrFld = new double[100];
41+
42+
public static void main(String[] strArr) {
43+
test();
44+
}
45+
46+
static void test() {
47+
long l = 34;
48+
for (int i = 78; i > 8; --i) {
49+
switch (i) {
50+
case 24:
51+
l += iFld - 34;
52+
case 25:
53+
iFld = iArrFld[i] += i;
54+
}
55+
dArrFld[i + 1] += i;
56+
}
57+
}
58+
}

test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateNotRemoved.java renamed to test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateNotRemoved.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* completely with JDK-8288981 and 8314116 just mitigates the problem.
3030
* @requires vm.compiler2.enabled
3131
* @run main/othervm -Xbatch -XX:-TieredCompilation
32-
* -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::*
33-
* compiler.predicates.TestTemplateAssertionPredicateNotRemoved
32+
* -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved::*
33+
* compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved
3434
* @run main/othervm -Xbatch -XX:-TieredCompilation -XX:LoopMaxUnroll=0
35-
* -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::*
36-
* compiler.predicates.TestTemplateAssertionPredicateNotRemoved
35+
* -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved::*
36+
* compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved
3737
*/
3838

39-
package compiler.predicates;
39+
package compiler.predicates.assertion;
4040

4141
public class TestTemplateAssertionPredicateNotRemoved {
4242
static int[] iArrFld = new int[10];

test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateWithTwoUCTs.java renamed to test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateWithTwoUCTs.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
* @bug 8342287
2828
* @summary Test that a fail path projection of a Template Assertion Predicate is not treated as success path projection.
2929
* @run main/othervm -XX:-TieredCompilation -Xbatch
30-
* -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateWithTwoUCTs::test
31-
* compiler.predicates.TestTemplateAssertionPredicateWithTwoUCTs
30+
* -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateWithTwoUCTs::test
31+
* compiler.predicates.assertion.TestTemplateAssertionPredicateWithTwoUCTs
3232
*/
3333

34-
package compiler.predicates;
34+
package compiler.predicates.assertion;
3535

3636
public class TestTemplateAssertionPredicateWithTwoUCTs {
3737
static int iFld;

0 commit comments

Comments
 (0)