Improved instruction + offset hunting.
Rationale:
This is generally useful for anything using this method
but in particular for deopting something like
bs[ off] = (byte)(n >>> 24);
bs[++off] = (byte)(n >>> 16);
bs[++off] = (byte)(n >>> 8);
bs[++off] = (byte)(n );
where the base + offset is hidden in the increments.
Occurs quite often in real-life code.
Change-Id: I3fa7d285a7368a179a26e590e8eee37f3b64c25d
diff --git a/test/449-checker-bce/src/Main.java b/test/449-checker-bce/src/Main.java
index 31bb94c..32bbc5b 100644
--- a/test/449-checker-bce/src/Main.java
+++ b/test/449-checker-bce/src/Main.java
@@ -391,6 +391,36 @@
array[base + 1] = 1;
}
+ /// CHECK-START: void Main.constantIndexing10(int[], int) BCE (before)
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+
+ /// CHECK-START: void Main.constantIndexing10(int[], int) BCE (after)
+ /// CHECK: Deoptimize
+ /// CHECK: Deoptimize
+ /// CHECK-NOT: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK-NOT: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK-NOT: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK-NOT: BoundsCheck
+ /// CHECK: ArraySet
+
+ static void constantIndexing10(int[] array, int base) {
+ // Offset hidden in incremented base.
+ array[base] = 1;
+ array[++base] = 2;
+ array[++base] = 3;
+ array[++base] = 4;
+ }
+
static void runAllConstantIndices() {
int[] a1 = { 0 };
int[] a6 = { 0, 0, 0, 0, 0, 0 };
@@ -502,6 +532,12 @@
a6[3] != 3 || a6[4] != 40 || a6[5] != 10) {
System.out.println("constant indices 9 failed!");
}
+
+ constantIndexing10(a6, 0);
+ if (a6[0] != 1 || a6[1] != 2 || a6[2] != 3 ||
+ a6[3] != 4 || a6[4] != 40 || a6[5] != 10) {
+ System.out.println("constant indices 10 failed!");
+ }
}
// A helper into which the actual throwing function should be inlined.