Implemented checker/unit test for various operations.

Rationale:
It's test time! These new checker tests verify that various
common integer operations are recognized as intrinsic.
Furthermore, some functionality testing is done to ensure
that architectural specific implementations are correct.

Change-Id: I8ac02a083ef1110c9baf274fbf75d931167e9ba5
diff --git a/test/564-checker-bitcount/src/Main.java b/test/564-checker-bitcount/src/Main.java
index b250145..2683b25 100644
--- a/test/564-checker-bitcount/src/Main.java
+++ b/test/564-checker-bitcount/src/Main.java
@@ -16,24 +16,20 @@
 
 public class Main {
 
-  // TODO: make this work when b/26700769 is done.
-  //
+  // TODO: make something like this work when b/26700769 is done.
   // CHECK-START-X86_64: int Main.bits32(int) disassembly (after)
   // CHECK-DAG: popcnt
-  //
-  // CHECK-START-X86_64: int Main.bits32(int) disassembly (after)
-  // CHECK-NOT: call
+
+  /// CHECK-START: int Main.bits32(int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerBitCount
+  /// CHECK-DAG:                 Return [<<Result>>]
   private static int bits32(int x) {
     return Integer.bitCount(x);
   }
 
-  // TODO: make this work when b/26700769 is done.
-  //
-  // CHECK-START-X86_64: int Main.bits64(long) disassembly (after)
-  // CHECK-DAG: popcnt
-  //
-  // CHECK-START-X86_64: int Main.bits64(long) disassembly (after)
-  // CHECK-NOT: call
+  /// CHECK-START: int Main.bits64(long) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:LongBitCount
+  /// CHECK-DAG:                 Return [<<Result>>]
   private static int bits64(long x) {
     return Long.bitCount(x);
   }
diff --git a/test/565-checker-rotate/expected.txt b/test/565-checker-rotate/expected.txt
new file mode 100644
index 0000000..b0aad4d
--- /dev/null
+++ b/test/565-checker-rotate/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/565-checker-rotate/info.txt b/test/565-checker-rotate/info.txt
new file mode 100644
index 0000000..c6a8091
--- /dev/null
+++ b/test/565-checker-rotate/info.txt
@@ -0,0 +1 @@
+Unit test for 32-bit and 64-bit rotate operations.
diff --git a/test/565-checker-rotate/src/Main.java b/test/565-checker-rotate/src/Main.java
new file mode 100644
index 0000000..33bbe02
--- /dev/null
+++ b/test/565-checker-rotate/src/Main.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+  /// CHECK-START: int Main.rotateLeft32(int, int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerRotateLeft
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int rotateLeft32(int x, int y) {
+    return Integer.rotateLeft(x, y);
+  }
+
+  /// CHECK-START: long Main.rotateLeft64(long, int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:j\d+>> InvokeStaticOrDirect intrinsic:LongRotateLeft
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static long rotateLeft64(long x, int y) {
+    return Long.rotateLeft(x, y);
+  }
+
+  /// CHECK-START: int Main.rotateRight32(int, int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerRotateRight
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int rotateRight32(int x, int y) {
+    return Integer.rotateRight(x, y);
+  }
+
+  /// CHECK-START: long Main.rotateRight64(long, int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:j\d+>> InvokeStaticOrDirect intrinsic:LongRotateRight
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static long rotateRight64(long x, int y) {
+    return Long.rotateRight(x, y);
+  }
+
+  public static void main(String args[]) {
+    expectEquals32(0x00000001, rotateLeft32(0x00000001, 0));
+    expectEquals32(0x00000002, rotateLeft32(0x00000001, 1));
+    expectEquals32(0x80000000, rotateLeft32(0x00000001, 31));
+    expectEquals32(0x00000001, rotateLeft32(0x00000001, 32));  // overshoot
+    expectEquals32(0x00000003, rotateLeft32(0x80000001, 1));
+    expectEquals32(0x00000006, rotateLeft32(0x80000001, 2));
+    expectEquals32(0x23456781, rotateLeft32(0x12345678, 4));
+    expectEquals32(0xBCDEF09A, rotateLeft32(0x9ABCDEF0, 8));
+    for (int i = 0; i < 40; i++) {  // overshoot a bit
+      int j = i & 31;
+      expectEquals32(0x00000000, rotateLeft32(0x00000000, i));
+      expectEquals32(0xFFFFFFFF, rotateLeft32(0xFFFFFFFF, i));
+      expectEquals32(1 << j, rotateLeft32(0x00000001, i));
+      expectEquals32((0x12345678 << j) | (0x12345678 >>> -j),
+                     rotateLeft32(0x12345678, i));
+    }
+
+    expectEquals64(0x0000000000000001L, rotateLeft64(0x0000000000000001L, 0));
+    expectEquals64(0x0000000000000002L, rotateLeft64(0x0000000000000001L, 1));
+    expectEquals64(0x8000000000000000L, rotateLeft64(0x0000000000000001L, 63));
+    expectEquals64(0x0000000000000001L, rotateLeft64(0x0000000000000001L, 64));  // overshoot
+    expectEquals64(0x0000000000000003L, rotateLeft64(0x8000000000000001L, 1));
+    expectEquals64(0x0000000000000006L, rotateLeft64(0x8000000000000001L, 2));
+    expectEquals64(0x23456789ABCDEF01L, rotateLeft64(0x123456789ABCDEF0L, 4));
+    expectEquals64(0x3456789ABCDEF012L, rotateLeft64(0x123456789ABCDEF0L, 8));
+    for (int i = 0; i < 70; i++) {  // overshoot a bit
+      int j = i & 63;
+      expectEquals64(0x0000000000000000L, rotateLeft64(0x0000000000000000L, i));
+      expectEquals64(0xFFFFFFFFFFFFFFFFL, rotateLeft64(0xFFFFFFFFFFFFFFFFL, i));
+      expectEquals64(1L << j, rotateLeft64(0x0000000000000001, i));
+      expectEquals64((0x123456789ABCDEF0L << j) | (0x123456789ABCDEF0L >>> -j),
+                     rotateLeft64(0x123456789ABCDEF0L, i));
+    }
+
+    expectEquals32(0x80000000, rotateRight32(0x80000000, 0));
+    expectEquals32(0x40000000, rotateRight32(0x80000000, 1));
+    expectEquals32(0x00000001, rotateRight32(0x80000000, 31));
+    expectEquals32(0x80000000, rotateRight32(0x80000000, 32));  // overshoot
+    expectEquals32(0xC0000000, rotateRight32(0x80000001, 1));
+    expectEquals32(0x60000000, rotateRight32(0x80000001, 2));
+    expectEquals32(0x81234567, rotateRight32(0x12345678, 4));
+    expectEquals32(0xF09ABCDE, rotateRight32(0x9ABCDEF0, 8));
+    for (int i = 0; i < 40; i++) {  // overshoot a bit
+      int j = i & 31;
+      expectEquals32(0x00000000, rotateRight32(0x00000000, i));
+      expectEquals32(0xFFFFFFFF, rotateRight32(0xFFFFFFFF, i));
+      expectEquals32(0x80000000 >>> j, rotateRight32(0x80000000, i));
+      expectEquals32((0x12345678 >>> j) | (0x12345678 << -j),
+                     rotateRight32(0x12345678, i));
+    }
+
+    expectEquals64(0x8000000000000000L, rotateRight64(0x8000000000000000L, 0));
+    expectEquals64(0x4000000000000000L, rotateRight64(0x8000000000000000L, 1));
+    expectEquals64(0x0000000000000001L, rotateRight64(0x8000000000000000L, 63));
+    expectEquals64(0x8000000000000000L, rotateRight64(0x8000000000000000L, 64));  // overshoot
+    expectEquals64(0xC000000000000000L, rotateRight64(0x8000000000000001L, 1));
+    expectEquals64(0x6000000000000000L, rotateRight64(0x8000000000000001L, 2));
+    expectEquals64(0x0123456789ABCDEFL, rotateRight64(0x123456789ABCDEF0L, 4));
+    expectEquals64(0xF0123456789ABCDEL, rotateRight64(0x123456789ABCDEF0L, 8));
+    for (int i = 0; i < 70; i++) {  // overshoot a bit
+      int j = i & 63;
+      expectEquals64(0x0000000000000000L, rotateRight64(0x0000000000000000L, i));
+      expectEquals64(0xFFFFFFFFFFFFFFFFL, rotateRight64(0xFFFFFFFFFFFFFFFFL, i));
+      expectEquals64(0x8000000000000000L >>> j, rotateRight64(0x8000000000000000L, i));
+      expectEquals64((0x123456789ABCDEF0L >>> j) | (0x123456789ABCDEF0L << -j),
+                     rotateRight64(0x123456789ABCDEF0L, i));
+    }
+
+    System.out.println("passed");
+  }
+
+  private static void expectEquals32(int expected, int result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+  private static void expectEquals64(long expected, long result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+}
diff --git a/test/566-checker-signum/expected.txt b/test/566-checker-signum/expected.txt
new file mode 100644
index 0000000..b0aad4d
--- /dev/null
+++ b/test/566-checker-signum/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/566-checker-signum/info.txt b/test/566-checker-signum/info.txt
new file mode 100644
index 0000000..328e494
--- /dev/null
+++ b/test/566-checker-signum/info.txt
@@ -0,0 +1 @@
+Unit test for 32-bit and 64-bit signum operations.
diff --git a/test/566-checker-signum/src/Main.java b/test/566-checker-signum/src/Main.java
new file mode 100644
index 0000000..cc4a984
--- /dev/null
+++ b/test/566-checker-signum/src/Main.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+  /// CHECK-START: int Main.sign32(int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerSignum
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int sign32(int x) {
+    return Integer.signum(x);
+  }
+
+  /// CHECK-START: int Main.sign64(long) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:LongSignum
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int sign64(long x) {
+    return Long.signum(x);
+  }
+
+  public static void main(String args[]) {
+    expectEquals(-1, sign32(Integer.MIN_VALUE));
+    expectEquals(-1, sign32(-12345));
+    expectEquals(-1, sign32(-1));
+    expectEquals(0, sign32(0));
+    expectEquals(1, sign32(1));
+    expectEquals(1, sign32(12345));
+    expectEquals(1, sign32(Integer.MAX_VALUE));
+
+    for (int i = -11; i <= 11; i++) {
+      int expected = 0;
+      if (i < 0) expected = -1;
+      else if (i > 0) expected = 1;
+      expectEquals(expected, sign32(i));
+    }
+
+    expectEquals(-1, sign64(Long.MIN_VALUE));
+    expectEquals(-1, sign64(-12345L));
+    expectEquals(-1, sign64(-1L));
+    expectEquals(0, sign64(0L));
+    expectEquals(1, sign64(1L));
+    expectEquals(1, sign64(12345L));
+    expectEquals(1, sign64(Long.MAX_VALUE));
+
+    for (long i = -11L; i <= 11L; i++) {
+      int expected = 0;
+      if (i < 0) expected = -1;
+      else if (i > 0) expected = 1;
+      expectEquals(expected, sign64(i));
+    }
+
+    System.out.println("passed");
+  }
+
+  private static void expectEquals(int expected, int result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+}
diff --git a/test/567-checker-compare/expected.txt b/test/567-checker-compare/expected.txt
new file mode 100644
index 0000000..b0aad4d
--- /dev/null
+++ b/test/567-checker-compare/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/567-checker-compare/info.txt b/test/567-checker-compare/info.txt
new file mode 100644
index 0000000..5bac7b1
--- /dev/null
+++ b/test/567-checker-compare/info.txt
@@ -0,0 +1 @@
+Unit test for 32-bit and 64-bit compare operations.
diff --git a/test/567-checker-compare/src/Main.java b/test/567-checker-compare/src/Main.java
new file mode 100644
index 0000000..52abb75
--- /dev/null
+++ b/test/567-checker-compare/src/Main.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+  /// CHECK-START: int Main.compare32(int, int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int compare32(int x, int y) {
+    return Integer.compare(x, y);
+  }
+
+  /// CHECK-START: int Main.compare64(long, long) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:LongCompare
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int compare64(long x, long y) {
+    return Long.compare(x, y);
+  }
+
+  public static void main(String args[]) {
+    expectEquals(-1, compare32(Integer.MIN_VALUE, Integer.MIN_VALUE + 1));
+    expectEquals(-1, compare32(Integer.MIN_VALUE, -1));
+    expectEquals(-1, compare32(Integer.MIN_VALUE, 0));
+    expectEquals(-1, compare32(Integer.MIN_VALUE, 1));
+    expectEquals(-1, compare32(Integer.MIN_VALUE, Integer.MAX_VALUE));
+    expectEquals(-1, compare32(-1, 0));
+    expectEquals(-1, compare32(-1, 1));
+    expectEquals(-1, compare32(0, 1));
+
+    expectEquals(0, compare32(Integer.MIN_VALUE, Integer.MIN_VALUE));
+    expectEquals(0, compare32(-1, -1));
+    expectEquals(0, compare32(0, 0));
+    expectEquals(0, compare32(1, 1));
+    expectEquals(0, compare32(Integer.MAX_VALUE, Integer.MAX_VALUE));
+
+    expectEquals(1, compare32(0, -1));
+    expectEquals(1, compare32(1, -1));
+    expectEquals(1, compare32(1, 0));
+    expectEquals(1, compare32(Integer.MAX_VALUE, Integer.MIN_VALUE));
+    expectEquals(1, compare32(Integer.MAX_VALUE, -1));
+    expectEquals(1, compare32(Integer.MAX_VALUE, 0));
+    expectEquals(1, compare32(Integer.MAX_VALUE, 1));
+    expectEquals(1, compare32(Integer.MAX_VALUE, Integer.MAX_VALUE - 1));
+
+    for (int i = -11; i <= 11; i++) {
+      for (int j = -11; j <= 11; j++) {
+        int expected = 0;
+        if (i < j) expected = -1;
+        else if (i > j) expected = 1;
+        expectEquals(expected, compare32(i, j));
+      }
+    }
+
+    expectEquals(-1, compare64(Long.MIN_VALUE, Long.MIN_VALUE + 1L));
+    expectEquals(-1, compare64(Long.MIN_VALUE, -1L));
+    expectEquals(-1, compare64(Long.MIN_VALUE, 0L));
+    expectEquals(-1, compare64(Long.MIN_VALUE, 1L));
+    expectEquals(-1, compare64(Long.MIN_VALUE, Long.MAX_VALUE));
+    expectEquals(-1, compare64(-1L, 0L));
+    expectEquals(-1, compare64(-1L, 1L));
+    expectEquals(-1, compare64(0L, 1L));
+
+    expectEquals(0, compare64(Long.MIN_VALUE, Long.MIN_VALUE));
+    expectEquals(0, compare64(-1L, -1L));
+    expectEquals(0, compare64(0L, 0L));
+    expectEquals(0, compare64(1L, 1L));
+    expectEquals(0, compare64(Long.MAX_VALUE, Long.MAX_VALUE));
+
+    expectEquals(1, compare64(0L, -1L));
+    expectEquals(1, compare64(1L, -1L));
+    expectEquals(1, compare64(1L, 0L));
+    expectEquals(1, compare64(Long.MAX_VALUE, Long.MIN_VALUE));
+    expectEquals(1, compare64(Long.MAX_VALUE, -1L));
+    expectEquals(1, compare64(Long.MAX_VALUE, 0L));
+    expectEquals(1, compare64(Long.MAX_VALUE, 1L));
+    expectEquals(1, compare64(Long.MAX_VALUE, Long.MAX_VALUE - 1L));
+
+    for (long i = -11L; i <= 11L; i++) {
+      for (long j = -11L; j <= 11L; j++) {
+        int expected = 0;
+        if (i < j) expected = -1;
+        else if (i > j) expected = 1;
+        expectEquals(expected, compare64(i, j));
+      }
+    }
+
+    System.out.println("passed");
+  }
+
+  private static void expectEquals(int expected, int result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+}
diff --git a/test/568-checker-onebit/expected.txt b/test/568-checker-onebit/expected.txt
new file mode 100644
index 0000000..b0aad4d
--- /dev/null
+++ b/test/568-checker-onebit/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/568-checker-onebit/info.txt b/test/568-checker-onebit/info.txt
new file mode 100644
index 0000000..c2b5bf8
--- /dev/null
+++ b/test/568-checker-onebit/info.txt
@@ -0,0 +1 @@
+Unit test for 32-bit and 64-bit high/low-bit operations.
diff --git a/test/568-checker-onebit/src/Main.java b/test/568-checker-onebit/src/Main.java
new file mode 100644
index 0000000..7007c6a
--- /dev/null
+++ b/test/568-checker-onebit/src/Main.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+  /// CHECK-START: int Main.hi32(int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerHighestOneBit
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int hi32(int x) {
+    return Integer.highestOneBit(x);
+  }
+
+  /// CHECK-START: int Main.lo32(int) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerLowestOneBit
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static int lo32(int x) {
+    return Integer.lowestOneBit(x);
+  }
+
+  /// CHECK-START: long Main.hi64(long) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:j\d+>> InvokeStaticOrDirect intrinsic:LongHighestOneBit
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static long hi64(long x) {
+    return Long.highestOneBit(x);
+  }
+
+  /// CHECK-START: long Main.lo64(long) intrinsics_recognition (after)
+  /// CHECK-DAG: <<Result:j\d+>> InvokeStaticOrDirect intrinsic:LongLowestOneBit
+  /// CHECK-DAG:                 Return [<<Result>>]
+  private static long lo64(long x) {
+    return Long.lowestOneBit(x);
+  }
+
+  public static void main(String args[]) {
+    expectEquals32(0x00000000, hi32(0x00000000));
+    expectEquals32(0x00000000, lo32(0x00000000));
+    expectEquals32(0x00010000, hi32(0x00010000));
+    expectEquals32(0x00010000, lo32(0x00010000));
+    expectEquals32(0x00800000, hi32(0x00FF0000));
+    expectEquals32(0x00010000, lo32(0x00FF0000));
+    expectEquals32(0x80000000, hi32(0xFFFFFFFF));
+    expectEquals32(0x00000001, lo32(0xFFFFFFFF));
+
+    for (int i = 0; i < 32; i++) {
+      expectEquals32(1 << i, hi32(1 << i));
+      expectEquals32(1 << i, lo32(1 << i));
+      int expected = i < 29 ? 0x8 << i : 0x80000000;
+      expectEquals32(expected, hi32(0xF << i));
+      expectEquals32(0x1 << i, lo32(0xF << i));
+    }
+
+    expectEquals64(0x0000000000000000L, hi64(0x0000000000000000L));
+    expectEquals64(0x0000000000000000L, lo64(0x0000000000000000L));
+    expectEquals64(0x0000000100000000L, hi64(0x0000000100000000L));
+    expectEquals64(0x0000000100000000L, lo64(0x0000000100000000L));
+    expectEquals64(0x0000008000000000L, hi64(0x000000FF00000000L));
+    expectEquals64(0x0000000100000000L, lo64(0x000000FF00000000L));
+    expectEquals64(0x8000000000000000L, hi64(0xFFFFFFFFFFFFFFFFL));
+    expectEquals64(0x0000000000000001L, lo64(0xFFFFFFFFFFFFFFFFL));
+
+    for (int i = 0; i < 64; i++) {
+      expectEquals64(1L << i, hi64(1L << i));
+      expectEquals64(1L << i, lo64(1L << i));
+      long expected = i < 61 ? 0x8L << i : 0x8000000000000000L;
+      expectEquals64(expected, hi64(0xFL << i));
+      expectEquals64(0x1L << i, lo64(0xFL << i));
+    }
+
+    System.out.println("passed");
+  }
+
+  private static void expectEquals32(int expected, int result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+  private static void expectEquals64(long expected, long result) {
+    if (expected != result) {
+      throw new Error("Expected: " + expected + ", found: " + result);
+    }
+  }
+}