diff options
author | 2016-12-16 13:57:52 -0800 | |
---|---|---|
committer | 2016-12-19 10:57:37 -0800 | |
commit | e6bd0272b43bf73faabc64abc9c51ab8ed128308 (patch) | |
tree | d75a15baadf77a859cec6540d7cd10ce998e955a /test/530-checker-loops3/src/Main.java | |
parent | 2c43590dc2bb7fb4a3a015b1b65543bb8705ffe8 (diff) |
Improved induction var and range analysis around types.
Rationale:
Lots of code should not depend on int only. This CL generalizes
the kinds of types that can be optimized after analysis. As part
of the CL, however, a minor cleanup regarding type safety of the
stored induction var analysis results is required. This further
improved our int benchmark, and brings the long benchmark up-to-par.
Test: m test-art-host-run-test
Change-Id: I5dfb623dabf9113de90c2f6da99328dda8f8b60b
Diffstat (limited to 'test/530-checker-loops3/src/Main.java')
-rw-r--r-- | test/530-checker-loops3/src/Main.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/test/530-checker-loops3/src/Main.java b/test/530-checker-loops3/src/Main.java index 209786a113..dfc4a5f98f 100644 --- a/test/530-checker-loops3/src/Main.java +++ b/test/530-checker-loops3/src/Main.java @@ -235,6 +235,59 @@ public class Main { } } + /// CHECK-START: void Main.shortBound1(int[], short) BCE (before) + /// CHECK-DAG: BoundsCheck loop:{{B\d+}} + // + /// CHECK-START: void Main.shortBound1(int[], short) BCE (after) + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-NOT: Deoptimize + // + /// CHECK-START: void Main.shortBound1(int[], short) BCE (after) + /// CHECK-NOT: BoundsCheck + public static void shortBound1(int[] array, short s) { + // Lower precision bound will appear in deopt arithmetic + // and follows normal implicit widening conversion. + for (int i = 0; i < s; i++) { + array[i] = 222; + } + } + + /// CHECK-START: void Main.shortBound2(int[], short) BCE (before) + /// CHECK-DAG: BoundsCheck loop:{{B\d+}} + // + /// CHECK-START: void Main.shortBound2(int[], short) BCE (after) + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-DAG: Deoptimize loop:none + /// CHECK-NOT: Deoptimize + // + /// CHECK-START: void Main.shortBound2(int[], short) BCE (after) + /// CHECK-NOT: BoundsCheck + public static void shortBound2(int[] array, short s) { + // Lower precision bound will appear in deopt arithmetic + // and follows normal implicit widening conversion. + for (int i = 0; s > i; i++) { + array[i] = 444; + } + } + + /// CHECK-START: void Main.narrowingFromLong(int[], int) BCE (before) + /// CHECK-DAG: BoundsCheck loop:{{B\d+}} + // + /// CHECK-START: void Main.narrowingFromLong(int[], int) BCE (after) + /// CHECK-DAG: BoundsCheck loop:{{B\d+}} + public static void narrowingFromLong(int[] array, int n) { + // Parallel induction in long precision that is narrowed provides type + // conversion challenges for BCE in deopt arithmetic when combined + // with the int loop induction. Therefore, currently skipped. + long l = 0; + for (int i = 0; i < n; i++, l++) { + array[(int)l] = 888; + } + } + // // Verifier. // @@ -316,6 +369,38 @@ public class Main { } catch (ArrayIndexOutOfBoundsException e) { } + shortBound1(a, (short)a.length); + for (int i = 0; i < a.length; i++) { + expectEquals(222, a[i]); + } + shortBound2(a, (short)a.length); + for (int i = 0; i < a.length; i++) { + expectEquals(444, a[i]); + } + + try { + shortBound1(a, (short)(a.length + 1)); + throw new Error("Should throw AIOOBE"); + } catch (ArrayIndexOutOfBoundsException e) { + } + for (int i = 0; i < a.length; i++) { + expectEquals(222, a[i]); + } + + try { + shortBound2(a, (short)(a.length + 1)); + throw new Error("Should throw AIOOBE"); + } catch (ArrayIndexOutOfBoundsException e) { + } + for (int i = 0; i < a.length; i++) { + expectEquals(444, a[i]); + } + + narrowingFromLong(a, a.length); + for (int i = 0; i < a.length; i++) { + expectEquals(888, a[i]); + } + System.out.println("passed"); } |