author | aeriksso |
Thu, 18 Feb 2016 16:15:28 +0100 | |
changeset 36353 | 28b633a6919d |
parent 28036 | 0365e6e60e1a |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
28036
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
1 |
/* |
0365e6e60e1a
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. |
0365e6e60e1a
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. |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
4 |
* |
0365e6e60e1a
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 |
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
8 |
* |
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0365e6e60e1a
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 |
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
14 |
* |
0365e6e60e1a
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 |
0365e6e60e1a
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, |
0365e6e60e1a
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. |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
18 |
* |
0365e6e60e1a
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 |
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
21 |
* questions. |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
22 |
*/ |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
23 |
|
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
24 |
/* |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
25 |
* @test |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
26 |
* @bug 8048170 |
0365e6e60e1a
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. |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
28 |
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearingLoopOpts |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
29 |
* |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
30 |
*/ |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
31 |
public class TestRangeCheckSmearingLoopOpts { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
32 |
|
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
33 |
static int dummy; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
34 |
|
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
35 |
static int m1(int[] array, int i) { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
36 |
for (;;) { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
37 |
for (;;) { |
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
39 |
break; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
40 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
41 |
i++; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
42 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
43 |
|
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
44 |
// A control flow that stops IfNode::up_one_dom() |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
45 |
if ((i % 2)== 0) { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
46 |
if ((array[i] % 2) == 0) { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
47 |
dummy = i; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
48 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
49 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
50 |
|
0365e6e60e1a
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 |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
52 |
if (array[i-1] == 9) { // range check (i-1) unchanged |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
53 |
int res = array[i-3]; // range check (i-3) unchanged |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
54 |
res += array[i]; // range check (i+0) unchanged |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
55 |
res += array[i-2]; // removed redundant range check |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
56 |
// the previous access might be hoisted by |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
57 |
// PhaseIdealLoop::split_if_with_blocks_post because |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
58 |
// it appears to have the same guard, but it also |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
59 |
// depends on the previous guards |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
60 |
return res; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
61 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
62 |
i++; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
63 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
64 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
65 |
|
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
66 |
static public void main(String[] args) { |
0365e6e60e1a
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 }; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
68 |
for (int i = 0; i < 20000; i++) { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
69 |
m1(array, 0); |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
70 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
71 |
array[0] = -1; |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
72 |
try { |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
73 |
m1(array, 0); |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
74 |
} catch(ArrayIndexOutOfBoundsException aioobe) {} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
75 |
} |
0365e6e60e1a
8048170: Test closed/java/text/Normalizer/ConformanceTest.java failed
roland
parents:
diff
changeset
|
76 |
} |