Mercurial > hg > graal-jvmci-8
annotate test/compiler/loopopts/TestLoopPeeling.java @ 24110:a8378ff1936d
remove use of cache in jdk.vm.ci.services.Services (GR-3293)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 20 Mar 2017 10:46:02 +0100 |
parents | 535618ab1c04 |
children |
rev | line source |
---|---|
23799
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
1 /* |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
4 * |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
8 * |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
13 * accompanied this code). |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
14 * |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
18 * |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
21 * questions. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
22 */ |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
23 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
24 /* |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
25 * @test |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
26 * @bug 8078262 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
27 * @summary Tests correct dominator information after loop peeling. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
28 * @run main/othervm -Xcomp -XX:CompileCommand=compileonly,TestLoopPeeling::test* TestLoopPeeling |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
29 */ |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
30 public class TestLoopPeeling { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
31 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
32 public int[] array = new int[100]; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
33 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
34 public static void main(String args[]) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
35 TestLoopPeeling test = new TestLoopPeeling(); |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
36 try { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
37 test.testArrayAccess(0, 1); |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
38 test.testArrayAllocation(0, 1); |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
39 } catch (Exception e) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
40 // Ignore exceptions |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
41 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
42 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
43 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
44 public void testArrayAccess(int index, int inc) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
45 int storeIndex = -1; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
46 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
47 for (; index < 10; index += inc) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
48 // This loop invariant check triggers loop peeling because it can |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
49 // be moved out of the loop (see 'IdealLoopTree::policy_peeling'). |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
50 if (inc == 42) return; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
51 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
52 // This loop variant usage of LShiftL( ConvI2L( Phi(storeIndex) ) ) |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
53 // prevents the split if optimization that would otherwise clone the |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
54 // LShiftL and ConvI2L nodes and assign them to their corresponding array |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
55 // address computation (see 'PhaseIdealLoop::split_if_with_blocks_post'). |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
56 if (storeIndex > 0 && array[storeIndex] == 42) return; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
57 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
58 if (index == 42) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
59 // This store and the corresponding range check are moved out of the |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
60 // loop and both used after old loop and the peeled iteration exit. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
61 // For the peeled iteration, storeIndex is always -1 and the ConvI2L |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
62 // is replaced by TOP. However, the range check is not folded because |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
63 // we don't do the split if optimization in PhaseIdealLoop2. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
64 // As a result, we have a (dead) control path from the peeled iteration |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
65 // to the StoreI but the data path is removed. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
66 array[storeIndex] = 1; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
67 return; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
68 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
69 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
70 storeIndex++; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
71 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
72 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
73 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
74 public byte[] testArrayAllocation(int index, int inc) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
75 int allocationCount = -1; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
76 byte[] result; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
77 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
78 for (; index < 10; index += inc) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
79 // This loop invariant check triggers loop peeling because it can |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
80 // be moved out of the loop (see 'IdealLoopTree::policy_peeling'). |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
81 if (inc == 42) return null; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
82 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
83 if (index == 42) { |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
84 // This allocation and the corresponding size check are moved out of the |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
85 // loop and both used after old loop and the peeled iteration exit. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
86 // For the peeled iteration, allocationCount is always -1 and the ConvI2L |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
87 // is replaced by TOP. However, the size check is not folded because |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
88 // we don't do the split if optimization in PhaseIdealLoop2. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
89 // As a result, we have a (dead) control path from the peeled iteration |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
90 // to the allocation but the data path is removed. |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
91 result = new byte[allocationCount]; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
92 return result; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
93 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
94 |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
95 allocationCount++; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
96 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
97 return null; |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
98 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
99 } |
535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
diff
changeset
|
100 |