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