|
| 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 | +/* |
| 26 | + * @test |
| 27 | + * @bug 8317723 |
| 28 | + * @library /test/lib |
| 29 | + * @summary Test that CountedLoopEndNodes and zero trip guard check If nodes are not treated as Runtime Predicates. |
| 30 | + * @run main/othervm -XX:-TieredCompilation -Xbatch |
| 31 | + * -XX:CompileCommand=compileonly,compiler.predicates.TestWrongRuntimePredicateDetection::test* |
| 32 | + * compiler.predicates.TestWrongRuntimePredicateDetection |
| 33 | + */ |
| 34 | + |
| 35 | +package compiler.predicates; |
| 36 | + |
| 37 | +public class TestWrongRuntimePredicateDetection { |
| 38 | + static int[] iArr = new int[50]; |
| 39 | + static long instanceCount; |
| 40 | + static boolean bFld = true; |
| 41 | + static volatile byte byFld; |
| 42 | + static long[][] lArrFld; |
| 43 | + |
| 44 | + |
| 45 | + public static void main(String[] x) { |
| 46 | + for (int i = 0; i < 1000; i++) { |
| 47 | + testCountedLoopEndAsRuntimePredicate(); |
| 48 | + } |
| 49 | + for (int i = 0; i < 10; i++) { |
| 50 | + testZeroTripGuardAsRuntimePredicate(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + static void testCountedLoopEndAsRuntimePredicate() { |
| 55 | + int i22 = 7, i26, i28, i29 = 8, i31 = 1; |
| 56 | + float f4; |
| 57 | + do { |
| 58 | + for (int i = 0; i < 10000; i++) { |
| 59 | + if (bFld) { |
| 60 | + break; |
| 61 | + } |
| 62 | + instanceCount = byFld; |
| 63 | + } |
| 64 | + for (i26 = 4; 80 > i26; i26 += 2) ; |
| 65 | + } while (++i22 < 315); |
| 66 | + i28 = 6; |
| 67 | + while ((i28 -= 3) > 0) { |
| 68 | + for (f4 = i28; f4 < 53; f4++) { |
| 69 | + bFld = false; |
| 70 | + } |
| 71 | + instanceCount = i26; |
| 72 | + do { |
| 73 | + switch ((i26 >>> 1) % 2 * 5 + 6) { |
| 74 | + case 12: |
| 75 | + case 10: |
| 76 | + lArrFld[i31][1] = i29; |
| 77 | + } |
| 78 | + } while (++i31 < 53); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + static void testZeroTripGuardAsRuntimePredicate() { |
| 83 | + int m; |
| 84 | + int a[] = new int[50]; |
| 85 | + for (int j = 0; j < a.length; j++) { |
| 86 | + a[j] = j; |
| 87 | + } |
| 88 | + |
| 89 | + for (int j = 4; j < 42; j++) { |
| 90 | + for (int k = 1; k < 5; k++) { |
| 91 | + iArr[1] = 34; |
| 92 | + switch (j % 4) { |
| 93 | + case 0: |
| 94 | + iArr = iArr; |
| 95 | + case 1: |
| 96 | + case 3: |
| 97 | + m = 3; |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | +} |
0 commit comments