Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/intrinsics/bmi/TestAndnI.java
41155 views
1
/*
2
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. 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 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
* @key randomness
27
* @bug 8031321
28
* @summary Verify that results of computations are the same w/
29
* and w/o usage of ANDN instruction
30
* @library /test/lib /
31
* @modules java.base/jdk.internal.misc
32
* java.management
33
* @build sun.hotspot.WhiteBox
34
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
35
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
36
* -XX:+WhiteBoxAPI compiler.intrinsics.bmi.TestAndnI
37
*/
38
39
package compiler.intrinsics.bmi;
40
41
import sun.hotspot.cpuinfo.CPUInfo;
42
43
public class TestAndnI {
44
45
public static void main(String args[]) throws Throwable {
46
if (!CPUInfo.hasFeature("bmi1")) {
47
System.out.println("INFO: CPU does not support bmi1 feature.");
48
}
49
50
BMITestRunner.runTests(AndnIExpr.class, args,
51
"-XX:+IgnoreUnrecognizedVMOptions",
52
"-XX:+UseBMI1Instructions");
53
BMITestRunner.runTests(AndnICommutativeExpr.class, args,
54
"-XX:+IgnoreUnrecognizedVMOptions",
55
"-XX:+UseBMI1Instructions");
56
}
57
58
public static class AndnIExpr extends Expr.BMIBinaryIntExpr {
59
60
public int intExpr(int src1, int src2) {
61
return ~src1 & src2;
62
}
63
64
public int intExpr(int src1, Expr.MemI src2) {
65
if (src2 != null) {
66
return ~src1 & src2.value;
67
} else {
68
return 0;
69
}
70
}
71
72
public int intExpr(Expr.MemI src1, int src2) {
73
if (src1 != null) {
74
return ~src1.value & src2;
75
} else {
76
return 0;
77
}
78
}
79
80
public int intExpr(Expr.MemI src1, Expr.MemI src2) {
81
if (src1 != null && src2 != null) {
82
return ~src1.value & src2.value;
83
} else {
84
return 0;
85
}
86
}
87
}
88
89
public static class AndnICommutativeExpr extends Expr.BMIBinaryIntExpr {
90
91
public int intExpr(int src1, int src2) {
92
return src1 & ~src2;
93
}
94
95
public int intExpr(int src1, Expr.MemI src2) {
96
if (src2 != null) {
97
return src1 & ~src2.value;
98
} else {
99
return 0;
100
}
101
}
102
103
public int intExpr(Expr.MemI src1, int src2) {
104
if (src1 != null) {
105
return src1.value & ~src2;
106
} else {
107
return 0;
108
}
109
}
110
111
public int intExpr(Expr.MemI src1, Expr.MemI src2) {
112
if (src1 != null && src2 != null) {
113
return src1.value & ~src2.value;
114
} else {
115
return 0;
116
}
117
}
118
}
119
}
120
121