Add support for intrinsic optimizations.

Change-Id: Ib5a4224022f9360e60c09a19ac8642270a7f3b64
diff --git a/test/536-checker-intrinsic-optimization/src/Main.java b/test/536-checker-intrinsic-optimization/src/Main.java
new file mode 100644
index 0000000..1b784ae
--- /dev/null
+++ b/test/536-checker-intrinsic-optimization/src/Main.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 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 {
+  public static void main(String[] args) {
+    stringEqualsSame();
+    stringArgumentNotNull("Foo");
+  }
+
+  /// CHECK-START: boolean Main.stringEqualsSame() instruction_simplifier (before)
+  /// CHECK:      InvokeStaticOrDirect
+
+  /// CHECK-START: boolean Main.stringEqualsSame() register (before)
+  /// CHECK:      <<Const1:i\d+>> IntConstant 1
+  /// CHECK:      Return [<<Const1>>]
+
+  /// CHECK-START: boolean Main.stringEqualsSame() register (before)
+  /// CHECK-NOT:  InvokeStaticOrDirect
+  public static boolean stringEqualsSame() {
+    return $inline$callStringEquals("obj", "obj");
+  }
+
+  /// CHECK-START: boolean Main.stringEqualsNull() register (after)
+  /// CHECK:      <<Invoke:z\d+>> InvokeStaticOrDirect
+  /// CHECK:      Return [<<Invoke>>]
+  public static boolean stringEqualsNull() {
+    String o = (String)myObject;
+    return $inline$callStringEquals(o, o);
+  }
+
+  public static boolean $inline$callStringEquals(String a, String b) {
+    return a.equals(b);
+  }
+
+  /// CHECK-START-X86: boolean Main.stringArgumentNotNull(java.lang.Object) disassembly (after)
+  /// CHECK:          InvokeStaticOrDirect
+  /// CHECK-NOT:      test
+  public static boolean stringArgumentNotNull(Object obj) {
+    obj.getClass();
+    return "foo".equals(obj);
+  }
+
+  // Test is very brittle as it depends on the order we emit instructions.
+  /// CHECK-START-X86: boolean Main.stringArgumentIsString() disassembly (after)
+  /// CHECK:      InvokeStaticOrDirect
+  /// CHECK:      test
+  /// CHECK:      jz/eq
+  // Check that we don't try to compare the classes.
+  /// CHECK-NOT:  mov
+  /// CHECK:      cmp
+  public static boolean stringArgumentIsString() {
+    return "foo".equals(myString);
+  }
+
+  static String myString;
+  static Object myObject;
+}