hotspot/test/compiler/loopopts/TestOverunrolling.java
author lana
Thu, 23 Feb 2017 17:30:12 +0000
changeset 44011 5eea3031ae7b
parent 40059 c2304140ed64
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40031
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     1
/*
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     4
 *
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     8
 *
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    13
 * accompanied this code).
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    14
 *
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    18
 *
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    21
 * questions.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    22
 */
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    23
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    24
/*
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    25
 * @test
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    26
 * @bug 8159016
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    27
 * @summary Tests correct dominator information after over-unrolling a loop.
40031
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    28
 * @requires vm.gc == "Parallel" | vm.gc == "null"
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    29
 *
40031
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    30
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-TieredCompilation
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    31
 *                   -XX:-UseG1GC -XX:+UseParallelGC
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    32
 *                   compiler.loopopts.TestOverunrolling
40031
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    33
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    34
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    35
package compiler.loopopts;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40031
diff changeset
    36
40031
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    37
public class TestOverunrolling {
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    38
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    39
    public static Object test(int arg) {
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    40
        Object arr[] = new Object[3];
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    41
        int lim = (arg & 3);
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    42
        // The pre loop is executed for one iteration, initializing p[0].
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    43
        // The main loop is unrolled twice, initializing p[1], p[2], p[3] and p[4].
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    44
        // The p[3] and p[4] stores are always out of bounds and removed. However,
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    45
        // C2 is unable to remove the "over-unrolled", dead main loop. As a result,
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    46
        // there is a control path from the main loop to the post loop without a
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    47
        // memory path (because the last store was replaced by TOP). We crash
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    48
        // because we use a memory edge from a non-dominating region.
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    49
        for (int i = 0; i < lim; ++i) {
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    50
            arr[i] = new Object();
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    51
        }
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    52
        // Avoid EA
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    53
        return arr;
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    54
    }
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    55
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    56
    public static void main(String args[]) {
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    57
        for (int i = 0; i < 42; ++i) {
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    58
            test(i);
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    59
        }
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    60
    }
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    61
}
6cc034201dba 8159016: Over-unrolled loop is partially removed
thartmann
parents:
diff changeset
    62