11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 6805724
27 * @summary ModLNode::Ideal() generates functionally incorrect graph
28 * when divisor is any (2^k-1) constant.
29 * @modules java.base/jdk.internal.misc
30 * @library /testlibrary
31 * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
32 */
33
34 import jdk.test.lib.Utils;
35
36 public class Test6805724 implements Runnable {
37 // Initialize DIVISOR so that it is final in this class.
38 static final long DIVISOR; // 2^k-1 constant
39
40 static {
41 long value = 0;
42 try {
43 value = Long.decode(System.getProperty("divisor"));
44 } catch (Throwable t) {
45 // This one is required for the Class.forName() in main.
46 }
47 DIVISOR = value;
48 }
49
50 static long fint(long x) {
51 return x % DIVISOR;
52 }
53
54 static long fcomp(long x) {
55 return x % DIVISOR;
56 }
57
58 public void run() {
59 long a = 0x617981E1L;
60
61 long expected = fint(a);
62 long result = fcomp(a);
63
64 if (result != expected)
65 throw new InternalError(result + " != " + expected);
66 }
67
68 public static void main(String args[]) throws Exception {
69 Class cl = Class.forName("Test6805724");
70 ClassLoader apploader = cl.getClassLoader();
71
72 // Iterate over all 2^k-1 divisors.
73 for (int k = 1; k < Long.SIZE; k++) {
74 long divisor = (1L << k) - 1;
75 System.setProperty("divisor", "" + divisor);
76 ClassLoader loader
77 = Utils.getTestClassPathURLClassLoader(apploader.getParent());
78 Class c = loader.loadClass("Test6805724");
79 Runnable r = (Runnable) c.newInstance();
80 r.run();
81 }
82 }
83 }
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 6805724
27 * @summary ModLNode::Ideal() generates functionally incorrect graph
28 * when divisor is any (2^k-1) constant.
29 * @modules java.base/jdk.internal.misc
30 * @library /testlibrary
31 *
32 * @run main/othervm -Xcomp
33 * -XX:CompileCommand=compileonly,compiler.c2.Test6805724::fcomp
34 * compiler.c2.Test6805724
35 */
36
37 package compiler.c2;
38
39 import jdk.test.lib.Utils;
40
41 public class Test6805724 implements Runnable {
42 // Initialize DIVISOR so that it is final in this class.
43 static final long DIVISOR; // 2^k-1 constant
44
45 static {
46 long value = 0;
47 try {
48 value = Long.decode(System.getProperty("divisor"));
49 } catch (Throwable t) {
50 // This one is required for the Class.forName() in main.
51 }
52 DIVISOR = value;
53 }
54
55 static long fint(long x) {
56 return x % DIVISOR;
57 }
58
59 static long fcomp(long x) {
60 return x % DIVISOR;
61 }
62
63 public void run() {
64 long a = 0x617981E1L;
65
66 long expected = fint(a);
67 long result = fcomp(a);
68
69 if (result != expected)
70 throw new InternalError(result + " != " + expected);
71 }
72
73 public static void main(String args[]) throws Exception {
74 Class cl = Test6805724.class;
75 ClassLoader apploader = cl.getClassLoader();
76
77 // Iterate over all 2^k-1 divisors.
78 for (int k = 1; k < Long.SIZE; k++) {
79 long divisor = (1L << k) - 1;
80 System.setProperty("divisor", "" + divisor);
81 ClassLoader loader
82 = Utils.getTestClassPathURLClassLoader(apploader.getParent());
83 Class c = loader.loadClass(Test6805724.class.getName());
84 Runnable r = (Runnable) c.newInstance();
85 r.run();
86 }
87 }
88 }
|