test/hotspot/jtreg/compiler/loopopts/LoopUnswitchingBadNodeBudget.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57803 23e3ab980622
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55150
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     1
/*
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     4
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     8
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    13
 * accompanied this code).
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    14
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    18
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    21
 * questions.
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    22
 */
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    23
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    24
/*
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    25
 * @test
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    26
 * @bug 8223502
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    27
 * @summary Node estimate for loop unswitching is not correct:
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    28
 *          assert(delta <= 2 * required) failed: Bad node estimate
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    29
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    30
 * @requires !vm.graal.enabled
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    31
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    32
 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    33
 *      -XX:-UseOnStackReplacement -XX:CompileOnly=LoopUnswitchingBadNodeBudget::test
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    34
 *      -XX:CompileCommand=dontinline,LoopUnswitchingBadNodeBudget::helper
57803
23e3ab980622 8229158: make UseSwitchProfiling non-experimental or false by-default
chagedorn
parents: 55150
diff changeset
    35
 *      -XX:+UnlockDiagnosticVMOptions -XX:-UseSwitchProfiling LoopUnswitchingBadNodeBudget
55150
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    36
 *
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    37
 */
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    38
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    39
public class LoopUnswitchingBadNodeBudget {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    40
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    41
    public static void main(String[] args) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    42
        for (int i = 0; i < 20_000; i++) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    43
            for (int j = 0; j < 100; j++) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    44
                test(j, true, 0, 0, 0);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    45
                test(j, false, 0, 0, 0);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    46
            }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    47
        }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    48
    }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    49
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    50
    private static int test(int j, boolean flag, int k, int l, int m) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    51
        int res = 0;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    52
        for (int i = 0; i < 24; i++) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    53
            if (flag) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    54
                k = k / 2;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    55
                l = l * 2;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    56
                m = m + 2;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    57
            }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    58
            switch (j) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    59
                case  0: break;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    60
                case  1: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    61
                case  2: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    62
                case  3: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    63
                case  4: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    64
                case  5: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    65
                case  6: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    66
                case  7: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    67
                case  8: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    68
                case  9: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    69
                case 10: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    70
                case 11: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    71
                case 12: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    72
                case 13: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    73
                case 14: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    74
                case 15: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    75
                case 16: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    76
                case 17: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    77
                case 18: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    78
                case 19: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    79
                case 20: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    80
                case 21: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    81
                case 22: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    82
                case 23: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    83
                case 24: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    84
                case 25: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    85
                case 26: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    86
                case 27: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    87
                case 28: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    88
                case 29: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    89
                case 30: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    90
                case 31: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    91
                case 32: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    92
                case 33: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    93
                case 34: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    94
                case 35: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    95
                case 36: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    96
                case 37: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    97
                case 38: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    98
                case 39: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
    99
                case 40: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   100
                case 41: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   101
                case 42: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   102
                case 43: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   103
                case 44: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   104
                case 45: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   105
                case 46: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   106
                case 47: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   107
                case 48: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   108
                case 49: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   109
                case 50: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   110
                case 51: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   111
                case 52: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   112
                case 53: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   113
                case 54: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   114
                case 55: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   115
                case 56: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   116
                case 57: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   117
                case 58: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   118
                case 59: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   119
                case 60: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   120
                case 61: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   121
                case 62: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   122
                case 63: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   123
                case 64: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   124
                case 65: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   125
                case 66: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   126
                case 67: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   127
                case 68: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   128
                case 69: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   129
                case 70: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   130
                case 71: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   131
                case 72: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   132
                case 73: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   133
                case 74: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   134
                case 75: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   135
                case 76: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   136
                case 77: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   137
                case 78: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   138
                case 79: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   139
                case 80: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   140
                case 81: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   141
                case 82: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   142
                case 83: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   143
                case 84: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   144
                case 85: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   145
                case 86: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   146
                case 87: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   147
                case 88: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   148
                case 89: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   149
                case 90: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   150
                case 91: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   151
                case 92: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   152
                case 93: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   153
                case 94: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   154
                case 95: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   155
                case 96: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   156
                case 97: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   157
                case 98: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   158
                case 99: return helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   159
            }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   160
            res += helper(j, k, l, m);
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   161
        }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   162
        return res;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   163
    }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   164
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   165
    private static int helper(int j, int k, int l, int m) {
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   166
        return j + k;
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   167
    }
ba171f871932 8223363: Bad node estimate assertion failure
phedlin
parents:
diff changeset
   168
}