Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codegen/BMI2.java
41149 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
* @summary Support BMI2 instructions on x86/x64
27
*
28
* @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure
29
* -XX:CompileCommand=dontinline,compiler.codegen.BMI2$BMITests::*
30
* compiler.codegen.BMI2
31
*/
32
33
package compiler.codegen;
34
35
public class BMI2 {
36
private final static int ITERATIONS = 30000;
37
38
// match(Set dst (ConvI2L (AndI src1 mask)))
39
public static void testBzhiI2L(int ix) {
40
long[] goldv = new long[16];
41
for (int i = 0; i <= 15; i++) {
42
goldv[i] = BMITests.bzhiI2L(ix, i);
43
}
44
for (int i2 = 0; i2 < ITERATIONS; i2++) {
45
for (int i = 0; i <= 15; i++) {
46
long v = BMITests.bzhiI2L(ix, i);
47
if (v != goldv[i]) {
48
throw new Error(returnBzhiI2LErrMessage (goldv[i], v));
49
}
50
}
51
}
52
}
53
54
private static String returnBzhiI2LErrMessage (long value, long value2) {
55
return "bzhi I2L with register failed, uncompiled result: " + value + " does not match compiled result: " + value2;
56
}
57
58
static class BMITests {
59
60
static long bzhiI2L(int src1, int src2) {
61
62
switch(src2) {
63
case 0:
64
return (long)(src1 & 0x1);
65
case 1:
66
return (long)(src1 & 0x3);
67
case 2:
68
return (long)(src1 & 0x7);
69
case 3:
70
return (long)(src1 & 0xF);
71
case 4:
72
return (long)(src1 & 0x1F);
73
case 5:
74
return (long)(src1 & 0x3F);
75
case 6:
76
return (long)(src1 & 0x7F);
77
case 7:
78
return (long)(src1 & 0xFF);
79
case 8:
80
return (long)(src1 & 0x1FF);
81
case 9:
82
return (long)(src1 & 0x3FF);
83
case 10:
84
return (long)(src1 & 0x7FF);
85
case 11:
86
return (long)(src1 & 0xFFF);
87
case 12:
88
return (long)(src1 & 0x1FFF);
89
case 13:
90
return (long)(src1 & 0x3FFF);
91
case 14:
92
return (long)(src1 & 0x7FFF);
93
case 15:
94
return (long)(src1 & 0xFFFF);
95
default:
96
return (long)(src1 & 0xFFFF);
97
}
98
}
99
}
100
101
public static void main(String[] args) {
102
testBzhiI2L(0);
103
testBzhiI2L(1);
104
}
105
}
106
107