Add a regression test for b/216762268.
Bug: 216762268
Test: 835-b216762268
Change-Id: Iafa01ceb8fb84e6f1150e57b6db249134a79a7ab
diff --git a/test/835-b216762268/expected-stderr.txt b/test/835-b216762268/expected-stderr.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/835-b216762268/expected-stderr.txt
diff --git a/test/835-b216762268/expected-stdout.txt b/test/835-b216762268/expected-stdout.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/835-b216762268/expected-stdout.txt
diff --git a/test/835-b216762268/info.txt b/test/835-b216762268/info.txt
new file mode 100644
index 0000000..4089967
--- /dev/null
+++ b/test/835-b216762268/info.txt
@@ -0,0 +1,2 @@
+Regression test for b/216762268, which found a bug in
+LoopOptimization::SimplifyInduction.
diff --git a/test/835-b216762268/src/Main.java b/test/835-b216762268/src/Main.java
new file mode 100644
index 0000000..5e41827
--- /dev/null
+++ b/test/835-b216762268/src/Main.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 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 {
+ static long count;
+
+ static int $noinline$mainTest() {
+ int i, i1 = 10, i15 = 49099, i17, i20, i21 = -2;
+ for (i = 5; i < 138; i++)
+ for (i15 = 11; i15 < 188; ++i15) {
+ for (i17 = 2; i17 > 1; i17--) {
+ i1 += i17;
+ count = i1;
+ }
+ for (i20 = 1; i20 < 2; ++i20) {
+ i21 += i17;
+ }
+ }
+ return i21;
+ }
+
+ public static void assertEquals(int expected, int actual) {
+ if (expected != actual) {
+ throw new Error("Expected " + expected + ", got " + actual);
+ }
+ }
+
+ public static void main(String[] strArr) {
+ assertEquals(23539, $noinline$mainTest());
+ }
+}
diff --git a/test/knownfailures.json b/test/knownfailures.json
index f68f6f0..377d8e7 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -1468,11 +1468,17 @@
"tests": ["597-deopt-invoke-stub"],
"variant": "redefine-stress & jit | jvmti-stress & jit",
"description": ["Test expects few methods to be interpreted but jvmti enables",
- "jit-on-first-use which breaks this expectation"]
+ "jit-on-first-use which breaks this expectation"]
},
{
"tests": ["667-jit-jni-stub"],
"variant": "jit-on-first-use | redefine-stress",
"description": ["jit-on-first-use disables jit GC but this test requires jit GC"]
+ },
+ {
+ "tests": ["835-b216762268"],
+ "variant": "jit | optimizing",
+ "bug": "b/216762268",
+ "description": ["bug in the loop optimization"]
}
]