568N/A/*
1472N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
568N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
568N/A *
568N/A * This code is free software; you can redistribute it and/or modify it
568N/A * under the terms of the GNU General Public License version 2 only, as
568N/A * published by the Free Software Foundation.
568N/A *
568N/A * This code is distributed in the hope that it will be useful, but WITHOUT
568N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
568N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
568N/A * version 2 for more details (a copy is included in the LICENSE file that
568N/A * accompanied this code).
568N/A *
568N/A * You should have received a copy of the GNU General Public License version
568N/A * 2 along with this work; if not, write to the Free Software Foundation,
568N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
568N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
568N/A */
568N/A
568N/A/**
568N/A * @test
568N/A * @bug 6805724
568N/A * @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
568N/A *
568N/A * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
568N/A */
568N/A
568N/Aimport java.net.URLClassLoader;
568N/A
568N/Apublic class Test6805724 implements Runnable {
568N/A // Initialize DIVISOR so that it is final in this class.
568N/A static final long DIVISOR; // 2^k-1 constant
568N/A
568N/A static {
568N/A long value = 0;
568N/A try {
568N/A value = Long.decode(System.getProperty("divisor"));
568N/A } catch (Throwable t) {
568N/A // This one is required for the Class.forName() in main.
568N/A }
568N/A DIVISOR = value;
568N/A }
568N/A
568N/A static long fint(long x) {
568N/A return x % DIVISOR;
568N/A }
568N/A
568N/A static long fcomp(long x) {
568N/A return x % DIVISOR;
568N/A }
568N/A
568N/A public void run() {
568N/A long a = 0x617981E1L;
568N/A
568N/A long expected = fint(a);
568N/A long result = fcomp(a);
568N/A
568N/A if (result != expected)
568N/A throw new InternalError(result + " != " + expected);
568N/A }
568N/A
568N/A public static void main(String args[]) throws Exception {
568N/A Class cl = Class.forName("Test6805724");
568N/A URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
568N/A
568N/A // Iterate over all 2^k-1 divisors.
568N/A for (int k = 1; k < Long.SIZE; k++) {
568N/A long divisor = (1L << k) - 1;
568N/A System.setProperty("divisor", "" + divisor);
568N/A ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
568N/A Class c = loader.loadClass("Test6805724");
568N/A Runnable r = (Runnable) c.newInstance();
568N/A r.run();
568N/A }
568N/A }
568N/A}