Mercurial > hg > graal-compiler
annotate test/compiler/rangechecks/TestRangeCheckSmearingLoopOpts.java @ 21472:c190ed6b84bf
added checkcopyrights command (from mxtool2)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 22 May 2015 23:11:17 +0200 |
parents | b6585ac86988 |
children |
rev | line source |
---|---|
20701
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
1 /* |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
4 * |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
8 * |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
13 * accompanied this code). |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
14 * |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
18 * |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
21 * questions. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
22 */ |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
23 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
24 /* |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
25 * @test |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
26 * @bug 8048170 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
27 * @summary Following range check smearing, range check cannot be replaced by dominating identical test. |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
28 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearingLoopOpts |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
29 * |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
30 */ |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
31 public class TestRangeCheckSmearingLoopOpts { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
32 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
33 static int dummy; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
34 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
35 static int m1(int[] array, int i) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
36 for (;;) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
37 for (;;) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
38 if (array[i] < 0) { // range check (i+0) dominates equivalent check below |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
39 break; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
40 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
41 i++; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
42 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
43 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
44 // A control flow that stops IfNode::up_one_dom() |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
45 if ((i % 2)== 0) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
46 if ((array[i] % 2) == 0) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
47 dummy = i; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
48 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
49 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
50 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
51 // IfNode::Ideal will rewrite some range checks if Compile::allow_range_check_smearing |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
52 if (array[i-1] == 9) { // range check (i-1) unchanged |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
53 int res = array[i-3]; // range check (i-3) unchanged |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
54 res += array[i]; // range check (i+0) unchanged |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
55 res += array[i-2]; // removed redundant range check |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
56 // the previous access might be hoisted by |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
57 // PhaseIdealLoop::split_if_with_blocks_post because |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
58 // it appears to have the same guard, but it also |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
59 // depends on the previous guards |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
60 return res; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
61 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
62 i++; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
63 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
64 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
65 |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
66 static public void main(String[] args) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
67 int[] array = { 0, 1, 2, -3, 4, 5, -2, 7, 8, 9, -1 }; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
68 for (int i = 0; i < 20000; i++) { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
69 m1(array, 0); |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
70 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
71 array[0] = -1; |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
72 try { |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
73 m1(array, 0); |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
74 } catch(ArrayIndexOutOfBoundsException aioobe) {} |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
75 } |
b6585ac86988
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
76 } |