Mercurial > hg > graal-jvmci-8
annotate test/compiler/codegen/IntRotateWithImmediate.java @ 23993:7b65bd0ebeb7
removed duplicate registration of StubRoutines::_multiplyToLen in vmstructs
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 31 Jan 2017 22:59:16 +0100 |
parents | 37a5a1341478 |
children |
rev | line source |
---|---|
23032
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
1 /* |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
2 * Copyright 2015 SAP AG. All Rights Reserved. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
4 * |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
8 * |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
13 * accompanied this code). |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
14 * |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
18 * |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
21 * questions. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
22 */ |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
23 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
24 /* |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
25 * @test |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
26 * @bug 8080190 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
27 * @key regression |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
28 * @summary Test that the rotate distance used in the rotate instruction is properly masked with 0x1f |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
29 * @run main/othervm -Xbatch -XX:-UseOnStackReplacement IntRotateWithImmediate |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
30 * @author volker.simonis@gmail.com |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
31 */ |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
32 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
33 public class IntRotateWithImmediate { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
34 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
35 // This is currently the same as Integer.rotateRight() |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
36 static int rotateRight(int i, int distance) { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
37 // On some architectures (i.e. x86_64 and ppc64) the following computation is |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
38 // matched in the .ad file into a single MachNode which emmits a single rotate |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
39 // machine instruction. It is important that the shift amount is masked to match |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
40 // corresponding immediate width in the native instruction. On x86_64 the rotate |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
41 // left instruction ('rol') encodes an 8-bit immediate while the corresponding |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
42 // 'rotlwi' instruction on Power only encodes a 5-bit immediate. |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
43 return ((i >>> distance) | (i << -distance)); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
44 } |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
45 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
46 static int compute(int x) { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
47 return rotateRight(x, 3); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
48 } |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
49 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
50 public static void main(String args[]) { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
51 int val = 4096; |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
52 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
53 int firstResult = compute(val); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
54 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
55 for (int i = 0; i < 100000; i++) { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
56 int newResult = compute(val); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
57 if (firstResult != newResult) { |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
58 throw new InternalError(firstResult + " != " + newResult); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
59 } |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
60 } |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
61 System.out.println("OK"); |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
62 } |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
63 |
37a5a1341478
8080190: PPC64: Fix wrong rotate instructions in the .ad file
simonis
parents:
diff
changeset
|
64 } |