Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6805724.java
41149 views
/*1* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 680572426* @summary ModLNode::Ideal() generates functionally incorrect graph27* when divisor is any (2^k-1) constant.28* @modules java.base/jdk.internal.misc29* @library /test/lib30*31* @run main/othervm -Xcomp32* -XX:CompileCommand=compileonly,compiler.c2.Test6805724::fcomp33* compiler.c2.Test680572434*/3536package compiler.c2;3738import jdk.test.lib.Utils;3940public class Test6805724 implements Runnable {41// Initialize DIVISOR so that it is final in this class.42static final long DIVISOR; // 2^k-1 constant4344static {45long value = 0;46try {47value = Long.decode(System.getProperty("divisor"));48} catch (Throwable t) {49// This one is required for the Class.forName() in main.50}51DIVISOR = value;52}5354static long fint(long x) {55return x % DIVISOR;56}5758static long fcomp(long x) {59return x % DIVISOR;60}6162public void run() {63long a = 0x617981E1L;6465long expected = fint(a);66long result = fcomp(a);6768if (result != expected)69throw new InternalError(result + " != " + expected);70}7172public static void main(String args[]) throws Exception {73Class cl = Test6805724.class;74ClassLoader apploader = cl.getClassLoader();7576// Iterate over all 2^k-1 divisors.77for (int k = 1; k < Long.SIZE; k++) {78long divisor = (1L << k) - 1;79System.setProperty("divisor", "" + divisor);80ClassLoader loader81= Utils.getTestClassPathURLClassLoader(apploader.getParent());82Class c = loader.loadClass(Test6805724.class.getName());83Runnable r = (Runnable) c.newInstance();84r.run();85}86}87}888990