|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Arm Limited. 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 8289954 |
| 27 | + * @summary C2: Assert failed in PhaseCFG::verify() after JDK-8183390 |
| 28 | + * |
| 29 | + * @run main/othervm -Xcomp -Xbatch |
| 30 | + * -XX:CompileOnly=compiler/loopopts/TestUnreachableInnerLoop |
| 31 | + * compiler.loopopts.TestUnreachableInnerLoop |
| 32 | + */ |
| 33 | + |
| 34 | +package compiler.loopopts; |
| 35 | + |
| 36 | +public class TestUnreachableInnerLoop { |
| 37 | + |
| 38 | + public static int field = 0; |
| 39 | + public static int arr[] = new int[500]; |
| 40 | + |
| 41 | + public static void fun() { |
| 42 | + for (int elem : arr) { |
| 43 | + int x = 1, y = 2, z = 3; |
| 44 | + int i, j; |
| 45 | + |
| 46 | + // This is a good loop |
| 47 | + for (i = 2; i < 63; i++) { |
| 48 | + arr[i] = arr[i] + 3592870; |
| 49 | + } |
| 50 | + |
| 51 | + // The inner loop looks quite complex but it's unreachable |
| 52 | + // code as loop condition "k < 2" never satisfies |
| 53 | + for (j = 3; j < 63; j++) { |
| 54 | + for (int k = j; k < 2; k++) { |
| 55 | + arr[j] <<= k; |
| 56 | + try { |
| 57 | + x = k / i; |
| 58 | + y = j % 6; |
| 59 | + arr[k] = 88 % elem; |
| 60 | + } catch (ArithmeticException ex) {} |
| 61 | + switch (2) { |
| 62 | + case 2: { |
| 63 | + try { |
| 64 | + y = arr[j] % y; |
| 65 | + z = x / 2345; |
| 66 | + elem = j % -2; |
| 67 | + } catch (ArithmeticException ex) {} |
| 68 | + break; |
| 69 | + } |
| 70 | + case 3: { |
| 71 | + y = arr[j] / 2; |
| 72 | + z -= k; |
| 73 | + break; |
| 74 | + } |
| 75 | + } |
| 76 | + arr[100] -= j; |
| 77 | + field += k; |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + public static void main(String[] args) { |
| 84 | + fun(); |
| 85 | + } |
| 86 | +} |
0 commit comments