author | thartmann |
Tue, 12 Nov 2019 10:16:04 +0100 | |
changeset 59022 | ff1887930406 |
permissions | -rw-r--r-- |
59022
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
1 |
/* |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
4 |
* |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
8 |
* |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
14 |
* |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
18 |
* |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
21 |
* questions. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
22 |
*/ |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
23 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
24 |
/** |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
25 |
* @test |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
26 |
* @bug 8233529 |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
27 |
* @summary Verify that correct loops are selected when trying to remove main/post. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
28 |
* @run main/othervm -XX:-TieredCompilation -Xbatch |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
29 |
* -XX:CompileCommand=compileonly,compiler.loopopts.TestRemoveMainPostLoops::test |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
30 |
* compiler.loopopts.TestRemoveMainPostLoops |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
31 |
*/ |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
32 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
33 |
package compiler.loopopts; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
34 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
35 |
public class TestRemoveMainPostLoops { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
36 |
static int cnt1 = 0; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
37 |
int cnt2 = 0; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
38 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
39 |
void testCallee() { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
40 |
// (5) Only main and post loops are created (no pre loop -> "PeelMainPost") and main is unrolled. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
41 |
for (int i = 0; i < 100; ++i) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
42 |
// (4) Inner loop is fully unrolled and removed. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
43 |
for (int j = 0; j < 10; ++j) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
44 |
cnt1 += j; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
45 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
46 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
47 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
48 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
49 |
void test() { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
50 |
for (int i = 0; i < 10_000; ++i) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
51 |
// (0) testCallee method is inlined |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
52 |
testCallee(); |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
53 |
cnt2 = 0; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
54 |
// (1) OSR compilation is triggered in this loop. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
55 |
// (2) Pre-/main-/post loops are created. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
56 |
// (3) Main and post loops found empty and removed. |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
57 |
// (6) Pre loop is found empty, attempt to remove main and post loop then incorrectly selects main from (5). |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
58 |
for (int j = 0; j < 10; ++j) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
59 |
cnt2 = cnt1 + j; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
60 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
61 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
62 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
63 |
|
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
64 |
public static void main(String[] strArr) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
65 |
TestRemoveMainPostLoops test = new TestRemoveMainPostLoops(); |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
66 |
for (int i = 0; i < 100; i++) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
67 |
cnt1 = 0; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
68 |
test.cnt2 = 0; |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
69 |
test.test(); |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
70 |
if (cnt1 != 45000000 || test.cnt2 != 45000009) { |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
71 |
throw new RuntimeException("Incorrect result: " + cnt1 + " " + test.cnt2); |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
72 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
73 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
74 |
} |
ff1887930406
8233529: loopTransform.cpp:2984: Error: assert(p_f->Opcode() == Op_IfFalse) failed
thartmann
parents:
diff
changeset
|
75 |
} |