hotspot/test/compiler/6805724/Test6805724.java
author ccheung
Fri, 04 Oct 2013 21:00:43 -0700
changeset 20384 49bfb2ec8f8f
parent 5547 f4b087cbb361
permissions -rw-r--r--
Merge
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
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
diff changeset
     2
 * Copyright (c) 2009, 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
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    27
 * @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    28
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    29
 * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    30
 */
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    31
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    32
import java.net.URLClassLoader;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    33
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    34
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
    35
    // 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
    36
    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
    37
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    38
    static {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    39
        long value = 0;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    40
        try {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    41
            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
    42
        } catch (Throwable t) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    43
            // 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
    44
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    45
        DIVISOR = value;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    46
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    47
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    48
    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
    49
        return x % DIVISOR;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    50
    }
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
    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
    53
        return x % DIVISOR;
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
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    56
    public void run() {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    57
        long a = 0x617981E1L;
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
        long expected = fint(a);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    60
        long result = fcomp(a);
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
        if (result != expected)
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    63
            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
    64
    }
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
    public static void main(String args[]) throws Exception {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    67
        Class cl = Class.forName("Test6805724");
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    68
        URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    69
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    70
        // 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
    71
        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
    72
            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
    73
            System.setProperty("divisor", "" + divisor);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    74
            ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    75
            Class c = loader.loadClass("Test6805724");
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    76
            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
    77
            r.run();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    78
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    79
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    80
}