Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/aarch64/IntShiftTests.java
32282 views
1
public class IntShiftTests {
2
3
private static int test_shl(int a, int b) {
4
return a << b;
5
}
6
7
private static int test_shlc1(int a) {
8
return a << 1;
9
}
10
11
private static int test_shlc33(int a) {
12
return a << 33;
13
}
14
15
private static int test_shr(int a, int b) {
16
return a >> b;
17
}
18
19
private static int test_shrc1(int a) {
20
return a >> 1;
21
}
22
23
private static int test_shrc33(int a) {
24
return a >> 33;
25
}
26
27
private static int test_ushr(int a, int b) {
28
return a >>> b;
29
}
30
31
private static int test_ushrc1(int a) {
32
return a >>> 1;
33
}
34
35
private static int test_ushrc33(int a) {
36
return a >>> 33;
37
}
38
39
private static void assertThat(boolean assertion) {
40
if (! assertion) {
41
throw new AssertionError();
42
}
43
}
44
45
public static void main(String[] args) {
46
47
assertThat(test_shl(32, 2) == 128);
48
assertThat(test_shl(0x80000000, 1) == 0);
49
assertThat(test_shl(0x40000000, 1) == 0x80000000);
50
assertThat(test_shl(0x40000000, 33) == 0x80000000);
51
52
assertThat(test_shr(32, 2) == 8);
53
assertThat(test_shr(1, 1) == 0);
54
assertThat(test_shr(0x80000000, 1) == 0xc0000000);
55
assertThat(test_shr(0x40000000, 33) == 0x20000000);
56
57
assertThat(test_ushr(32, 2) == 8);
58
assertThat(test_ushr(1, 1) == 0);
59
assertThat(test_ushr(0x80000000, 1) == 0x40000000);
60
assertThat(test_ushr(0x40000000, 33) == 0x20000000);
61
62
assertThat(test_shlc1(32) == 64);
63
assertThat(test_shlc1(0x80000000) == 0);
64
assertThat(test_shlc1(0x40000000) == 0x80000000);
65
assertThat(test_shlc33(0x40000000) == 0x80000000);
66
67
assertThat(test_shrc1(32) == 16);
68
assertThat(test_shrc1(1) == 0);
69
assertThat(test_shrc1(0x80000000) == 0xc0000000);
70
assertThat(test_shrc33(0x40000000) == 0x20000000);
71
72
assertThat(test_ushrc1(32) == 16);
73
assertThat(test_ushrc1(1) == 0);
74
assertThat(test_ushrc1(0x80000000) == 0x40000000);
75
assertThat(test_ushrc33(0x40000000) == 0x20000000);
76
}
77
}
78
79