Fix bug in dynamic BCE. With regression test.
Rationale:
We implicitly assumed anything on a fixed offset to a suitable
candidate could be picked for codegen. Although this is usually
true, the scanner found an exception (on types). So, it is best
to make the test explicit. Note: some type implications are TBD.
Bug:32193474
Test: test-art-host and offending APKs
Change-Id: I664a2caa97a7f231509f8832b940dd72da11a372
diff --git a/test/530-checker-loops2/src/Main.java b/test/530-checker-loops2/src/Main.java
index dca00bd..23d6438 100644
--- a/test/530-checker-loops2/src/Main.java
+++ b/test/530-checker-loops2/src/Main.java
@@ -890,6 +890,18 @@
return result;
}
+ static int shortIndex(int[] a) {
+ int r = 0;
+ // Make sure short/int conversions compiles well (b/32193474).
+ // TODO: investigate type implications and whether we can use
+ // constant range to apply dyn BCE on all subscripts.
+ for (short i = 1; i < 10; i++) {
+ int ki = i - 1;
+ r += a[ki] + a[i];
+ }
+ return r;
+ }
+
//
// Verifier.
//
@@ -1224,6 +1236,8 @@
Integer[] x9 = { 9 };
expectEquals(145, dynamicBCEAndConstantIndexRefType(x, x9, 0, 10));
+ expectEquals(99, shortIndex(x));
+
System.out.println("passed");
}