Run LSE with LoadStoreAnalysisType::kBasic analysis.

Otherwise, the code assumes partial LSE gets run, which isn't the case
as it's currently disabled.

Test: 834-lse
Bug: 205813546
Bug: 205676807
Change-Id: Ief5cba2964d60522e747395b60f90b862fcfe560
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 722cc83..b767032 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -3889,7 +3889,7 @@
                         stats_,
                         &allocator,
                         enable_partial_lse ? LoadStoreAnalysisType::kFull
-                                           : LoadStoreAnalysisType::kNoPredicatedInstructions);
+                                           : LoadStoreAnalysisType::kBasic);
   lsa.Run();
   const HeapLocationCollector& heap_location_collector = lsa.GetHeapLocationCollector();
   if (heap_location_collector.GetNumberOfHeapLocations() == 0) {
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index 7d68c9f..02dc939 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -4536,7 +4536,8 @@
 // // DO NOT ELIMINATE
 // return obj.field;
 // EXIT
-TEST_F(LoadStoreEliminationTest, PartialLoadPreserved4) {
+// Disabled due to b/205813546.
+TEST_F(LoadStoreEliminationTest, DISABLED_PartialLoadPreserved4) {
   ScopedObjectAccess soa(Thread::Current());
   VariableSizedHandleScope vshs(soa.Self());
   CreateGraph(&vshs);
@@ -4728,7 +4729,8 @@
 // EXIT
 // ELIMINATE
 // return obj.field
-TEST_F(LoadStoreEliminationTest, PartialLoadPreserved6) {
+// Disabled due to b/205813546.
+TEST_F(LoadStoreEliminationTest, DISABLED_PartialLoadPreserved6) {
   CreateGraph();
   AdjacencyListGraph blks(SetupFromAdjacencyList("entry",
                                                  "exit",
diff --git a/test/530-checker-lse/src/Main.java b/test/530-checker-lse/src/Main.java
index 06cf79f..9f10afe 100644
--- a/test/530-checker-lse/src/Main.java
+++ b/test/530-checker-lse/src/Main.java
@@ -3942,6 +3942,8 @@
   /// CHECK-START: int Main.$noinline$testPartialEscape1(TestClass, boolean) load_store_elimination (after)
   /// CHECK:         InstanceFieldSet
   //
+  // TODO: We should be able to remove this setter by realizing `i` only escapes in a branch.
+  /// CHECK:         InstanceFieldSet
   /// CHECK-NOT:     InstanceFieldSet
   //
   /// CHECK-START: int Main.$noinline$testPartialEscape1(TestClass, boolean) load_store_elimination (after)
diff --git a/test/834-lse/expected-stderr.txt b/test/834-lse/expected-stderr.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/834-lse/expected-stderr.txt
diff --git a/test/834-lse/expected-stdout.txt b/test/834-lse/expected-stdout.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/834-lse/expected-stdout.txt
diff --git a/test/834-lse/info.txt b/test/834-lse/info.txt
new file mode 100644
index 0000000..8229be9
--- /dev/null
+++ b/test/834-lse/info.txt
@@ -0,0 +1,2 @@
+Regression test for the load-store-elimination pass, which used to remove stores
+too agressively.
diff --git a/test/834-lse/src/Main.java b/test/834-lse/src/Main.java
new file mode 100644
index 0000000..6513969
--- /dev/null
+++ b/test/834-lse/src/Main.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+class Main {
+  int myField;
+  static boolean test;
+
+  static void $noinline$assertEquals(int expected, int actual) {
+    if (expected != actual) {
+      throw new Error("Expected " + expected + ", got " + actual);
+    }
+  }
+
+  static void $noinline$empty() {}
+  static void $noinline$escape(Object m) {}
+
+  public static void main(String[] args) {
+    Main m = new Main();
+    if (test) {
+      $noinline$escape(m);
+    } else {
+      m.myField = 42;
+    }
+    $noinline$empty();
+    $noinline$assertEquals(42, m.myField);
+  }
+}