1 /*
2 * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24 /**
25 * @test
26 * @bug 6800154
27 * @summary Add comments to long_by_long_mulhi() for better understandability
28 *
29 * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
30 */
31
32 public class Test6800154 {
33 public static void main(String[] args)
34 {
35 div(0);
36 div(1);
37 div(1423487);
38 div(4444441);
39 div(4918923241323L);
40 div(-1);
41 div(-24351);
42 div(0x3333);
43 div(0x0000000080000000L);
44 div(0x7fffffffffffffffL);
45 div(0x8000000000000000L);
46 }
47
48 static final int N = 11;
49
50 static final long DIV1 = 2;
51 static final long DIV2 = 17;
52 static final long DIV3 = 24123;
53 static final long DIV4 = -4423423234231423L;
54 static final long DIV5 = -1;
55 static final long DIV6 = 123444442344L;
56 static final long DIV7 = 1;
57 static final long DIV8 = 0x7fffffffffffffffL;
58 static final long DIV9 = 143444;
59 static final long DIV10 = 12342;
60 static final long DIV11 = 0x0000000080000000L;
61
62 static void div(long a)
63 {
64 // Element at 0 is left empty intentionally.
65 long[] expected = new long[N + 1];
66 long[] result = new long[N + 1];
67
68 divint(expected, a);
69 divcomp(result, a);
70
71 for (int i = 1; i <= N; i++) {
72 if (result[i] != expected[i])
73 throw new InternalError("Division of " + a + " failed at " + i + ": " + result + " != " + expected);
74 }
75 }
76
77 static void divint(long[] la, long a)
78 {
79 // Element at 0 is left empty intentionally.
80 la[1] = a / DIV1;
81 la[2] = a / DIV2;
82 la[3] = a / DIV3;
83 la[4] = a / DIV4;
84 la[5] = a / DIV5;
85 la[6] = a / DIV6;
86 la[7] = a / DIV7;
87 la[8] = a / DIV8;
88 la[9] = a / DIV9;
89 la[10] = a / DIV10;
90 la[11] = a / DIV11;
91 }
92
93 static void divcomp(long[] la, long a)
94 {
95 // Element at 0 is left empty intentionally.
96 la[1] = a / DIV1;
97 la[2] = a / DIV2;
98 la[3] = a / DIV3;
99 la[4] = a / DIV4;
100 la[5] = a / DIV5;
101 la[6] = a / DIV6;
102 la[7] = a / DIV7;
103 la[8] = a / DIV8;
104 la[9] = a / DIV9;
105 la[10] = a / DIV10;
106 la[11] = a / DIV11;
107 }
108 }