author | ysuenaga |
Thu, 14 Jun 2018 16:56:58 +0900 | |
changeset 50560 | dafb2cc6ba32 |
parent 50558 | d9936e986e4f |
child 50561 | 5756e8eecb17 |
permissions | -rw-r--r-- |
49487
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
1 |
/* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Red Hat, Inc. All rights reserved. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
4 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
8 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
14 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
18 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
21 |
* questions. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
22 |
*/ |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
23 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
24 |
/** |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
25 |
* @test |
50558
d9936e986e4f
8203915: Induction variable of over-unrolled loop conflicts with range checks
thartmann
parents:
49487
diff
changeset
|
26 |
* @bug 8193130 8203915 |
49487
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
27 |
* @summary Bad graph when unrolled loop bounds conflicts with range checks |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
28 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
29 |
* @run main/othervm IterationSplitPredicateInconsistency |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
30 |
* @run main/othervm -XX:-UseLoopPredicate IterationSplitPredicateInconsistency |
50558
d9936e986e4f
8203915: Induction variable of over-unrolled loop conflicts with range checks
thartmann
parents:
49487
diff
changeset
|
31 |
* @run main/othervm -XX:LoopStripMiningIter=0 IterationSplitPredicateInconsistency |
49487
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
32 |
* |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
33 |
*/ |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
34 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
35 |
public class IterationSplitPredicateInconsistency { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
36 |
static volatile int barrier; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
37 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
38 |
// Pollute profile so loop appears to run for a large number of iterations |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
39 |
static boolean test1_helper(int start, int stop, double[] array1, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
40 |
for (int i = start; i < stop; i++) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
41 |
array1[i] = array2[i]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
42 |
if (i == exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
43 |
return true; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
44 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
45 |
barrier = 0x42; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
46 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
47 |
return false; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
48 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
49 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
50 |
static double[] test1(int start, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
51 |
double[] array1 = new double[10]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
52 |
// Predication moves range checks out of loop and |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
53 |
// pre/main/post loops are created. The main loop is unrolled |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
54 |
// several times to the point where it's never executed but |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
55 |
// compiler can't tell from the loop bounds alone. The lower |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
56 |
// bound of the loop is negative and would cause range checks |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
57 |
// (that were removed from the loop body) to fail. |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
58 |
if (test1_helper(start, 5, array1, array2, exit)) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
59 |
return null; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
60 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
61 |
return array1; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
62 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
63 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
64 |
// Same as above with other combinations of increasing/decreasing |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
65 |
// loops, positive/negative stride |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
66 |
static boolean test2_helper(int start, int stop, double[] array1, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
67 |
for (int i = start-1; i >= stop; i--) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
68 |
array1[i] = array2[i]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
69 |
if (i == exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
70 |
return true; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
71 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
72 |
barrier = 0x42; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
73 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
74 |
return false; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
75 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
76 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
77 |
static double[] test2(int start, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
78 |
double[] array1 = new double[10]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
79 |
if (test2_helper(start, 0, array1, array2, exit)) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
80 |
return null; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
81 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
82 |
return array1; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
83 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
84 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
85 |
static boolean test3_helper(int start, int stop, double[] array1, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
86 |
for (int i = start; i < stop; i++) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
87 |
array1[stop-i-1] = array2[stop-i-1]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
88 |
if (i == exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
89 |
return true; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
90 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
91 |
barrier = 0x42; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
92 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
93 |
return false; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
94 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
95 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
96 |
static double[] test3(int start, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
97 |
double[] array1 = new double[5]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
98 |
if (test3_helper(start, 5, array1, array2, exit)) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
99 |
return null; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
100 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
101 |
return array1; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
102 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
103 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
104 |
static boolean test4_helper(int start, int stop, int from, double[] array1, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
105 |
for (int i = start-1; i >= stop; i--) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
106 |
array1[from-i-1] = array2[from-i-1]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
107 |
if (i == exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
108 |
return true; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
109 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
110 |
barrier = 0x42; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
111 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
112 |
return false; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
113 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
114 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
115 |
static double[] test4(int start, double[] array2, int exit) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
116 |
double[] array1 = new double[5]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
117 |
if (test4_helper(start, 0, 5, array1, array2, exit)) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
118 |
return null; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
119 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
120 |
return array1; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
121 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
122 |
|
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
123 |
public static void main(String[] args) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
124 |
double[] array2 = new double[10]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
125 |
double[] array3 = new double[1000]; |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
126 |
for (int i = 0; i < 20_000; i++) { |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
127 |
test1_helper(0, 1000, array3, array3, 998); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
128 |
test1(0, array2, 999); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
129 |
test1(0, array2, 4); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
130 |
test2_helper(1000, 0, array3, array3, 1); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
131 |
test2(5, array2, 999); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
132 |
test2(5, array2, 1); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
133 |
test3_helper(0, 1000, array3, array3, 998); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
134 |
test3(0, array2, 999); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
135 |
test3(0, array2, 4); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
136 |
test4_helper(1000, 0, 1000, array3, array3, 1); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
137 |
test4(5, array2, 999); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
138 |
test4(5, array2, 1); |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
139 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
140 |
} |
bde392011cd8
8193130: Bad graph when unrolled loop bounds conflicts with range checks
roland
parents:
diff
changeset
|
141 |
} |