|
| 1 | +/* |
| 2 | + * Copyright (c) 2023, Red Hat, Inc. 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 8303511 |
| 27 | + * @summary C2: assert(get_ctrl(n) == cle_out) during unrolling |
| 28 | + * @requires vm.gc.Parallel |
| 29 | + * @run main/othervm -XX:-BackgroundCompilation -XX:+UseParallelGC TestAddPAtOuterLoopHead |
| 30 | + */ |
| 31 | + |
| 32 | + |
| 33 | +import java.util.Arrays; |
| 34 | + |
| 35 | +public class TestAddPAtOuterLoopHead { |
| 36 | + public static void main(String[] args) { |
| 37 | + boolean[] flags1 = new boolean[1000]; |
| 38 | + boolean[] flags2 = new boolean[1000]; |
| 39 | + Arrays.fill(flags2, true); |
| 40 | + for (int i = 0; i < 20_000; i++) { |
| 41 | + testHelper(42, 42, 43); |
| 42 | + test(flags1); |
| 43 | + test(flags2); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + private static int test(boolean[] flags) { |
| 48 | + int[] array = new int[1000]; |
| 49 | + |
| 50 | + int k; |
| 51 | + for (k = 0; k < 10; k++) { |
| 52 | + for (int i = 0; i < 2; i++) { |
| 53 | + } |
| 54 | + } |
| 55 | + k = k / 10; |
| 56 | + int m; |
| 57 | + for (m = 0; m < 2; m++) { |
| 58 | + for (int i = 0; i < 2; i++) { |
| 59 | + for (int j = 0; j < 2; j++) { |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + |
| 65 | + int v = 0; |
| 66 | + for (int j = 0; j < 2; j++) { |
| 67 | + for (int i = 0; i < 998; i += k) { |
| 68 | + int l = testHelper(m, j, i); |
| 69 | + v = array[i + l]; |
| 70 | + if (flags[i]) { |
| 71 | + return v; |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + return v; |
| 77 | + } |
| 78 | + |
| 79 | + private static int testHelper(int m, int j, int i) { |
| 80 | + return m == 2 ? j : i; |
| 81 | + } |
| 82 | +} |
0 commit comments