Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/intrinsics/bmi/TestBzhiI2L.java
41155 views
1
/*
2
* Copyright (c) 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
* @summary Verify that results of computations are the same w/
28
* and w/o usage of BZHI instruction
29
* @library /test/lib /
30
* @modules java.base/jdk.internal.misc
31
* java.management
32
* @build sun.hotspot.WhiteBox
33
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
34
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35
* -XX:+WhiteBoxAPI compiler.intrinsics.bmi.TestBzhiI2L
36
*/
37
38
package compiler.intrinsics.bmi;
39
40
import jdk.test.lib.Platform;
41
import sun.hotspot.cpuinfo.CPUInfo;
42
43
public class TestBzhiI2L {
44
45
public static void main(String args[]) throws Throwable {
46
if (Platform.isX86()) {
47
System.out.println("INFO: Bzhiq not implemented for x86_32, test SKIPPED" );
48
return;
49
}
50
if (!CPUInfo.hasFeature("bmi2")) {
51
System.out.println("INFO: CPU does not support bmi2 feature, test SKIPPED" );
52
return;
53
}
54
55
BMITestRunner.runTests(BzhiI2LExpr.class, args,
56
"-XX:+IgnoreUnrecognizedVMOptions",
57
"-XX:+UseBMI2Instructions");
58
BMITestRunner.runTests(BzhiI2LCommutativeExpr.class, args,
59
"-XX:+IgnoreUnrecognizedVMOptions",
60
"-XX:+UseBMI2Instructions");
61
}
62
63
public static class BzhiI2LExpr extends Expr.BMIUnaryIntToLongExpr {
64
65
public long intToLongExpr(int src1) {
66
int value = src1;
67
long returnValue = 0L;
68
69
for(int i = 0; i < 10000; ++i) {
70
returnValue =
71
(long)(value & 0x1) ^ (long)(value & 0x3) ^ (long)(value & 0x7) ^ (long)(value & 0xF) ^
72
(long)(value & 0x1F) ^ (long)(value & 0x3F) ^ (long)(value & 0x7F) ^ (long)(value & 0xFF) ^
73
(long)(value & 0x1FF) ^ (long)(value & 0x3FF) ^ (long)(value & 0x7FF) ^ (long)(value & 0xFFF) ^
74
(long)(value & 0x1FFF) ^ (long)(value & 0x3FFF) ^ (long)(value & 0x7FFF) ^ (long)(value & 0xFFFF);
75
}
76
return returnValue;
77
}
78
}
79
80
public static class BzhiI2LCommutativeExpr extends Expr.BMIUnaryIntToLongExpr {
81
82
public long intToLongExpr(int src1) {
83
int value = src1;
84
long returnValue = 0L;
85
86
for(int i = 0; i < 10000; ++i) {
87
returnValue =
88
(long)(value & 0x1) ^ (long)(value & 0x3) ^ (long)(value & 0x7) ^ (long)(value & 0xF) ^
89
(long)(value & 0x1F) ^ (long)(value & 0x3F) ^ (long)(value & 0x7F) ^ (long)(value & 0xFF) ^
90
(long)(value & 0x1FF) ^ (long)(value & 0x3FF) ^ (long)(value & 0x7FF) ^ (long)(value & 0xFFF) ^
91
(long)(value & 0x1FFF) ^ (long)(value & 0x3FFF) ^ (long)(value & 0x7FFF) ^ (long)(value & 0xFFFF);
92
}
93
return returnValue;
94
}
95
}
96
}
97
98