Skip to content

Commit c3695c7

Browse files
martinuyRealCLanger
authored andcommitted
8303466: C2: failed: malformed control flow. Limit type made precise with MaxL/MinL
Reviewed-by: roland Backport-of: cc894d849aa5f730d5a806acfc7a237cf5170af1
1 parent 3189704 commit c3695c7

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2023, 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 id=test1
26+
* @bug 8298935
27+
* @summary CMoveI for underflow protection of the limit did not compute a type that was precise enough.
28+
* This lead to dead data but zero-trip-guard control did not die -> "malformed control flow".
29+
* @requires vm.compiler2.enabled
30+
* @run main/othervm
31+
* -XX:CompileCommand=compileonly,compiler.loopopts.TestUnrollLimitPreciseType::test1
32+
* -XX:CompileCommand=dontinline,compiler.loopopts.TestUnrollLimitPreciseType::*
33+
* -XX:MaxVectorSize=64
34+
* -Xcomp
35+
* -XX:+UnlockExperimentalVMOptions -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0
36+
* compiler.loopopts.TestUnrollLimitPreciseType test1
37+
*/
38+
39+
/*
40+
* @test id=test2
41+
* @bug 8298935
42+
* @summary CMoveI for underflow protection of the limit did not compute a type that was precise enough.
43+
* This lead to dead data but zero-trip-guard control did not die -> "malformed control flow".
44+
* @requires vm.compiler2.enabled
45+
* @run main/othervm
46+
* -XX:CompileCommand=compileonly,compiler.loopopts.TestUnrollLimitPreciseType::*
47+
* -Xcomp
48+
* compiler.loopopts.TestUnrollLimitPreciseType test2
49+
*/
50+
51+
52+
package compiler.loopopts;
53+
54+
public class TestUnrollLimitPreciseType {
55+
static final int RANGE = 512;
56+
57+
public static void main(String args[]) {
58+
if (args.length != 1) {
59+
throw new RuntimeException("Need exactly one argument.");
60+
}
61+
if (args[0].equals("test1")) {
62+
byte[] data = new byte[RANGE];
63+
test1(data);
64+
} else if (args[0].equals("test2")) {
65+
test2();
66+
} else {
67+
throw new RuntimeException("Do not have: " + args[0]);
68+
}
69+
}
70+
71+
public static void test1(byte[] data) {
72+
// Did not fully analyze this. But it is also unrolled, SuperWorded,
73+
// and further unrolled with vectorlized post loop.
74+
// Only seems to reproduce with avx512, and not with avx2.
75+
for (int j = 192; j < RANGE; j++) {
76+
data[j - 192] = (byte)(data[j] * 11);
77+
}
78+
}
79+
80+
static void test2() {
81+
// Loop is SuperWord'ed.
82+
// We unroll more afterwards, and so add vectorized post loop.
83+
// But it turns out that the vectorized post loop is never entered.
84+
// This lead to assert, because the zero-trip-guard did not collaspse,
85+
// but the CastII with the trip count did die.
86+
// Only seems to reproduce with avx512, and not with avx2.
87+
double dArr[][] = new double[100][100];
88+
for (int i = 2, j = 2; j < 68; j++) {
89+
dArr[i][j] = 8;
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)