/* * Copyright (C) 2015 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 { public static void assertIntEquals(int expected, int result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } /** * Test that HArrayGet with a constant index is not split. */ /// CHECK-START-ARM64: int Main.constantIndexGet(int[]) instruction_simplifier_arm64 (before) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArrayGet [<>,<>] /// CHECK-START-ARM64: int Main.constantIndexGet(int[]) instruction_simplifier_arm64 (after) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArrayGet [<>,<>] /// CHECK-START-ARM: int Main.constantIndexGet(int[]) instruction_simplifier_arm (before) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArrayGet [<>,<>] /// CHECK-START-ARM: int Main.constantIndexGet(int[]) instruction_simplifier_arm (after) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArrayGet [<>,<>] public static int constantIndexGet(int array[]) { return array[1]; } /** * Test that HArraySet with a constant index is not split. */ /// CHECK-START-ARM64: void Main.constantIndexSet(int[]) instruction_simplifier_arm64 (before) /// CHECK: <> IntConstant 2 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: void Main.constantIndexSet(int[]) instruction_simplifier_arm64 (after) /// CHECK: <> IntConstant 2 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: void Main.constantIndexSet(int[]) instruction_simplifier_arm (before) /// CHECK: <> IntConstant 2 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: void Main.constantIndexSet(int[]) instruction_simplifier_arm (after) /// CHECK: <> IntConstant 2 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<>,<>,<>] public static void constantIndexSet(int array[]) { array[1] = 2; } /** * Test basic splitting of HArrayGet. */ /// CHECK-START-ARM64: int Main.get(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArrayGet [<>,<>] /// CHECK-START-ARM64: int Main.get(int[], int) instruction_simplifier_arm64 (after) /// CHECK: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArrayGet [<
>,<>] /// CHECK-START-ARM: int Main.get(int[], int) instruction_simplifier_arm (before) /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArrayGet [<>,<>] /// CHECK-START-ARM: int Main.get(int[], int) instruction_simplifier_arm (after) /// CHECK: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArrayGet [<
>,<>] public static int get(int array[], int index) { return array[index]; } /** * Test basic splitting of HArraySet. */ /// CHECK-START-ARM64: void Main.set(int[], int, int) instruction_simplifier_arm64 (before) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <> ParameterValue /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: void Main.set(int[], int, int) instruction_simplifier_arm64 (after) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <> ParameterValue /// CHECK: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<
>,<>,<>] /// CHECK-START-ARM: void Main.set(int[], int, int) instruction_simplifier_arm (before) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <> ParameterValue /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: void Main.set(int[], int, int) instruction_simplifier_arm (after) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <> ParameterValue /// CHECK: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<
>,<>,<>] public static void set(int array[], int index, int value) { array[index] = value; } /** * Check that the intermediate address can be shared after GVN. */ /// CHECK-START-ARM64: void Main.getSet(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: void Main.getSet(int[], int) instruction_simplifier_arm64 (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: void Main.getSet(int[], int) GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<
>,<>] /// CHECK: <> Add [<>,<>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<>,<>] /// CHECK-START-ARM: void Main.getSet(int[], int) instruction_simplifier_arm (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: void Main.getSet(int[], int) instruction_simplifier_arm (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<>] /// CHECK-START-ARM: void Main.getSet(int[], int) GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<
>,<>] /// CHECK: <> Add [<>,<>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<>,<>] public static void getSet(int array[], int index) { array[index] = array[index] + 1; } /** * Check that the intermediate address computation is not reordered or merged * across IRs that can trigger GC. */ /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) instruction_simplifier_arm64 (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: int[] Main.accrossGC(int[], int) instruction_simplifier_arm (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: int[] Main.accrossGC(int[], int) instruction_simplifier_arm (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<>] /// CHECK-START-ARM: int[] Main.accrossGC(int[], int) GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant /// CHECK: <> NullCheck /// CHECK: <> BoundsCheck /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Add [<>,<>] /// CHECK: NewArray /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArraySet [<>,<>,<>] public static int[] accrossGC(int array[], int index) { int tmp = array[index] + 1; int[] new_array = new int[1]; array[index] = tmp; return new_array; } /** * Test that the intermediate address is shared between array accesses after * the bounds check have been removed by BCE. */ // For checker tests `instruction_simplifier_ (after)` below, by the time we reach // the architecture-specific instruction simplifier, BCE has removed the bounds checks in // the loop. // Note that we do not care that the `DataOffset` is `12`. But if we do not // specify it and any other `IntConstant` appears before that instruction, // checker will match the previous `IntConstant`, and we will thus fail the // check. /// CHECK-START-ARM64: int Main.canMergeAfterBCE1() instruction_simplifier_arm64 (before) /// CHECK: <> IntConstant 7 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Div [<>,<>] /// CHECK: ArraySet [<>,<>,<
>] /// CHECK-START-ARM64: int Main.canMergeAfterBCE1() instruction_simplifier_arm64 (after) /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Div [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<
>] /// CHECK-START-ARM64: int Main.canMergeAfterBCE1() GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<
>,<>] /// CHECK: <> Div [<>,<>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<>,<
>] /// CHECK-START-ARM: int Main.canMergeAfterBCE1() instruction_simplifier_arm (before) /// CHECK: <> IntConstant 7 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> ArrayGet [<>,<>] /// CHECK: <> Div [<>,<>] /// CHECK: ArraySet [<>,<>,<
>] /// CHECK-START-ARM: int Main.canMergeAfterBCE1() instruction_simplifier_arm (after) /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: <> ArrayGet [<>,<>] /// CHECK: <> Div [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK-NEXT: ArraySet [<>,<>,<
>] /// CHECK-START-ARM: int Main.canMergeAfterBCE1() GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: <> ArrayGet [<
>,<>] /// CHECK: <> Div [<>,<>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<>,<
>] public static int canMergeAfterBCE1() { int[] array = {0, 7, 14, 21, 28, 35, 42}; for (int i = 0; i < array.length; i++) { array[i] = array[i] / 7; } return array[array.length - 1]; } /** * This test case is similar to `canMergeAfterBCE1`, but with different * indexes for the accesses. */ /// CHECK-START-ARM64: int Main.canMergeAfterBCE2() instruction_simplifier_arm64 (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: ArraySet [<>,<>,<>] // Note that we do not care that the `DataOffset` is `12`. But if we do not // specify it and any other `IntConstant` appears before that instruction, // checker will match the previous `IntConstant`, and we will thus fail the // check. /// CHECK-START-ARM64: int Main.canMergeAfterBCE2() instruction_simplifier_arm64 (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM64: int Main.canMergeAfterBCE2() GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<
>,<>] /// CHECK-DAG: <> ArrayGet [<
>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: ArraySet [<
>,<>,<>] // There should be only one intermediate address computation in the loop. /// CHECK-START-ARM64: int Main.canMergeAfterBCE2() GVN$after_arch (after) /// CHECK: IntermediateAddress /// CHECK-NOT: IntermediateAddress /// CHECK-START-ARM: int Main.canMergeAfterBCE2() instruction_simplifier_arm (before) /// CHECK: <> IntConstant 1 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: int Main.canMergeAfterBCE2() instruction_simplifier_arm (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArraySet [<>,<>,<>] /// CHECK-START-ARM: int Main.canMergeAfterBCE2() GVN$after_arch (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 12 /// CHECK: <> NewArray /// CHECK: <> Phi /// CHECK: If // -------------- Loop /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> IntermediateAddress [<>,<>] /// CHECK-DAG: <> ArrayGet [<
>,<>] /// CHECK-DAG: <> ArrayGet [<
>,<>] /// CHECK: <> Shl [<>,<>] /// CHECK: ArraySet [<
>,<>,<>] /// CHECK-START-ARM: int Main.canMergeAfterBCE2() GVN$after_arch (after) /// CHECK: IntermediateAddress /// CHECK-NOT: IntermediateAddress public static int canMergeAfterBCE2() { int[] array = {128, 64, 32, 8, 4, 2 }; for (int i = 0; i < array.length - 1; i++) { array[i + 1] = array[i] << array[i + 1]; } return array[array.length - 1]; } /// CHECK-START-ARM: int Main.checkLongFloatDouble() instruction_simplifier_arm (before) /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> Phi /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-START-ARM: int Main.checkLongFloatDouble() instruction_simplifier_arm (after) /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> NewArray /// CHECK-DAG: <> Phi /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-DAG: ArrayGet [<>,<>] /// CHECK-START-ARM: int Main.checkLongFloatDouble() instruction_simplifier_arm (after) /// CHECK-NOT: IntermediateAddress public static int checkLongFloatDouble() { long[] array_long = {0, 1, 2, 3}; float[] array_float = {(float)0.0, (float)1.0, (float)2.0, (float)3.0}; double[] array_double = {0.0, 1.0, 2.0, 3.0}; double s = 0.0; for (int i = 0; i < 4; i++) { s += (double)array_long[i] + (double)array_float[i] + array_double[i]; } return (int)s; } // // Check that IntermediateAddress can be shared across BoundsCheck, DivZeroCheck and NullCheck - // instruction which have fatal slow paths. // /// CHECK-START-{ARM,ARM64}: void Main.checkGVNForFatalChecks(int, int, char[], int[]) GVN$after_arch (before) /// CHECK: IntermediateAddress /// CHECK: IntermediateAddress // /// CHECK-NOT: IntermediateAddress /// CHECK-START-{ARM,ARM64}: void Main.checkGVNForFatalChecks(int, int, char[], int[]) GVN$after_arch (after) /// CHECK: IntermediateAddress // /// CHECK-NOT: IntermediateAddress public final static void checkGVNForFatalChecks(int begin, int end, char[] buf1, int[] buf2) { buf1[begin] = 'a'; buf2[0] = begin / end; buf1[end] = 'n'; } // // Check that IntermediateAddress can be shared for object ArrayGets. // /// CHECK-START-ARM64: int Main.checkObjectArrayGet(int, java.lang.Integer[], java.lang.Integer[]) instruction_simplifier_arm64 (before) /// CHECK: <> ParameterValue /// CHECK: <> NullCheck [<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK-START-ARM64: int Main.checkObjectArrayGet(int, java.lang.Integer[], java.lang.Integer[]) instruction_simplifier_arm64 (after) /// CHECK: <> ParameterValue /// CHECK: <> IntConstant 12 /// CHECK: <> NullCheck [<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] // /// CHECK-NOT: IntermediateAddress /// CHECK-START-ARM64: int Main.checkObjectArrayGet(int, java.lang.Integer[], java.lang.Integer[]) GVN$after_arch (after) /// CHECK: <> ParameterValue /// CHECK: <> IntConstant 12 /// CHECK: <> NullCheck [<>] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: <> IntermediateAddress [<>,<>] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] /// CHECK: ArraySet [<>,{{i\d+}},{{l\d+}}] // /// CHECK-NOT: IntermediateAddress public final static int checkObjectArrayGet(int index, Integer[] a, Integer[] b) { Integer five = Integer.valueOf(5); int tmp1 = a[index]; tmp1 += a[index + 1]; a[index + 1] = five; tmp1 += a[index + 2]; a[index + 2] = five; a[index + 3] = five; return tmp1; } /// CHECK-START-ARM64: int Main.testIntAddressObjDisasm(java.lang.Integer[], int) disassembly (after) /// CHECK: <> IntermediateAddress /// CHECK: add w<>, {{w\d+}}, #0xc /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ldr {{w\d+}}, [x<>, x{{\d+}}, lsl #2] /// CHECK: ArrayGet [<>,{{i\d+}}] /// CHECK: ldr {{w\d+}}, [x<>, x{{\d+}}, lsl #2] /// CHECK-START-ARM64: int Main.testIntAddressObjDisasm(java.lang.Integer[], int) disassembly (after) /// CHECK: add {{w\d+}}, {{w\d+}}, #0xc /// CHECK-NOT: add {{w\d+}}, {{w\d+}}, #0xc private int testIntAddressObjDisasm(Integer[] obj, int x) { return obj[x] + obj[x + 1]; } public final static int ARRAY_SIZE = 128; public static void main(String[] args) { int[] array = {123, 456, 789}; assertIntEquals(456, constantIndexGet(array)); constantIndexSet(array); assertIntEquals(2, array[1]); assertIntEquals(789, get(array, 2)); set(array, 1, 456); assertIntEquals(456, array[1]); getSet(array, 0); assertIntEquals(124, array[0]); accrossGC(array, 0); assertIntEquals(125, array[0]); assertIntEquals(6, canMergeAfterBCE1()); assertIntEquals(2097152, canMergeAfterBCE2()); assertIntEquals(18, checkLongFloatDouble()); char[] c1 = new char[ARRAY_SIZE]; int[] i1 = new int[ARRAY_SIZE]; checkGVNForFatalChecks(1, 2, c1, i1); assertIntEquals('n', c1[2]); } }