1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 public class Main { 18 19 /** 20 * Check that the intermediate address computation is not reordered or merged 21 * across the call to Math.abs(). 22 */ 23 24 /// CHECK-START-ARM: void Main.main(java.lang.String[]) instruction_simplifier_arm (before) 25 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 26 /// CHECK-DAG: <<Array:l\d+>> NullCheck 27 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 28 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Array>>,<<Index>>] 29 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 30 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 31 /// CHECK-DAG: ArraySet [<<Array>>,<<Index>>,<<Add>>] 32 33 /// CHECK-START-ARM: void Main.main(java.lang.String[]) instruction_simplifier_arm (after) 34 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 35 /// CHECK-DAG: <<DataOffset:i\d+>> IntConstant 36 /// CHECK-DAG: <<Array:l\d+>> NullCheck 37 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 38 /// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 39 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>] 40 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 41 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 42 /// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 43 /// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>] 44 45 /// CHECK-START-ARM: void Main.main(java.lang.String[]) GVN$after_arch (after) 46 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 47 /// CHECK-DAG: <<DataOffset:i\d+>> IntConstant 48 /// CHECK-DAG: <<Array:l\d+>> NullCheck 49 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 50 /// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 51 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>] 52 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 53 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 54 /// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 55 /// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>] 56 57 58 /// CHECK-START-ARM64: void Main.main(java.lang.String[]) instruction_simplifier_arm64 (before) 59 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 60 /// CHECK-DAG: <<Array:l\d+>> NullCheck 61 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 62 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Array>>,<<Index>>] 63 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 64 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 65 /// CHECK-DAG: ArraySet [<<Array>>,<<Index>>,<<Add>>] 66 67 /// CHECK-START-ARM64: void Main.main(java.lang.String[]) instruction_simplifier_arm64 (after) 68 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 69 /// CHECK-DAG: <<DataOffset:i\d+>> IntConstant 70 /// CHECK-DAG: <<Array:l\d+>> NullCheck 71 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 72 /// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 73 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>] 74 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 75 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 76 /// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 77 /// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>] 78 79 /// CHECK-START-ARM64: void Main.main(java.lang.String[]) GVN$after_arch (after) 80 /// CHECK-DAG: <<ConstM42:i\d+>> IntConstant -42 81 /// CHECK-DAG: <<DataOffset:i\d+>> IntConstant 82 /// CHECK-DAG: <<Array:l\d+>> NullCheck 83 /// CHECK-DAG: <<Index:i\d+>> BoundsCheck 84 /// CHECK-DAG: <<Address1:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 85 /// CHECK-DAG: <<ArrayGet:i\d+>> ArrayGet [<<Address1>>,<<Index>>] 86 /// CHECK-DAG: <<AbsM42:i\d+>> InvokeStaticOrDirect [<<ConstM42>>] intrinsic:MathAbsInt 87 /// CHECK-DAG: <<Add:i\d+>> Add [<<ArrayGet>>,<<AbsM42>>] 88 /// CHECK-DAG: <<Address2:i\d+>> IntermediateAddress [<<Array>>,<<DataOffset>>] 89 /// CHECK-DAG: ArraySet [<<Address2>>,<<Index>>,<<Add>>] 90 main(String[] args)91 public static void main(String[] args) { 92 array[index] += Math.abs(-42); 93 } 94 95 static int index = 0; 96 static int[] array = new int[2]; 97 } 98