author | iignatyev |
Sat, 22 Mar 2014 00:26:48 +0400 | |
changeset 23493 | 170c77c1103a |
child 25958 | 8dc85547d6d6 |
permissions | -rw-r--r-- |
23493
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
1 |
/* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
4 |
* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
8 |
* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
14 |
* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
18 |
* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
22 |
* |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
23 |
*/ |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
24 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
25 |
/** |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
26 |
* @test |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
27 |
* @bug 8031321 |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
28 |
* @summary Verify that results of computations are the same w/ |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
29 |
* and w/o usage of ANDN instruction |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
30 |
* @library /testlibrary /testlibrary/whitebox |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
31 |
* @build TestAndnI BMITestRunner Expr |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
32 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
33 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
34 |
* -XX:+WhiteBoxAPI TestAndnI |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
35 |
*/ |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
36 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
37 |
import sun.hotspot.cpuinfo.CPUInfo; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
38 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
39 |
public class TestAndnI { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
40 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
41 |
public static void main(String args[]) throws Throwable { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
42 |
if (!CPUInfo.hasFeature("bmi1")) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
43 |
System.out.println("CPU does not support bmi1 feature. "+ |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
44 |
"Test skipped."); |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
45 |
return; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
46 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
47 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
48 |
BMITestRunner.runTests(AndnIExpr.class, args, |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
49 |
"-XX:+UseBMI1Instructions"); |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
50 |
BMITestRunner.runTests(AndnICommutativeExpr.class, args, |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
51 |
"-XX:+UseBMI1Instructions"); |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
52 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
53 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
54 |
public static class AndnIExpr extends Expr.BMIBinaryIntExpr { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
55 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
56 |
public int intExpr(int src1, int src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
57 |
return ~src1 & src2; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
58 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
59 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
60 |
public int intExpr(int src1, Expr.MemI src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
61 |
return ~src1 & src2.value; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
62 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
63 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
64 |
public int intExpr(Expr.MemI src1, int src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
65 |
return ~src1.value & src2; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
66 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
67 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
68 |
public int intExpr(Expr.MemI src1, Expr.MemI src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
69 |
return ~src1.value & src2.value; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
70 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
71 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
72 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
73 |
public static class AndnICommutativeExpr extends Expr.BMIBinaryIntExpr { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
74 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
75 |
public int intExpr(int src1, int src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
76 |
return src1 & ~src2; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
77 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
78 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
79 |
public int intExpr(int src1, Expr.MemI src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
80 |
return src1 & ~src2.value; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
81 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
82 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
83 |
public int intExpr(Expr.MemI src1, int src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
84 |
return src1.value & ~src2; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
85 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
86 |
|
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
87 |
public int intExpr(Expr.MemI src1, Expr.MemI src2) { |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
88 |
return src1.value & ~src2.value; |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
89 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
90 |
} |
170c77c1103a
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
91 |
} |