test/hotspot/jtreg/compiler/c2/Test6805724.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     4
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     8
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    13
 * accompanied this code).
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    14
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
diff changeset
    21
 * questions.
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    22
 */
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    23
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    24
/**
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    25
 * @test
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    26
 * @bug 6805724
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    27
 * @summary ModLNode::Ideal() generates functionally incorrect graph
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    28
 *          when divisor is any (2^k-1) constant.
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 33187
diff changeset
    29
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    30
 * @library /test/lib
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    31
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    32
 * @run main/othervm -Xcomp
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *      -XX:CompileCommand=compileonly,compiler.c2.Test6805724::fcomp
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    34
 *      compiler.c2.Test6805724
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    35
 */
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    36
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    38
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    39
import jdk.test.lib.Utils;
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    40
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    41
public class Test6805724 implements Runnable {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    42
    // Initialize DIVISOR so that it is final in this class.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    43
    static final long DIVISOR;  // 2^k-1 constant
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    44
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    45
    static {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    46
        long value = 0;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    47
        try {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    48
            value = Long.decode(System.getProperty("divisor"));
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    49
        } catch (Throwable t) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    50
            // This one is required for the Class.forName() in main.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    51
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    52
        DIVISOR = value;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    53
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    54
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    55
    static long fint(long x) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    56
        return x % DIVISOR;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    57
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    58
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    59
    static long fcomp(long x) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    60
        return x % DIVISOR;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    61
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    62
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    63
    public void run() {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    64
        long a = 0x617981E1L;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    65
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    66
        long expected = fint(a);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    67
        long result = fcomp(a);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    68
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    69
        if (result != expected)
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    70
            throw new InternalError(result + " != " + expected);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    71
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    72
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    73
    public static void main(String args[]) throws Exception {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    74
        Class cl = Test6805724.class;
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    75
        ClassLoader apploader = cl.getClassLoader();
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    76
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    77
        // Iterate over all 2^k-1 divisors.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    78
        for (int k = 1; k < Long.SIZE; k++) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    79
            long divisor = (1L << k) - 1;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    80
            System.setProperty("divisor", "" + divisor);
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    81
            ClassLoader loader
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    82
                    = Utils.getTestClassPathURLClassLoader(apploader.getParent());
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    83
            Class c = loader.loadClass(Test6805724.class.getName());
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    84
            Runnable r = (Runnable) c.newInstance();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    85
            r.run();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    86
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    87
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    88
}