hotspot/test/compiler/rangechecks/PowerOf2SizedArraysChecks.java
author aeriksso
Thu, 18 Feb 2016 16:15:28 +0100
changeset 36353 28b633a6919d
parent 35756 28e2a0fd6756
child 40059 c2304140ed64
permissions -rw-r--r--
8149743: JVM crash after debugger hotswap with lambdas Reviewed-by: sspitsyn, coleenp, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35756
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     1
/*
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     4
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     7
 * published by the Free Software Foundation.
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     8
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    13
 * accompanied this code).
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    14
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    18
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    21
 * questions.
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    22
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    23
 */
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    24
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    25
/**
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    26
 * @test
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    27
 * @bug 8003585
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    28
 * @summary strength reduce or eliminate range checks for power-of-two sized arrays
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    29
 * @run main/othervm -XX:CompileCommand=compileonly,PowerOf2SizedArraysChecks::test* -XX:-BackgroundCompilation PowerOf2SizedArraysChecks
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    30
 *
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    31
 */
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    32
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    33
import java.util.function.*;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    34
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    35
public class PowerOf2SizedArraysChecks {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    36
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    37
    static void check_result(String name, int x, int m, boolean expected, boolean res) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    38
        if (expected != res) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    39
            throw new RuntimeException("Bad result in " + name + " for x =  " + x + " m = " + m + " expected " + expected  + " got " + res);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    40
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    41
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    42
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    43
    static void helper(String name, BiFunction<Integer, int[], Boolean> test, int[] x_values, int[] m_values, boolean[][] expected) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    44
        for (int i = 0; i < x_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    45
            int x = x_values[i];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    46
            for (int j = 0; j < m_values.length; j++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    47
                int m = m_values[j];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    48
                int[] array = new int[m];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    49
                boolean res = test.apply(x, array);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    50
                check_result(name, x, m, expected[i][j], res);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    51
            }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    52
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    53
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    54
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    55
    static void check_result(String name, int m, boolean expected, boolean res) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    56
        if (expected != res) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    57
            throw new RuntimeException("Bad result in " + name + " for m = " + m + " expected " + expected  + " got " + res);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    58
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    59
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    60
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    61
    static void helper2(String name, Function<int[], Boolean> test, int[] m_values, boolean[] expected) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    62
        for (int j = 0; j < m_values.length; j++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    63
            int m = m_values[j];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    64
            int[] array = new int[m];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    65
            boolean res = test.apply(array);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    66
            check_result(name, m, expected[j], res);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    67
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    68
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    69
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    70
    // ((x & m) u<= m) is always true
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    71
    static boolean test1(int x, int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    72
        int m = array.length;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    73
        if ((x & m) < 0 || (x & m) > m) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    74
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    75
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    76
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    77
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    78
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    79
    // ((x & (m - 1)) u< m) iff (m > 0)
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    80
    static boolean test2(int x, int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    81
        int m = array.length;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    82
        if ((x & (m-1)) < 0 || (x & (m-1)) >= m) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    83
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    84
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    85
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    86
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    87
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    88
    static boolean test3(int x, int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    89
        try {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    90
            int v = array[x & (array.length-1)];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    91
        } catch(ArrayIndexOutOfBoundsException aioobe) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    92
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    93
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    94
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    95
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    96
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    97
    // arraylength <= 0 to arraylength u<= 0
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    98
    static boolean test4(int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
    99
        if (array.length <= 0) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   100
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   101
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   102
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   103
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   104
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   105
    // arraylength == 0 to arraylength u<= 0
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   106
    static boolean test5(int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   107
        if (array.length == 0) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   108
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   109
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   110
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   111
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   112
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   113
    // arraylength != 0 to arraylength u> 0
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   114
    static boolean test6(int[] array) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   115
        if (array.length != 0) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   116
            return false;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   117
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   118
        return true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   119
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   120
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   121
    static public void main(String[] args) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   122
        int[] x_values = {-10, -5, 0, 5, 8, 16, 100};
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   123
        int[] m_values = { 16, 10, 0 };
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   124
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   125
        boolean[][] test1_expected = new boolean[x_values.length][m_values.length];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   126
        for (int i = 0; i < x_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   127
            for (int j = 0; j < m_values.length; j++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   128
                test1_expected[i][j] = true;
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   129
            }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   130
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   131
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   132
        boolean[][] test2_expected = new boolean[x_values.length][m_values.length];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   133
        for (int i = 0; i < x_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   134
            for (int j = 0; j < m_values.length; j++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   135
                test2_expected[i][j] = (m_values[j] > 0);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   136
            }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   137
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   138
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   139
        boolean[] test4_expected = new boolean[m_values.length];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   140
        for (int i = 0; i < m_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   141
            test4_expected[i] = (m_values[i] > 0);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   142
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   143
        boolean[] test5_expected = new boolean[m_values.length];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   144
        for (int i = 0; i < m_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   145
            test5_expected[i] = (m_values[i] != 0);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   146
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   147
        boolean[] test6_expected = new boolean[m_values.length];
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   148
        for (int i = 0; i < m_values.length; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   149
            test6_expected[i] = (m_values[i] == 0);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   150
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   151
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   152
        for (int i = 0; i < 20000; i++) {
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   153
            helper("test1", PowerOf2SizedArraysChecks::test1, x_values, m_values, test1_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   154
            helper("test2", PowerOf2SizedArraysChecks::test2, x_values, m_values, test2_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   155
            helper("test3", PowerOf2SizedArraysChecks::test3, x_values, m_values, test2_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   156
            helper2("test4", PowerOf2SizedArraysChecks::test4, m_values, test4_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   157
            helper2("test5", PowerOf2SizedArraysChecks::test5, m_values, test5_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   158
            helper2("test6", PowerOf2SizedArraysChecks::test6, m_values, test6_expected);
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   159
        }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   160
    }
28e2a0fd6756 8003585: strength reduce or eliminate range checks for power-of-two sized arrays
kmo
parents:
diff changeset
   161
}