forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8297642: PhaseIdealLoop::only_has_infinite_loops must detect all loop…
…s that never lead to termination Reviewed-by: thartmann, roland
- Loading branch information
Showing
3 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
test/hotspot/jtreg/compiler/loopopts/TestOnlyInfiniteLoops.jasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (c) 2022, 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. | ||
*/ | ||
|
||
|
||
super public class TestOnlyInfiniteLoops | ||
{ | ||
public Method "<init>":"()V" | ||
stack 2 locals 1 | ||
{ | ||
aload_0; | ||
invokespecial Method java/lang/Object."<init>":"()V"; | ||
return; | ||
} | ||
|
||
static Method test_simple:"(III)I" | ||
stack 200 locals 10 | ||
{ | ||
// Nested infinite loop, where inner loop eventually | ||
// looses exit to outer loop. Then, the inner loop | ||
// floats outside the inner loop. The entry from | ||
// outer to inner loop now becomes an exit for the | ||
// outer loop, where it now enters the next loop, that | ||
// used to be the inner loop. | ||
iconst_0; | ||
istore 9; | ||
|
||
iload 0; | ||
ifeq LEND; // skip | ||
|
||
LOOP1: | ||
iload 1; | ||
ifeq LOOP1; // dominates | ||
LOOP2: | ||
// SKIP: prevent loop-exit from becoming zero-trip guard | ||
iload 2; | ||
ifeq SKIP; | ||
iinc 9, 1; | ||
SKIP: | ||
iload 1; | ||
ifeq LOOP1; // is dominated | ||
goto LOOP2; | ||
|
||
LEND: | ||
iload 9; | ||
ireturn; | ||
} | ||
static Method test_irreducible:"(IIII)V" | ||
stack 200 locals 200 | ||
{ | ||
iload_0; | ||
ifeq LEND; // skip | ||
|
||
L1: | ||
iload 1; | ||
ifgt MERGE; | ||
L2: | ||
iload 2; | ||
ifge MERGE; | ||
goto L1; | ||
|
||
MERGE: | ||
nop; | ||
LOOP: | ||
iload 3; | ||
ifle L2; | ||
iconst_0; // always true | ||
ifeq LOOP; | ||
iconst_0; // always true | ||
ifeq LOOP; | ||
INFTY: | ||
goto INFTY; // infinite loop | ||
|
||
LEND: | ||
return; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
test/hotspot/jtreg/compiler/loopopts/TestOnlyInfiniteLoopsMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2022, 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 8297642 | ||
* @compile TestOnlyInfiniteLoops.jasm | ||
* @summary Nested irreducible loops, where the inner loop floats out of the outer | ||
* @run main/othervm | ||
* -XX:CompileCommand=compileonly,TestOnlyInfiniteLoops::test* | ||
* -XX:-TieredCompilation -Xcomp | ||
* TestOnlyInfiniteLoopsMain | ||
* | ||
* @test | ||
* @bug 8297642 | ||
* @compile TestOnlyInfiniteLoops.jasm | ||
* @summary Nested irreducible loops, where the inner loop floats out of the outer | ||
* @run main/othervm | ||
* -XX:CompileCommand=compileonly,TestOnlyInfiniteLoops::test* | ||
* -XX:-TieredCompilation -Xcomp | ||
* -XX:PerMethodTrapLimit=0 | ||
* TestOnlyInfiniteLoopsMain | ||
*/ | ||
|
||
public class TestOnlyInfiniteLoopsMain { | ||
public static void main(String[] args) { | ||
TestOnlyInfiniteLoops t = new TestOnlyInfiniteLoops(); | ||
System.out.println("test_simple"); | ||
t.test_simple(0, 0, 0); | ||
System.out.println("test_irreducible"); | ||
t.test_irreducible(0, 0, 0, 0); | ||
} | ||
} |