test/hotspot/jtreg/compiler/loopopts/TestStripMinedBackToBackIfs.java
author roland
Tue, 30 Jan 2018 09:08:44 +0100
changeset 48713 efa7f1a283e4
permissions -rw-r--r--
8196296: Lucene test crashes C2 compilation Summary: Prevent merging of back to back ifs if one is a counted loop end. Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48713
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     1
/*
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     2
 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     4
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     8
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    13
 * accompanied this code).
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    14
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    18
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    21
 * questions.
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    22
 */
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    23
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    24
/**
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    25
 * @test
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    26
 * @bug 8196296
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    27
 * @summary Bad graph when unrolled loop bounds conflicts with range checks
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    28
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:LoopUnrollLimit=0 TestStripMinedBackToBackIfs
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    30
 *
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    31
 */
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    32
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    33
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    34
public class TestStripMinedBackToBackIfs {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    35
    public static void main(String[] args) {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    36
        for (int i = 0; i < 20_000; i++) {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    37
            test(100);
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    38
        }
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    39
    }
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    40
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    41
    private static double test(int limit) {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    42
        double v = 1;
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    43
        for (int i = 0; i < limit; i++) {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    44
            v = v * 4;
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    45
            // We don't want this test to be merged with identical
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    46
            // loop end test
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    47
            if (i+1 < limit) {
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    48
                v = v * 2;
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    49
            }
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    50
        }
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    51
        return v;
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    52
    }
efa7f1a283e4 8196296: Lucene test crashes C2 compilation
roland
parents:
diff changeset
    53
}