test/hotspot/jtreg/compiler/loopstripmining/LoadDependsOnIfIdenticalToLoopExit.java
author xliu
Wed, 04 Sep 2019 16:39:12 +0200
changeset 58006 cf8164854fda
permissions -rw-r--r--
8229450: C2 compilation fails with assert(found_sfpt) failed Reviewed-by: roland, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58006
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     1
/*
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     2
 * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     4
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     8
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    13
 * accompanied this code).
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    14
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    18
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    21
 * questions.
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    22
 */
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    23
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    24
/**
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    25
 * @test
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    26
 * @bug 8229450
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    27
 * @summary shared an identical bool node with a strip-mined loop
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    28
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    29
 * @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:LoopMaxUnroll=0 -XX:CompileCommand=dontinline,LoadDependsOnIfIdenticalToLoopExit::not_inlined -XX:CompileCommand=compileonly,LoadDependsOnIfIdenticalToLoopExit::test1 LoadDependsOnIfIdenticalToLoopExit
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    30
 *
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    31
 */
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    32
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    33
public class LoadDependsOnIfIdenticalToLoopExit {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    34
    public static void main(String[] args) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    35
        for (int i = 0; i < 20_000; i++) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    36
            test1(false, false);
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    37
            test1(true, true);
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    38
        }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    39
    }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    40
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    41
    private static int test1(boolean flag1, boolean flag2) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    42
        int res = 1;
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    43
        int[] array = new int[10];
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    44
        not_inlined(array);
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    45
        int i;
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    46
        for (i = 0; i < 2000; i++) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    47
            res *= i;
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    48
        }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    49
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    50
        if (flag1) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    51
            if (flag2) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    52
                res++;
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    53
            }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    54
        }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    55
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    56
        if (i >= 2000) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    57
            res *= array[0];
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    58
        }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    59
        return res;
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    60
    }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    61
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    62
    private static void not_inlined(int[] array) {
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    63
    }
cf8164854fda 8229450: C2 compilation fails with assert(found_sfpt) failed
xliu
parents:
diff changeset
    64
}