|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Alibaba Group Holding 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 | +/** |
| 26 | + * @test |
| 27 | + * @bug 8290432 |
| 28 | + * @summary Unexpected parallel induction variable pattern was recongized |
| 29 | + * |
| 30 | + * @run main/othervm -XX:-TieredCompilation -Xcomp |
| 31 | + * -XX:CompileCommand=compileonly,compiler.c2.TestUnexpectedParallelIV::test |
| 32 | + * -XX:CompileCommand=compileonly,compiler.c2.TestUnexpectedParallelIV::test2 |
| 33 | + * -XX:CompileCommand=quiet |
| 34 | + * -XX:CompileCommand=dontinline,compiler.c2.TestUnexpectedParallelIV::* compiler.c2.TestUnexpectedParallelIV |
| 35 | + */ |
| 36 | + |
| 37 | +package compiler.c2; |
| 38 | + |
| 39 | +public class TestUnexpectedParallelIV { |
| 40 | + |
| 41 | + static boolean bFld; |
| 42 | + |
| 43 | + static int dontInline() { |
| 44 | + return 0; |
| 45 | + } |
| 46 | + |
| 47 | + static int test2(int i1) { |
| 48 | + int i2, i3 = 0, i4, i5 = 0, i6; |
| 49 | + for (i2 = 0; 4 > i2; ++i2) { |
| 50 | + for (i4 = 1; i4 < 5; ++i4) { |
| 51 | + i3 -= --i1; |
| 52 | + i6 = 1; |
| 53 | + while (++i6 < 2) { |
| 54 | + dontInline(); |
| 55 | + if (bFld) { |
| 56 | + i1 = 5; |
| 57 | + } |
| 58 | + } |
| 59 | + if (bFld) { |
| 60 | + break; |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + return i3; |
| 65 | + } |
| 66 | + |
| 67 | + static long test(int val, boolean b) { |
| 68 | + long ret = 0; |
| 69 | + long dArr[] = new long[100]; |
| 70 | + for (int i = 15; 293 > i; ++i) { |
| 71 | + ret = val; |
| 72 | + int j = 1; |
| 73 | + while (++j < 6) { |
| 74 | + int k = (val--); |
| 75 | + for (long l = i; 1 > l; ) { |
| 76 | + if (k != 0) { |
| 77 | + ret += dontInline(); |
| 78 | + } |
| 79 | + } |
| 80 | + if (b) { |
| 81 | + break; |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + return ret; |
| 86 | + } |
| 87 | + |
| 88 | + public static void main(String[] args) { |
| 89 | + for (int i = 0; i < 1000; i++) { |
| 90 | + test(0, false); |
| 91 | + } |
| 92 | + |
| 93 | + test2(5); |
| 94 | + } |
| 95 | +} |
0 commit comments