1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker import java.lang.reflect.Method; 18*795d594fSAndroid Build Coastguard Worker 19*795d594fSAndroid Build Coastguard Worker public class Main { 20*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(boolean expected, boolean result)21*795d594fSAndroid Build Coastguard Worker public static void assertBooleanEquals(boolean expected, boolean result) { 22*795d594fSAndroid Build Coastguard Worker if (expected != result) { 23*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 24*795d594fSAndroid Build Coastguard Worker } 25*795d594fSAndroid Build Coastguard Worker } 26*795d594fSAndroid Build Coastguard Worker assertIntEquals(int expected, int result)27*795d594fSAndroid Build Coastguard Worker public static void assertIntEquals(int expected, int result) { 28*795d594fSAndroid Build Coastguard Worker if (expected != result) { 29*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 30*795d594fSAndroid Build Coastguard Worker } 31*795d594fSAndroid Build Coastguard Worker } 32*795d594fSAndroid Build Coastguard Worker assertLongEquals(long expected, long result)33*795d594fSAndroid Build Coastguard Worker public static void assertLongEquals(long expected, long result) { 34*795d594fSAndroid Build Coastguard Worker if (expected != result) { 35*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 36*795d594fSAndroid Build Coastguard Worker } 37*795d594fSAndroid Build Coastguard Worker } 38*795d594fSAndroid Build Coastguard Worker assertFloatEquals(float expected, float result)39*795d594fSAndroid Build Coastguard Worker public static void assertFloatEquals(float expected, float result) { 40*795d594fSAndroid Build Coastguard Worker if (expected != result) { 41*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 42*795d594fSAndroid Build Coastguard Worker } 43*795d594fSAndroid Build Coastguard Worker } 44*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(double expected, double result)45*795d594fSAndroid Build Coastguard Worker public static void assertDoubleEquals(double expected, double result) { 46*795d594fSAndroid Build Coastguard Worker if (expected != result) { 47*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 48*795d594fSAndroid Build Coastguard Worker } 49*795d594fSAndroid Build Coastguard Worker } 50*795d594fSAndroid Build Coastguard Worker assertStringEquals(String expected, String result)51*795d594fSAndroid Build Coastguard Worker public static void assertStringEquals(String expected, String result) { 52*795d594fSAndroid Build Coastguard Worker if (expected == null ? result != null : !expected.equals(result)) { 53*795d594fSAndroid Build Coastguard Worker throw new Error("Expected: " + expected + ", found: " + result); 54*795d594fSAndroid Build Coastguard Worker } 55*795d594fSAndroid Build Coastguard Worker } 56*795d594fSAndroid Build Coastguard Worker 57*795d594fSAndroid Build Coastguard Worker /** 58*795d594fSAndroid Build Coastguard Worker * Tiny programs exercising optimizations of arithmetic identities. 59*795d594fSAndroid Build Coastguard Worker */ 60*795d594fSAndroid Build Coastguard Worker 61*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (before) 62*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 63*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 64*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:j\d+>> Add [<<Const0>>,<<Arg>>] 65*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 66*795d594fSAndroid Build Coastguard Worker 67*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) 68*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 69*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 70*795d594fSAndroid Build Coastguard Worker 71*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) 72*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 73*795d594fSAndroid Build Coastguard Worker $noinline$Add0(long arg)74*795d594fSAndroid Build Coastguard Worker public static long $noinline$Add0(long arg) { 75*795d594fSAndroid Build Coastguard Worker return 0 + arg; 76*795d594fSAndroid Build Coastguard Worker } 77*795d594fSAndroid Build Coastguard Worker 78*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (before) 79*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 80*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 81*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 82*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstM3:i\d+>> IntConstant -3 83*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 84*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add1:i\d+>> Add [<<ArgValue>>,<<Const1>>] 85*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add2:i\d+>> Add [<<Add1>>,<<Const2>>] 86*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add2>>,<<ConstM3>>] 87*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add4:i\d+>> Add [<<Add3>>,<<Const4>>] 88*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add4>>] 89*795d594fSAndroid Build Coastguard Worker 90*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (after) 91*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 92*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 93*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const4>>] 94*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 95*795d594fSAndroid Build Coastguard Worker $noinline$AddAddSubAddConst(int arg)96*795d594fSAndroid Build Coastguard Worker public static int $noinline$AddAddSubAddConst(int arg) { 97*795d594fSAndroid Build Coastguard Worker return arg + 1 + 2 - 3 + 4; 98*795d594fSAndroid Build Coastguard Worker } 99*795d594fSAndroid Build Coastguard Worker 100*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (before) 101*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 102*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 103*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<ConstF>>] 104*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 105*795d594fSAndroid Build Coastguard Worker 106*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) 107*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 108*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 109*795d594fSAndroid Build Coastguard Worker 110*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) 111*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 112*795d594fSAndroid Build Coastguard Worker $noinline$AndAllOnes(int arg)113*795d594fSAndroid Build Coastguard Worker public static int $noinline$AndAllOnes(int arg) { 114*795d594fSAndroid Build Coastguard Worker return arg & -1; 115*795d594fSAndroid Build Coastguard Worker } 116*795d594fSAndroid Build Coastguard Worker 117*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (before) 118*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 119*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 120*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const15:i\d+>> IntConstant 15 121*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] 122*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const15>>] 123*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 124*795d594fSAndroid Build Coastguard Worker 125*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) 126*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 127*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 128*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] 129*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 130*795d594fSAndroid Build Coastguard Worker 131*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) 132*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 133*795d594fSAndroid Build Coastguard Worker $noinline$UShr28And15(int arg)134*795d594fSAndroid Build Coastguard Worker public static int $noinline$UShr28And15(int arg) { 135*795d594fSAndroid Build Coastguard Worker return (arg >>> 28) & 15; 136*795d594fSAndroid Build Coastguard Worker } 137*795d594fSAndroid Build Coastguard Worker 138*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (before) 139*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 140*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 141*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const15:j\d+>> LongConstant 15 142*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] 143*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const15>>] 144*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 145*795d594fSAndroid Build Coastguard Worker 146*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) 147*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 148*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 149*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] 150*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 151*795d594fSAndroid Build Coastguard Worker 152*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) 153*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 154*795d594fSAndroid Build Coastguard Worker $noinline$UShr60And15(long arg)155*795d594fSAndroid Build Coastguard Worker public static long $noinline$UShr60And15(long arg) { 156*795d594fSAndroid Build Coastguard Worker return (arg >>> 60) & 15; 157*795d594fSAndroid Build Coastguard Worker } 158*795d594fSAndroid Build Coastguard Worker 159*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (before) 160*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 161*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 162*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 163*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] 164*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>] 165*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 166*795d594fSAndroid Build Coastguard Worker 167*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (after) 168*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 169*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 170*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 171*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] 172*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>] 173*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 174*795d594fSAndroid Build Coastguard Worker $noinline$UShr28And7(int arg)175*795d594fSAndroid Build Coastguard Worker public static int $noinline$UShr28And7(int arg) { 176*795d594fSAndroid Build Coastguard Worker return (arg >>> 28) & 7; 177*795d594fSAndroid Build Coastguard Worker } 178*795d594fSAndroid Build Coastguard Worker 179*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (before) 180*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 181*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 182*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 183*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] 184*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>] 185*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 186*795d594fSAndroid Build Coastguard Worker 187*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (after) 188*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 189*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 190*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 191*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] 192*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>] 193*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 194*795d594fSAndroid Build Coastguard Worker $noinline$UShr60And7(long arg)195*795d594fSAndroid Build Coastguard Worker public static long $noinline$UShr60And7(long arg) { 196*795d594fSAndroid Build Coastguard Worker return (arg >>> 60) & 7; 197*795d594fSAndroid Build Coastguard Worker } 198*795d594fSAndroid Build Coastguard Worker 199*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (before) 200*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 201*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 202*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 203*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] 204*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const255>>] 205*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 206*795d594fSAndroid Build Coastguard Worker 207*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) 208*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 209*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 210*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const24>>] 211*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 212*795d594fSAndroid Build Coastguard Worker 213*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) 214*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 215*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 216*795d594fSAndroid Build Coastguard Worker $noinline$Shr24And255(int arg)217*795d594fSAndroid Build Coastguard Worker public static int $noinline$Shr24And255(int arg) { 218*795d594fSAndroid Build Coastguard Worker return (arg >> 24) & 255; 219*795d594fSAndroid Build Coastguard Worker } 220*795d594fSAndroid Build Coastguard Worker 221*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (before) 222*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 223*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const25:i\d+>> IntConstant 25 224*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 225*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const25>>] 226*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] 227*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 228*795d594fSAndroid Build Coastguard Worker 229*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) 230*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 231*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const25:i\d+>> IntConstant 25 232*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const25>>] 233*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 234*795d594fSAndroid Build Coastguard Worker 235*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) 236*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 237*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 238*795d594fSAndroid Build Coastguard Worker $noinline$Shr25And127(int arg)239*795d594fSAndroid Build Coastguard Worker public static int $noinline$Shr25And127(int arg) { 240*795d594fSAndroid Build Coastguard Worker return (arg >> 25) & 127; 241*795d594fSAndroid Build Coastguard Worker } 242*795d594fSAndroid Build Coastguard Worker 243*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (before) 244*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 245*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 246*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:j\d+>> LongConstant 255 247*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] 248*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const255>>] 249*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 250*795d594fSAndroid Build Coastguard Worker 251*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) 252*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 253*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 254*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const56>>] 255*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 256*795d594fSAndroid Build Coastguard Worker 257*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) 258*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 259*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 260*795d594fSAndroid Build Coastguard Worker $noinline$Shr56And255(long arg)261*795d594fSAndroid Build Coastguard Worker public static long $noinline$Shr56And255(long arg) { 262*795d594fSAndroid Build Coastguard Worker return (arg >> 56) & 255; 263*795d594fSAndroid Build Coastguard Worker } 264*795d594fSAndroid Build Coastguard Worker 265*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (before) 266*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 267*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const57:i\d+>> IntConstant 57 268*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 269*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const57>>] 270*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] 271*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 272*795d594fSAndroid Build Coastguard Worker 273*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) 274*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 275*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const57:i\d+>> IntConstant 57 276*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const57>>] 277*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 278*795d594fSAndroid Build Coastguard Worker 279*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) 280*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 281*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 282*795d594fSAndroid Build Coastguard Worker $noinline$Shr57And127(long arg)283*795d594fSAndroid Build Coastguard Worker public static long $noinline$Shr57And127(long arg) { 284*795d594fSAndroid Build Coastguard Worker return (arg >> 57) & 127; 285*795d594fSAndroid Build Coastguard Worker } 286*795d594fSAndroid Build Coastguard Worker 287*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (before) 288*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 289*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 290*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 291*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] 292*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] 293*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 294*795d594fSAndroid Build Coastguard Worker 295*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (after) 296*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 297*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 298*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 299*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] 300*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] 301*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 302*795d594fSAndroid Build Coastguard Worker $noinline$Shr24And127(int arg)303*795d594fSAndroid Build Coastguard Worker public static int $noinline$Shr24And127(int arg) { 304*795d594fSAndroid Build Coastguard Worker return (arg >> 24) & 127; 305*795d594fSAndroid Build Coastguard Worker } 306*795d594fSAndroid Build Coastguard Worker 307*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (before) 308*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 309*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 310*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 311*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] 312*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] 313*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 314*795d594fSAndroid Build Coastguard Worker 315*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (after) 316*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 317*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 318*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 319*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] 320*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] 321*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 322*795d594fSAndroid Build Coastguard Worker $noinline$Shr56And127(long arg)323*795d594fSAndroid Build Coastguard Worker public static long $noinline$Shr56And127(long arg) { 324*795d594fSAndroid Build Coastguard Worker return (arg >> 56) & 127; 325*795d594fSAndroid Build Coastguard Worker } 326*795d594fSAndroid Build Coastguard Worker 327*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (before) 328*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 329*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 330*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:j\d+>> Div [<<Arg>>,<<Const1>>] 331*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 332*795d594fSAndroid Build Coastguard Worker 333*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) 334*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 335*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 336*795d594fSAndroid Build Coastguard Worker 337*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) 338*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div 339*795d594fSAndroid Build Coastguard Worker $noinline$Div1(long arg)340*795d594fSAndroid Build Coastguard Worker public static long $noinline$Div1(long arg) { 341*795d594fSAndroid Build Coastguard Worker return arg / 1; 342*795d594fSAndroid Build Coastguard Worker } 343*795d594fSAndroid Build Coastguard Worker 344*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (before) 345*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 346*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 347*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:i\d+>> Div [<<Arg>>,<<ConstN1>>] 348*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 349*795d594fSAndroid Build Coastguard Worker 350*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) 351*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 352*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] 353*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 354*795d594fSAndroid Build Coastguard Worker 355*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) 356*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div 357*795d594fSAndroid Build Coastguard Worker $noinline$DivN1(int arg)358*795d594fSAndroid Build Coastguard Worker public static int $noinline$DivN1(int arg) { 359*795d594fSAndroid Build Coastguard Worker return arg / -1; 360*795d594fSAndroid Build Coastguard Worker } 361*795d594fSAndroid Build Coastguard Worker 362*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (before) 363*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 364*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 365*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const1>>,<<Arg>>] 366*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 367*795d594fSAndroid Build Coastguard Worker 368*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) 369*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 370*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 371*795d594fSAndroid Build Coastguard Worker 372*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) 373*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Mul 374*795d594fSAndroid Build Coastguard Worker $noinline$Mul1(long arg)375*795d594fSAndroid Build Coastguard Worker public static long $noinline$Mul1(long arg) { 376*795d594fSAndroid Build Coastguard Worker return arg * 1; 377*795d594fSAndroid Build Coastguard Worker } 378*795d594fSAndroid Build Coastguard Worker 379*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (before) 380*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 381*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 382*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Arg>>,<<ConstN1>>] 383*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 384*795d594fSAndroid Build Coastguard Worker 385*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) 386*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 387*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] 388*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 389*795d594fSAndroid Build Coastguard Worker 390*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) 391*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Mul 392*795d594fSAndroid Build Coastguard Worker $noinline$MulN1(int arg)393*795d594fSAndroid Build Coastguard Worker public static int $noinline$MulN1(int arg) { 394*795d594fSAndroid Build Coastguard Worker return arg * -1; 395*795d594fSAndroid Build Coastguard Worker } 396*795d594fSAndroid Build Coastguard Worker 397*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (before) 398*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 399*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const128:j\d+>> LongConstant 128 400*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const128>>,<<Arg>>] 401*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 402*795d594fSAndroid Build Coastguard Worker 403*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) 404*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 405*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 406*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Arg>>,<<Const7>>] 407*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 408*795d594fSAndroid Build Coastguard Worker 409*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) 410*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Mul 411*795d594fSAndroid Build Coastguard Worker $noinline$MulPowerOfTwo128(long arg)412*795d594fSAndroid Build Coastguard Worker public static long $noinline$MulPowerOfTwo128(long arg) { 413*795d594fSAndroid Build Coastguard Worker return arg * 128; 414*795d594fSAndroid Build Coastguard Worker } 415*795d594fSAndroid Build Coastguard Worker 416*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (before) 417*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue 418*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const10:j\d+>> LongConstant 10 419*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 420*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const12:j\d+>> LongConstant 12 421*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul1:j\d+>> Mul [<<Const10>>,<<ArgValue>>] 422*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul2:j\d+>> Mul [<<Mul1>>,<<Const11>>] 423*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul3:j\d+>> Mul [<<Mul2>>,<<Const12>>] 424*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul3>>] 425*795d594fSAndroid Build Coastguard Worker 426*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (after) 427*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue 428*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1320:j\d+>> LongConstant 1320 429*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:j\d+>> Mul [<<ArgValue>>,<<Const1320>>] 430*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 431*795d594fSAndroid Build Coastguard Worker $noinline$MulMulMulConst(long arg)432*795d594fSAndroid Build Coastguard Worker public static long $noinline$MulMulMulConst(long arg) { 433*795d594fSAndroid Build Coastguard Worker return 10 * arg * 11 * 12; 434*795d594fSAndroid Build Coastguard Worker } 435*795d594fSAndroid Build Coastguard Worker 436*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (before) 437*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 438*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 439*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<Const0>>] 440*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 441*795d594fSAndroid Build Coastguard Worker 442*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) 443*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 444*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 445*795d594fSAndroid Build Coastguard Worker 446*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) 447*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Or 448*795d594fSAndroid Build Coastguard Worker $noinline$Or0(int arg)449*795d594fSAndroid Build Coastguard Worker public static int $noinline$Or0(int arg) { 450*795d594fSAndroid Build Coastguard Worker return arg | 0; 451*795d594fSAndroid Build Coastguard Worker } 452*795d594fSAndroid Build Coastguard Worker 453*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (before) 454*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 455*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:j\d+>> Or [<<Arg>>,<<Arg>>] 456*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 457*795d594fSAndroid Build Coastguard Worker 458*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) 459*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 460*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 461*795d594fSAndroid Build Coastguard Worker 462*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) 463*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Or 464*795d594fSAndroid Build Coastguard Worker $noinline$OrSame(long arg)465*795d594fSAndroid Build Coastguard Worker public static long $noinline$OrSame(long arg) { 466*795d594fSAndroid Build Coastguard Worker return arg | arg; 467*795d594fSAndroid Build Coastguard Worker } 468*795d594fSAndroid Build Coastguard Worker 469*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (before) 470*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 471*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 472*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Arg>>,<<Const0>>] 473*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 474*795d594fSAndroid Build Coastguard Worker 475*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) 476*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 477*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 478*795d594fSAndroid Build Coastguard Worker 479*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) 480*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 481*795d594fSAndroid Build Coastguard Worker $noinline$Shl0(int arg)482*795d594fSAndroid Build Coastguard Worker public static int $noinline$Shl0(int arg) { 483*795d594fSAndroid Build Coastguard Worker return arg << 0; 484*795d594fSAndroid Build Coastguard Worker } 485*795d594fSAndroid Build Coastguard Worker 486*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (before) 487*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 488*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 489*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const0>>] 490*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shr>>] 491*795d594fSAndroid Build Coastguard Worker 492*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) 493*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 494*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 495*795d594fSAndroid Build Coastguard Worker 496*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) 497*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 498*795d594fSAndroid Build Coastguard Worker $noinline$Shr0(long arg)499*795d594fSAndroid Build Coastguard Worker public static long $noinline$Shr0(long arg) { 500*795d594fSAndroid Build Coastguard Worker return arg >> 0; 501*795d594fSAndroid Build Coastguard Worker } 502*795d594fSAndroid Build Coastguard Worker 503*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (before) 504*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 505*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const64:i\d+>> IntConstant 64 506*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const64>>] 507*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shr>>] 508*795d594fSAndroid Build Coastguard Worker 509*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) 510*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 511*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 512*795d594fSAndroid Build Coastguard Worker 513*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) 514*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 515*795d594fSAndroid Build Coastguard Worker $noinline$Shr64(long arg)516*795d594fSAndroid Build Coastguard Worker public static long $noinline$Shr64(long arg) { 517*795d594fSAndroid Build Coastguard Worker return arg >> 64; 518*795d594fSAndroid Build Coastguard Worker } 519*795d594fSAndroid Build Coastguard Worker 520*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (before) 521*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 522*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 523*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Const0>>] 524*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 525*795d594fSAndroid Build Coastguard Worker 526*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) 527*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 528*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 529*795d594fSAndroid Build Coastguard Worker 530*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) 531*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 532*795d594fSAndroid Build Coastguard Worker $noinline$Sub0(long arg)533*795d594fSAndroid Build Coastguard Worker public static long $noinline$Sub0(long arg) { 534*795d594fSAndroid Build Coastguard Worker return arg - 0; 535*795d594fSAndroid Build Coastguard Worker } 536*795d594fSAndroid Build Coastguard Worker 537*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (before) 538*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 539*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 540*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const0>>,<<Arg>>] 541*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 542*795d594fSAndroid Build Coastguard Worker 543*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) 544*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 545*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] 546*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 547*795d594fSAndroid Build Coastguard Worker 548*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) 549*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 550*795d594fSAndroid Build Coastguard Worker $noinline$SubAliasNeg(int arg)551*795d594fSAndroid Build Coastguard Worker public static int $noinline$SubAliasNeg(int arg) { 552*795d594fSAndroid Build Coastguard Worker return 0 - arg; 553*795d594fSAndroid Build Coastguard Worker } 554*795d594fSAndroid Build Coastguard Worker 555*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (before) 556*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 557*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 558*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 559*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<ArgValue>>] 560*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Sub>>,<<Const6>>] 561*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 562*795d594fSAndroid Build Coastguard Worker 563*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (after) 564*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 565*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const11:i\d+>> IntConstant 11 566*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const11>>,<<ArgValue>>] 567*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 568*795d594fSAndroid Build Coastguard Worker $noinline$SubAddConst1(int arg)569*795d594fSAndroid Build Coastguard Worker public static int $noinline$SubAddConst1(int arg) { 570*795d594fSAndroid Build Coastguard Worker return 5 - arg + 6; 571*795d594fSAndroid Build Coastguard Worker } 572*795d594fSAndroid Build Coastguard Worker 573*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (before) 574*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 575*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14 576*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 577*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const13>>] 578*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const14>>,<<Add>>] 579*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 580*795d594fSAndroid Build Coastguard Worker 581*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (after) 582*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 583*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 584*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const1>>,<<ArgValue>>] 585*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 586*795d594fSAndroid Build Coastguard Worker $noinline$SubAddConst2(int arg)587*795d594fSAndroid Build Coastguard Worker public static int $noinline$SubAddConst2(int arg) { 588*795d594fSAndroid Build Coastguard Worker return 14 - (arg + 13); 589*795d594fSAndroid Build Coastguard Worker } 590*795d594fSAndroid Build Coastguard Worker 591*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (before) 592*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue 593*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const17:j\d+>> LongConstant 17 594*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const18:j\d+>> LongConstant 18 595*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub1:j\d+>> Sub [<<Const18>>,<<ArgValue>>] 596*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub2:j\d+>> Sub [<<Const17>>,<<Sub1>>] 597*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub2>>] 598*795d594fSAndroid Build Coastguard Worker 599*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (after) 600*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue 601*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstM1:j\d+>> LongConstant -1 602*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:j\d+>> Add [<<ArgValue>>,<<ConstM1>>] 603*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 604*795d594fSAndroid Build Coastguard Worker $noinline$SubSubConst(long arg)605*795d594fSAndroid Build Coastguard Worker public static long $noinline$SubSubConst(long arg) { 606*795d594fSAndroid Build Coastguard Worker return 17 - (18 - arg); 607*795d594fSAndroid Build Coastguard Worker } 608*795d594fSAndroid Build Coastguard Worker 609*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (before) 610*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 611*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 612*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const0>>] 613*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 614*795d594fSAndroid Build Coastguard Worker 615*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) 616*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 617*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 618*795d594fSAndroid Build Coastguard Worker 619*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) 620*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr 621*795d594fSAndroid Build Coastguard Worker $noinline$UShr0(long arg)622*795d594fSAndroid Build Coastguard Worker public static long $noinline$UShr0(long arg) { 623*795d594fSAndroid Build Coastguard Worker return arg >>> 0; 624*795d594fSAndroid Build Coastguard Worker } 625*795d594fSAndroid Build Coastguard Worker 626*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (before) 627*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 628*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 629*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Const0>>] 630*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Xor>>] 631*795d594fSAndroid Build Coastguard Worker 632*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) 633*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 634*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 635*795d594fSAndroid Build Coastguard Worker 636*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) 637*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Xor 638*795d594fSAndroid Build Coastguard Worker $noinline$Xor0(int arg)639*795d594fSAndroid Build Coastguard Worker public static int $noinline$Xor0(int arg) { 640*795d594fSAndroid Build Coastguard Worker return arg ^ 0; 641*795d594fSAndroid Build Coastguard Worker } 642*795d594fSAndroid Build Coastguard Worker 643*795d594fSAndroid Build Coastguard Worker /** 644*795d594fSAndroid Build Coastguard Worker * Test that addition or subtraction operation with both inputs negated are 645*795d594fSAndroid Build Coastguard Worker * optimized to use a single negation after the operation. 646*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in 647*795d594fSAndroid Build Coastguard Worker * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. 648*795d594fSAndroid Build Coastguard Worker */ 649*795d594fSAndroid Build Coastguard Worker 650*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (before) 651*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 652*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 653*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] 654*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] 655*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] 656*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 657*795d594fSAndroid Build Coastguard Worker 658*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (after) 659*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 660*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 661*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 662*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] 663*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] 664*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 665*795d594fSAndroid Build Coastguard Worker $noinline$AddNegs1(int arg1, int arg2)666*795d594fSAndroid Build Coastguard Worker public static int $noinline$AddNegs1(int arg1, int arg2) { 667*795d594fSAndroid Build Coastguard Worker return -arg1 + -arg2; 668*795d594fSAndroid Build Coastguard Worker } 669*795d594fSAndroid Build Coastguard Worker 670*795d594fSAndroid Build Coastguard Worker /** 671*795d594fSAndroid Build Coastguard Worker * This is similar to the test-case AddNegs1, but the negations have 672*795d594fSAndroid Build Coastguard Worker * multiple uses. 673*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in 674*795d594fSAndroid Build Coastguard Worker * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. 675*795d594fSAndroid Build Coastguard Worker * The current code won't perform the previous optimization. The 676*795d594fSAndroid Build Coastguard Worker * transformations do not look at other uses of their inputs. As they don't 677*795d594fSAndroid Build Coastguard Worker * know what will happen with other uses, they do not take the risk of 678*795d594fSAndroid Build Coastguard Worker * increasing the register pressure by creating or extending live ranges. 679*795d594fSAndroid Build Coastguard Worker */ 680*795d594fSAndroid Build Coastguard Worker 681*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (before) 682*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 683*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 684*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] 685*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] 686*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] 687*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] 688*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] 689*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 690*795d594fSAndroid Build Coastguard Worker 691*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (after) 692*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 693*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 694*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] 695*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] 696*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] 697*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] 698*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 699*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] 700*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 701*795d594fSAndroid Build Coastguard Worker 702*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$AddNegs2(int, int) GVN (after) 703*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 704*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 705*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] 706*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] 707*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] 708*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Add>>,<<Add>>] 709*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 710*795d594fSAndroid Build Coastguard Worker $noinline$AddNegs2(int arg1, int arg2)711*795d594fSAndroid Build Coastguard Worker public static int $noinline$AddNegs2(int arg1, int arg2) { 712*795d594fSAndroid Build Coastguard Worker int temp1 = -arg1; 713*795d594fSAndroid Build Coastguard Worker int temp2 = -arg2; 714*795d594fSAndroid Build Coastguard Worker return (temp1 + temp2) | (temp1 + temp2); 715*795d594fSAndroid Build Coastguard Worker } 716*795d594fSAndroid Build Coastguard Worker 717*795d594fSAndroid Build Coastguard Worker /** 718*795d594fSAndroid Build Coastguard Worker * This follows test-cases AddNegs1 and AddNegs2. 719*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in 720*795d594fSAndroid Build Coastguard Worker * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. 721*795d594fSAndroid Build Coastguard Worker * The optimization should not happen if it moves an additional instruction in 722*795d594fSAndroid Build Coastguard Worker * the loop. 723*795d594fSAndroid Build Coastguard Worker */ 724*795d594fSAndroid Build Coastguard Worker 725*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (before) 726*795d594fSAndroid Build Coastguard Worker // -------------- Arguments and initial negation operations. 727*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 728*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 729*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] 730*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] 731*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 732*795d594fSAndroid Build Coastguard Worker // -------------- Loop 733*795d594fSAndroid Build Coastguard Worker /// CHECK: SuspendCheck 734*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] 735*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 736*795d594fSAndroid Build Coastguard Worker 737*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (after) 738*795d594fSAndroid Build Coastguard Worker // -------------- Arguments and initial negation operations. 739*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 740*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 741*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] 742*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] 743*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 744*795d594fSAndroid Build Coastguard Worker // -------------- Loop 745*795d594fSAndroid Build Coastguard Worker /// CHECK: SuspendCheck 746*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] 747*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 748*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 749*795d594fSAndroid Build Coastguard Worker $noinline$AddNegs3(long arg1, long arg2)750*795d594fSAndroid Build Coastguard Worker public static long $noinline$AddNegs3(long arg1, long arg2) { 751*795d594fSAndroid Build Coastguard Worker long res = 0; 752*795d594fSAndroid Build Coastguard Worker long n_arg1 = -arg1; 753*795d594fSAndroid Build Coastguard Worker long n_arg2 = -arg2; 754*795d594fSAndroid Build Coastguard Worker for (long i = 0; i < 1; i++) { 755*795d594fSAndroid Build Coastguard Worker res += n_arg1 + n_arg2 + i; 756*795d594fSAndroid Build Coastguard Worker } 757*795d594fSAndroid Build Coastguard Worker return res; 758*795d594fSAndroid Build Coastguard Worker } 759*795d594fSAndroid Build Coastguard Worker 760*795d594fSAndroid Build Coastguard Worker /** 761*795d594fSAndroid Build Coastguard Worker * Test the simplification of an addition with a negated argument into a 762*795d594fSAndroid Build Coastguard Worker * subtraction. 763*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. 764*795d594fSAndroid Build Coastguard Worker */ 765*795d594fSAndroid Build Coastguard Worker 766*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (before) 767*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 768*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 769*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] 770*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:j\d+>> Add [<<Neg>>,<<Arg2>>] 771*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 772*795d594fSAndroid Build Coastguard Worker 773*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) 774*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 775*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 776*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg2>>,<<Arg1>>] 777*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 778*795d594fSAndroid Build Coastguard Worker 779*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) 780*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 781*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 782*795d594fSAndroid Build Coastguard Worker $noinline$AddNeg1(long arg1, long arg2)783*795d594fSAndroid Build Coastguard Worker public static long $noinline$AddNeg1(long arg1, long arg2) { 784*795d594fSAndroid Build Coastguard Worker return -arg1 + arg2; 785*795d594fSAndroid Build Coastguard Worker } 786*795d594fSAndroid Build Coastguard Worker 787*795d594fSAndroid Build Coastguard Worker /** 788*795d594fSAndroid Build Coastguard Worker * This is similar to the test-case AddNeg1, but the negation has two uses. 789*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. 790*795d594fSAndroid Build Coastguard Worker * The current code won't perform the previous optimization. The 791*795d594fSAndroid Build Coastguard Worker * transformations do not look at other uses of their inputs. As they don't 792*795d594fSAndroid Build Coastguard Worker * know what will happen with other uses, they do not take the risk of 793*795d594fSAndroid Build Coastguard Worker * increasing the register pressure by creating or extending live ranges. 794*795d594fSAndroid Build Coastguard Worker */ 795*795d594fSAndroid Build Coastguard Worker 796*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (before) 797*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 798*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 799*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] 800*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] 801*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] 802*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] 803*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 804*795d594fSAndroid Build Coastguard Worker 805*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) 806*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 807*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 808*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] 809*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] 810*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] 811*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] 812*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 813*795d594fSAndroid Build Coastguard Worker 814*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) 815*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 816*795d594fSAndroid Build Coastguard Worker $noinline$AddNeg2(long arg1, long arg2)817*795d594fSAndroid Build Coastguard Worker public static long $noinline$AddNeg2(long arg1, long arg2) { 818*795d594fSAndroid Build Coastguard Worker long temp = -arg2; 819*795d594fSAndroid Build Coastguard Worker return (arg1 + temp) | (arg1 + temp); 820*795d594fSAndroid Build Coastguard Worker } 821*795d594fSAndroid Build Coastguard Worker 822*795d594fSAndroid Build Coastguard Worker /** 823*795d594fSAndroid Build Coastguard Worker * Test simplification of the `-(-var)` pattern. 824*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. 825*795d594fSAndroid Build Coastguard Worker */ 826*795d594fSAndroid Build Coastguard Worker 827*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (before) 828*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 829*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg>>] 830*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Neg1>>] 831*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg2>>] 832*795d594fSAndroid Build Coastguard Worker 833*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) 834*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 835*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 836*795d594fSAndroid Build Coastguard Worker 837*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) 838*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 839*795d594fSAndroid Build Coastguard Worker $noinline$NegNeg1(long arg)840*795d594fSAndroid Build Coastguard Worker public static long $noinline$NegNeg1(long arg) { 841*795d594fSAndroid Build Coastguard Worker return -(-arg); 842*795d594fSAndroid Build Coastguard Worker } 843*795d594fSAndroid Build Coastguard Worker 844*795d594fSAndroid Build Coastguard Worker /** 845*795d594fSAndroid Build Coastguard Worker * Test 'multi-step' simplification, where a first transformation yields a 846*795d594fSAndroid Build Coastguard Worker * new simplification possibility for the current instruction. 847*795d594fSAndroid Build Coastguard Worker * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` 848*795d594fSAndroid Build Coastguard Worker * and in `InstructionSimplifierVisitor::VisitAdd`. 849*795d594fSAndroid Build Coastguard Worker */ 850*795d594fSAndroid Build Coastguard Worker 851*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (before) 852*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 853*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg>>] 854*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Neg1>>] 855*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg2>>,<<Neg1>>] 856*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 857*795d594fSAndroid Build Coastguard Worker 858*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) 859*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 860*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg>>,<<Arg>>] 861*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 862*795d594fSAndroid Build Coastguard Worker 863*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) 864*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 865*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 866*795d594fSAndroid Build Coastguard Worker 867*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegNeg2(int) constant_folding$after_gvn (after) 868*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const0:i\d+>> IntConstant 0 869*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 870*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 871*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<Const0>>] 872*795d594fSAndroid Build Coastguard Worker $noinline$NegNeg2(int arg)873*795d594fSAndroid Build Coastguard Worker public static int $noinline$NegNeg2(int arg) { 874*795d594fSAndroid Build Coastguard Worker int temp = -arg; 875*795d594fSAndroid Build Coastguard Worker return temp + -temp; 876*795d594fSAndroid Build Coastguard Worker } 877*795d594fSAndroid Build Coastguard Worker 878*795d594fSAndroid Build Coastguard Worker /** 879*795d594fSAndroid Build Coastguard Worker * Test another 'multi-step' simplification, where a first transformation 880*795d594fSAndroid Build Coastguard Worker * yields a new simplification possibility for the current instruction. 881*795d594fSAndroid Build Coastguard Worker * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` 882*795d594fSAndroid Build Coastguard Worker * and in `InstructionSimplifierVisitor::VisitSub`. 883*795d594fSAndroid Build Coastguard Worker */ 884*795d594fSAndroid Build Coastguard Worker 885*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (before) 886*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 887*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 888*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg>>] 889*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const0>>,<<Neg>>] 890*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 891*795d594fSAndroid Build Coastguard Worker 892*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) 893*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 894*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 895*795d594fSAndroid Build Coastguard Worker 896*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) 897*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 898*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 899*795d594fSAndroid Build Coastguard Worker $noinline$NegNeg3(long arg)900*795d594fSAndroid Build Coastguard Worker public static long $noinline$NegNeg3(long arg) { 901*795d594fSAndroid Build Coastguard Worker return 0 - -arg; 902*795d594fSAndroid Build Coastguard Worker } 903*795d594fSAndroid Build Coastguard Worker 904*795d594fSAndroid Build Coastguard Worker /** 905*795d594fSAndroid Build Coastguard Worker * Test that a negated subtraction is simplified to a subtraction with its 906*795d594fSAndroid Build Coastguard Worker * arguments reversed. 907*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. 908*795d594fSAndroid Build Coastguard Worker */ 909*795d594fSAndroid Build Coastguard Worker 910*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (before) 911*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 912*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 913*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] 914*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Sub>>] 915*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 916*795d594fSAndroid Build Coastguard Worker 917*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) 918*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 919*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 920*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg2>>,<<Arg1>>] 921*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 922*795d594fSAndroid Build Coastguard Worker 923*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) 924*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 925*795d594fSAndroid Build Coastguard Worker $noinline$NegSub1(int arg1, int arg2)926*795d594fSAndroid Build Coastguard Worker public static int $noinline$NegSub1(int arg1, int arg2) { 927*795d594fSAndroid Build Coastguard Worker return -(arg1 - arg2); 928*795d594fSAndroid Build Coastguard Worker } 929*795d594fSAndroid Build Coastguard Worker 930*795d594fSAndroid Build Coastguard Worker /** 931*795d594fSAndroid Build Coastguard Worker * This is similar to the test-case NegSub1, but the subtraction has 932*795d594fSAndroid Build Coastguard Worker * multiple uses. 933*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. 934*795d594fSAndroid Build Coastguard Worker * The current code won't perform the previous optimization. The 935*795d594fSAndroid Build Coastguard Worker * transformations do not look at other uses of their inputs. As they don't 936*795d594fSAndroid Build Coastguard Worker * know what will happen with other uses, they do not take the risk of 937*795d594fSAndroid Build Coastguard Worker * increasing the register pressure by creating or extending live ranges. 938*795d594fSAndroid Build Coastguard Worker */ 939*795d594fSAndroid Build Coastguard Worker 940*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (before) 941*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 942*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 943*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] 944*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] 945*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] 946*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] 947*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 948*795d594fSAndroid Build Coastguard Worker 949*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (after) 950*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 951*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 952*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] 953*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] 954*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] 955*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] 956*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 957*795d594fSAndroid Build Coastguard Worker $noinline$NegSub2(int arg1, int arg2)958*795d594fSAndroid Build Coastguard Worker public static int $noinline$NegSub2(int arg1, int arg2) { 959*795d594fSAndroid Build Coastguard Worker int temp = arg1 - arg2; 960*795d594fSAndroid Build Coastguard Worker return -temp | -temp; 961*795d594fSAndroid Build Coastguard Worker } 962*795d594fSAndroid Build Coastguard Worker 963*795d594fSAndroid Build Coastguard Worker /** 964*795d594fSAndroid Build Coastguard Worker * Test the simplification of a subtraction with a negated argument. 965*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. 966*795d594fSAndroid Build Coastguard Worker */ 967*795d594fSAndroid Build Coastguard Worker 968*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (before) 969*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 970*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 971*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] 972*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Neg>>,<<Arg2>>] 973*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Sub>>] 974*795d594fSAndroid Build Coastguard Worker 975*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) 976*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 977*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 978*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] 979*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] 980*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Neg>>] 981*795d594fSAndroid Build Coastguard Worker 982*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) 983*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 984*795d594fSAndroid Build Coastguard Worker $noinline$SubNeg1(int arg1, int arg2)985*795d594fSAndroid Build Coastguard Worker public static int $noinline$SubNeg1(int arg1, int arg2) { 986*795d594fSAndroid Build Coastguard Worker return -arg1 - arg2; 987*795d594fSAndroid Build Coastguard Worker } 988*795d594fSAndroid Build Coastguard Worker 989*795d594fSAndroid Build Coastguard Worker /** 990*795d594fSAndroid Build Coastguard Worker * This is similar to the test-case SubNeg1, but the negation has 991*795d594fSAndroid Build Coastguard Worker * multiple uses. 992*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. 993*795d594fSAndroid Build Coastguard Worker * The current code won't perform the previous optimization. The 994*795d594fSAndroid Build Coastguard Worker * transformations do not look at other uses of their inputs. As they don't 995*795d594fSAndroid Build Coastguard Worker * know what will happen with other uses, they do not take the risk of 996*795d594fSAndroid Build Coastguard Worker * increasing the register pressure by creating or extending live ranges. 997*795d594fSAndroid Build Coastguard Worker */ 998*795d594fSAndroid Build Coastguard Worker 999*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (before) 1000*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 1001*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 1002*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] 1003*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] 1004*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] 1005*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] 1006*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 1007*795d594fSAndroid Build Coastguard Worker 1008*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) 1009*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 1010*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 1011*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] 1012*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] 1013*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] 1014*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] 1015*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Or>>] 1016*795d594fSAndroid Build Coastguard Worker 1017*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) 1018*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 1019*795d594fSAndroid Build Coastguard Worker $noinline$SubNeg2(int arg1, int arg2)1020*795d594fSAndroid Build Coastguard Worker public static int $noinline$SubNeg2(int arg1, int arg2) { 1021*795d594fSAndroid Build Coastguard Worker int temp = -arg1; 1022*795d594fSAndroid Build Coastguard Worker return (temp - arg2) | (temp - arg2); 1023*795d594fSAndroid Build Coastguard Worker } 1024*795d594fSAndroid Build Coastguard Worker 1025*795d594fSAndroid Build Coastguard Worker /** 1026*795d594fSAndroid Build Coastguard Worker * This follows test-cases SubNeg1 and SubNeg2. 1027*795d594fSAndroid Build Coastguard Worker * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. 1028*795d594fSAndroid Build Coastguard Worker * The optimization should not happen if it moves an additional instruction in 1029*795d594fSAndroid Build Coastguard Worker * the loop. 1030*795d594fSAndroid Build Coastguard Worker */ 1031*795d594fSAndroid Build Coastguard Worker 1032*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (before) 1033*795d594fSAndroid Build Coastguard Worker // -------------- Arguments and initial negation operation. 1034*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 1035*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 1036*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] 1037*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 1038*795d594fSAndroid Build Coastguard Worker // -------------- Loop 1039*795d594fSAndroid Build Coastguard Worker /// CHECK: SuspendCheck 1040*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] 1041*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 1042*795d594fSAndroid Build Coastguard Worker 1043*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (after) 1044*795d594fSAndroid Build Coastguard Worker // -------------- Arguments and initial negation operation. 1045*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue 1046*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue 1047*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] 1048*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Goto 1049*795d594fSAndroid Build Coastguard Worker // -------------- Loop 1050*795d594fSAndroid Build Coastguard Worker /// CHECK: SuspendCheck 1051*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] 1052*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Neg 1053*795d594fSAndroid Build Coastguard Worker /// CHECK: Goto 1054*795d594fSAndroid Build Coastguard Worker $noinline$SubNeg3(long arg1, long arg2)1055*795d594fSAndroid Build Coastguard Worker public static long $noinline$SubNeg3(long arg1, long arg2) { 1056*795d594fSAndroid Build Coastguard Worker long res = 0; 1057*795d594fSAndroid Build Coastguard Worker long temp = -arg1; 1058*795d594fSAndroid Build Coastguard Worker for (long i = 0; i < 1; i++) { 1059*795d594fSAndroid Build Coastguard Worker res += temp - arg2 - i; 1060*795d594fSAndroid Build Coastguard Worker } 1061*795d594fSAndroid Build Coastguard Worker return res; 1062*795d594fSAndroid Build Coastguard Worker } 1063*795d594fSAndroid Build Coastguard Worker 1064*795d594fSAndroid Build Coastguard Worker /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (before) 1065*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:z\d+>> ParameterValue 1066*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1067*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1068*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 1069*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<Arg>>] 1070*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Const0>>,<<Const1>>] 1071*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cond:z\d+>> Equal [<<Phi1>>,<<Const2>>] 1072*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<Cond>>] 1073*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi2:i\d+>> Phi [<<Const0>>,<<Const1>>] 1074*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi2>>] 1075*795d594fSAndroid Build Coastguard Worker 1076*795d594fSAndroid Build Coastguard Worker /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (after) 1077*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<True:i\d+>> IntConstant 1 1078*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<True>>] 1079*795d594fSAndroid Build Coastguard Worker $noinline$EqualBoolVsIntConst(boolean arg)1080*795d594fSAndroid Build Coastguard Worker public static boolean $noinline$EqualBoolVsIntConst(boolean arg) { 1081*795d594fSAndroid Build Coastguard Worker // Make calls that will be inlined to make sure the instruction simplifier 1082*795d594fSAndroid Build Coastguard Worker // sees the simplification (dead code elimination will also try to simplify it). 1083*795d594fSAndroid Build Coastguard Worker return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) != 2; 1084*795d594fSAndroid Build Coastguard Worker } 1085*795d594fSAndroid Build Coastguard Worker $inline$ReturnArg(int arg)1086*795d594fSAndroid Build Coastguard Worker public static int $inline$ReturnArg(int arg) { 1087*795d594fSAndroid Build Coastguard Worker return arg; 1088*795d594fSAndroid Build Coastguard Worker } 1089*795d594fSAndroid Build Coastguard Worker 1090*795d594fSAndroid Build Coastguard Worker /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (before) 1091*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:z\d+>> ParameterValue 1092*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1093*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1094*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 1095*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<Arg>>] 1096*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Const0>>,<<Const1>>] 1097*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Phi1>>,<<Const2>>] 1098*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<Cond>>] 1099*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi2:i\d+>> Phi [<<Const0>>,<<Const1>>] 1100*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi2>>] 1101*795d594fSAndroid Build Coastguard Worker 1102*795d594fSAndroid Build Coastguard Worker /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (after) 1103*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<False:i\d+>> IntConstant 0 1104*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<False>>] 1105*795d594fSAndroid Build Coastguard Worker $noinline$NotEqualBoolVsIntConst(boolean arg)1106*795d594fSAndroid Build Coastguard Worker public static boolean $noinline$NotEqualBoolVsIntConst(boolean arg) { 1107*795d594fSAndroid Build Coastguard Worker // Make calls that will be inlined to make sure the instruction simplifier 1108*795d594fSAndroid Build Coastguard Worker // sees the simplification (dead code elimination will also try to simplify it). 1109*795d594fSAndroid Build Coastguard Worker return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) == 2; 1110*795d594fSAndroid Build Coastguard Worker } 1111*795d594fSAndroid Build Coastguard Worker 1112*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (before) 1113*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1114*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 1115*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<Const2>>] 1116*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 1117*795d594fSAndroid Build Coastguard Worker 1118*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) 1119*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1120*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstP5:f\d+>> FloatConstant 0.5 1121*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstP5>>] 1122*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 1123*795d594fSAndroid Build Coastguard Worker 1124*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) 1125*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div 1126*795d594fSAndroid Build Coastguard Worker $noinline$Div2(float arg)1127*795d594fSAndroid Build Coastguard Worker public static float $noinline$Div2(float arg) { 1128*795d594fSAndroid Build Coastguard Worker return arg / 2.0f; 1129*795d594fSAndroid Build Coastguard Worker } 1130*795d594fSAndroid Build Coastguard Worker 1131*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (before) 1132*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1133*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 1134*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<Const2>>] 1135*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 1136*795d594fSAndroid Build Coastguard Worker 1137*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) 1138*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1139*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstP5:d\d+>> DoubleConstant 0.5 1140*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstP5>>] 1141*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 1142*795d594fSAndroid Build Coastguard Worker 1143*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) 1144*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div $noinline$Div2(double arg)1145*795d594fSAndroid Build Coastguard Worker public static double $noinline$Div2(double arg) { 1146*795d594fSAndroid Build Coastguard Worker return arg / 2.0; 1147*795d594fSAndroid Build Coastguard Worker } 1148*795d594fSAndroid Build Coastguard Worker 1149*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (before) 1150*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1151*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstMP25:f\d+>> FloatConstant -0.25 1152*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<ConstMP25>>] 1153*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 1154*795d594fSAndroid Build Coastguard Worker 1155*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) 1156*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1157*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstM4:f\d+>> FloatConstant -4 1158*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstM4>>] 1159*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 1160*795d594fSAndroid Build Coastguard Worker 1161*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) 1162*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div 1163*795d594fSAndroid Build Coastguard Worker $noinline$DivMP25(float arg)1164*795d594fSAndroid Build Coastguard Worker public static float $noinline$DivMP25(float arg) { 1165*795d594fSAndroid Build Coastguard Worker return arg / -0.25f; 1166*795d594fSAndroid Build Coastguard Worker } 1167*795d594fSAndroid Build Coastguard Worker 1168*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (before) 1169*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1170*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstMP25:d\d+>> DoubleConstant -0.25 1171*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<ConstMP25>>] 1172*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Div>>] 1173*795d594fSAndroid Build Coastguard Worker 1174*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) 1175*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1176*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<ConstM4:d\d+>> DoubleConstant -4 1177*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstM4>>] 1178*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Mul>>] 1179*795d594fSAndroid Build Coastguard Worker 1180*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) 1181*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Div $noinline$DivMP25(double arg)1182*795d594fSAndroid Build Coastguard Worker public static double $noinline$DivMP25(double arg) { 1183*795d594fSAndroid Build Coastguard Worker return arg / -0.25f; 1184*795d594fSAndroid Build Coastguard Worker } 1185*795d594fSAndroid Build Coastguard Worker 1186*795d594fSAndroid Build Coastguard Worker /** 1187*795d594fSAndroid Build Coastguard Worker * Test strength reduction of factors of the form (2^n + 1). 1188*795d594fSAndroid Build Coastguard Worker */ 1189*795d594fSAndroid Build Coastguard Worker 1190*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (before) 1191*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1192*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const9:i\d+>> IntConstant 9 1193*795d594fSAndroid Build Coastguard Worker /// CHECK: Mul [<<Arg>>,<<Const9>>] 1194*795d594fSAndroid Build Coastguard Worker 1195*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (after) 1196*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1197*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 1198*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> Shl [<<Arg>>,<<Const3>>] 1199*795d594fSAndroid Build Coastguard Worker /// CHECK-NEXT: Add [<<Arg>>,<<Shift>>] 1200*795d594fSAndroid Build Coastguard Worker $noinline$mulPow2Plus1(int arg)1201*795d594fSAndroid Build Coastguard Worker public static int $noinline$mulPow2Plus1(int arg) { 1202*795d594fSAndroid Build Coastguard Worker return arg * 9; 1203*795d594fSAndroid Build Coastguard Worker } 1204*795d594fSAndroid Build Coastguard Worker 1205*795d594fSAndroid Build Coastguard Worker /** 1206*795d594fSAndroid Build Coastguard Worker * Test strength reduction of factors of the form (2^n - 1). 1207*795d594fSAndroid Build Coastguard Worker */ 1208*795d594fSAndroid Build Coastguard Worker 1209*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (before) 1210*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1211*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const31:j\d+>> LongConstant 31 1212*795d594fSAndroid Build Coastguard Worker /// CHECK: Mul [<<Const31>>,<<Arg>>] 1213*795d594fSAndroid Build Coastguard Worker 1214*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (after) 1215*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1216*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 1217*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:j\d+>> Shl [<<Arg>>,<<Const5>>] 1218*795d594fSAndroid Build Coastguard Worker /// CHECK-NEXT: Sub [<<Shift>>,<<Arg>>] 1219*795d594fSAndroid Build Coastguard Worker $noinline$mulPow2Minus1(long arg)1220*795d594fSAndroid Build Coastguard Worker public static long $noinline$mulPow2Minus1(long arg) { 1221*795d594fSAndroid Build Coastguard Worker return arg * 31; 1222*795d594fSAndroid Build Coastguard Worker } 1223*795d594fSAndroid Build Coastguard Worker 1224*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() instruction_simplifier$after_inlining (before) 1225*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1226*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1227*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1228*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet 1229*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<NE:z\d+>> NotEqual [<<Field>>,<<Const1>>] 1230*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<NE>>] 1231*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const13>>,<<Const54>>] 1232*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi>>] 1233*795d594fSAndroid Build Coastguard Worker 1234*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() select_generator (after) 1235*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet 1236*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1237*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1238*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Select:i\d+>> Select [<<Const54>>,<<Const13>>,<<Field>>] 1239*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Select>>] 1240*795d594fSAndroid Build Coastguard Worker $noinline$booleanFieldNotEqualOne()1241*795d594fSAndroid Build Coastguard Worker public static int $noinline$booleanFieldNotEqualOne() { 1242*795d594fSAndroid Build Coastguard Worker return (booleanField == $inline$true()) ? 13 : 54; 1243*795d594fSAndroid Build Coastguard Worker } 1244*795d594fSAndroid Build Coastguard Worker 1245*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$booleanFieldEqualZero() instruction_simplifier$after_inlining (before) 1246*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1247*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1248*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1249*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet 1250*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<EQ:z\d+>> Equal [<<Field>>,<<Const0>>] 1251*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<EQ>>] 1252*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const13>>,<<Const54>>] 1253*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi>>] 1254*795d594fSAndroid Build Coastguard Worker 1255*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$booleanFieldEqualZero() select_generator (after) 1256*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet 1257*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1258*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1259*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Select:i\d+>> Select [<<Const54>>,<<Const13>>,<<Field>>] 1260*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Select>>] 1261*795d594fSAndroid Build Coastguard Worker $noinline$booleanFieldEqualZero()1262*795d594fSAndroid Build Coastguard Worker public static int $noinline$booleanFieldEqualZero() { 1263*795d594fSAndroid Build Coastguard Worker return (booleanField != $inline$false()) ? 13 : 54; 1264*795d594fSAndroid Build Coastguard Worker } 1265*795d594fSAndroid Build Coastguard Worker 1266*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) instruction_simplifier$after_inlining (before) 1267*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1268*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1269*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1270*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1271*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1272*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1273*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1274*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<LE>>] 1275*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Const1>>,<<Const0>>] 1276*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<NE:z\d+>> NotEqual [<<Phi1>>,<<Const1>>] 1277*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<NE>>] 1278*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi2:i\d+>> Phi [<<Const13>>,<<Const54>>] 1279*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi2>>] 1280*795d594fSAndroid Build Coastguard Worker 1281*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) select_generator (after) 1282*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1283*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1284*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1285*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1286*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1287*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] 1288*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Result>>] 1289*795d594fSAndroid Build Coastguard Worker // Note that we match `LE` from Select because there are two identical 1290*795d594fSAndroid Build Coastguard Worker // LessThanOrEqual instructions. 1291*795d594fSAndroid Build Coastguard Worker $noinline$intConditionNotEqualOne(int i)1292*795d594fSAndroid Build Coastguard Worker public static int $noinline$intConditionNotEqualOne(int i) { 1293*795d594fSAndroid Build Coastguard Worker return ((i > 42) == $inline$true()) ? 13 : 54; 1294*795d594fSAndroid Build Coastguard Worker } 1295*795d594fSAndroid Build Coastguard Worker 1296*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) instruction_simplifier$after_inlining (before) 1297*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1298*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1299*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1300*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1301*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1302*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1303*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1304*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<LE>>] 1305*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Const1>>,<<Const0>>] 1306*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<EQ:z\d+>> Equal [<<Phi1>>,<<Const0>>] 1307*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: If [<<EQ>>] 1308*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Phi2:i\d+>> Phi [<<Const13>>,<<Const54>>] 1309*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Phi2>>] 1310*795d594fSAndroid Build Coastguard Worker 1311*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) select_generator (after) 1312*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1313*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1314*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1315*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1316*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1317*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] 1318*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Result>>] 1319*795d594fSAndroid Build Coastguard Worker // Note that we match `LE` from Select because there are two identical 1320*795d594fSAndroid Build Coastguard Worker // LessThanOrEqual instructions. 1321*795d594fSAndroid Build Coastguard Worker $noinline$intConditionEqualZero(int i)1322*795d594fSAndroid Build Coastguard Worker public static int $noinline$intConditionEqualZero(int i) { 1323*795d594fSAndroid Build Coastguard Worker return ((i > 42) != $inline$false()) ? 13 : 54; 1324*795d594fSAndroid Build Coastguard Worker } 1325*795d594fSAndroid Build Coastguard Worker 1326*795d594fSAndroid Build Coastguard Worker // Test that conditions on float/double are not flipped. 1327*795d594fSAndroid Build Coastguard Worker 1328*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) builder (after) 1329*795d594fSAndroid Build Coastguard Worker /// CHECK: LessThanOrEqual 1330*795d594fSAndroid Build Coastguard Worker 1331*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) instruction_simplifier$before_codegen (after) 1332*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1333*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1334*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1335*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:f\d+>> FloatConstant 42 1336*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1337*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] 1338*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Select>>] 1339*795d594fSAndroid Build Coastguard Worker $noinline$floatConditionNotEqualOne(float f)1340*795d594fSAndroid Build Coastguard Worker public static int $noinline$floatConditionNotEqualOne(float f) { 1341*795d594fSAndroid Build Coastguard Worker return ((f > 42.0f) == true) ? 13 : 54; 1342*795d594fSAndroid Build Coastguard Worker } 1343*795d594fSAndroid Build Coastguard Worker 1344*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$doubleConditionEqualZero(double) builder (after) 1345*795d594fSAndroid Build Coastguard Worker /// CHECK: LessThanOrEqual 1346*795d594fSAndroid Build Coastguard Worker 1347*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$doubleConditionEqualZero(double) instruction_simplifier$before_codegen (after) 1348*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1349*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 1350*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 1351*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 1352*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] 1353*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] 1354*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Select>>] 1355*795d594fSAndroid Build Coastguard Worker $noinline$doubleConditionEqualZero(double d)1356*795d594fSAndroid Build Coastguard Worker public static int $noinline$doubleConditionEqualZero(double d) { 1357*795d594fSAndroid Build Coastguard Worker return ((d > 42.0) != false) ? 13 : 54; 1358*795d594fSAndroid Build Coastguard Worker } 1359*795d594fSAndroid Build Coastguard Worker 1360*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (before) 1361*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1362*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1363*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] 1364*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1365*795d594fSAndroid Build Coastguard Worker 1366*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) 1367*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1368*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 1369*795d594fSAndroid Build Coastguard Worker 1370*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) 1371*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1372*795d594fSAndroid Build Coastguard Worker $noinline$intToDoubleToInt(int value)1373*795d594fSAndroid Build Coastguard Worker public static int $noinline$intToDoubleToInt(int value) { 1374*795d594fSAndroid Build Coastguard Worker // Lossless conversion followed by a conversion back. 1375*795d594fSAndroid Build Coastguard Worker return (int) (double) value; 1376*795d594fSAndroid Build Coastguard Worker } 1377*795d594fSAndroid Build Coastguard Worker 1378*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (before) 1379*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1380*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1381*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] 1382*795d594fSAndroid Build Coastguard Worker 1383*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) 1384*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1385*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{d\d+}} TypeConversion [<<Arg>>] 1386*795d594fSAndroid Build Coastguard Worker 1387*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) 1388*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: TypeConversion 1389*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1390*795d594fSAndroid Build Coastguard Worker $noinline$intToDoubleToIntPrint(int value)1391*795d594fSAndroid Build Coastguard Worker public static String $noinline$intToDoubleToIntPrint(int value) { 1392*795d594fSAndroid Build Coastguard Worker // Lossless conversion followed by a conversion back 1393*795d594fSAndroid Build Coastguard Worker // with another use of the intermediate result. 1394*795d594fSAndroid Build Coastguard Worker double d = (double) value; 1395*795d594fSAndroid Build Coastguard Worker int i = (int) d; 1396*795d594fSAndroid Build Coastguard Worker return "d=" + d + ", i=" + i; 1397*795d594fSAndroid Build Coastguard Worker } 1398*795d594fSAndroid Build Coastguard Worker 1399*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (before) 1400*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 1401*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1402*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] 1403*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1404*795d594fSAndroid Build Coastguard Worker 1405*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) 1406*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 1407*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 1408*795d594fSAndroid Build Coastguard Worker 1409*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) 1410*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1411*795d594fSAndroid Build Coastguard Worker $noinline$byteToDoubleToInt(byte value)1412*795d594fSAndroid Build Coastguard Worker public static int $noinline$byteToDoubleToInt(byte value) { 1413*795d594fSAndroid Build Coastguard Worker // Lossless conversion followed by another conversion, use implicit conversion. 1414*795d594fSAndroid Build Coastguard Worker return (int) (double) value; 1415*795d594fSAndroid Build Coastguard Worker } 1416*795d594fSAndroid Build Coastguard Worker 1417*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (before) 1418*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1419*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1420*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] 1421*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1422*795d594fSAndroid Build Coastguard Worker 1423*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) 1424*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1425*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1426*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1427*795d594fSAndroid Build Coastguard Worker 1428*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) 1429*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: TypeConversion 1430*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1431*795d594fSAndroid Build Coastguard Worker $noinline$floatToDoubleToInt(float value)1432*795d594fSAndroid Build Coastguard Worker public static int $noinline$floatToDoubleToInt(float value) { 1433*795d594fSAndroid Build Coastguard Worker // Lossless conversion followed by another conversion. 1434*795d594fSAndroid Build Coastguard Worker return (int) (double) value; 1435*795d594fSAndroid Build Coastguard Worker } 1436*795d594fSAndroid Build Coastguard Worker 1437*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (before) 1438*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1439*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1440*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] 1441*795d594fSAndroid Build Coastguard Worker 1442*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (after) 1443*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1444*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1445*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] 1446*795d594fSAndroid Build Coastguard Worker $noinline$floatToDoubleToIntPrint(float value)1447*795d594fSAndroid Build Coastguard Worker public static String $noinline$floatToDoubleToIntPrint(float value) { 1448*795d594fSAndroid Build Coastguard Worker // Lossless conversion followed by another conversion with 1449*795d594fSAndroid Build Coastguard Worker // an extra use of the intermediate result. 1450*795d594fSAndroid Build Coastguard Worker double d = (double) value; 1451*795d594fSAndroid Build Coastguard Worker int i = (int) d; 1452*795d594fSAndroid Build Coastguard Worker return "d=" + d + ", i=" + i; 1453*795d594fSAndroid Build Coastguard Worker } 1454*795d594fSAndroid Build Coastguard Worker 1455*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (before) 1456*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 1457*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1458*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] 1459*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] 1460*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1461*795d594fSAndroid Build Coastguard Worker 1462*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) 1463*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 1464*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 1465*795d594fSAndroid Build Coastguard Worker 1466*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) 1467*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1468*795d594fSAndroid Build Coastguard Worker $noinline$byteToDoubleToShort(byte value)1469*795d594fSAndroid Build Coastguard Worker public static short $noinline$byteToDoubleToShort(byte value) { 1470*795d594fSAndroid Build Coastguard Worker // Originally, this is byte->double->int->short. The first conversion is lossless, 1471*795d594fSAndroid Build Coastguard Worker // so we merge this with the second one to byte->int which we omit as it's an implicit 1472*795d594fSAndroid Build Coastguard Worker // conversion. Then we eliminate the resulting byte->short as an implicit conversion. 1473*795d594fSAndroid Build Coastguard Worker return (short) (double) value; 1474*795d594fSAndroid Build Coastguard Worker } 1475*795d594fSAndroid Build Coastguard Worker 1476*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (before) 1477*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:c\d+>> ParameterValue 1478*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1479*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] 1480*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] 1481*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1482*795d594fSAndroid Build Coastguard Worker 1483*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) 1484*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:c\d+>> ParameterValue 1485*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Arg>>] 1486*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1487*795d594fSAndroid Build Coastguard Worker 1488*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) 1489*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: TypeConversion 1490*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion 1491*795d594fSAndroid Build Coastguard Worker $noinline$charToDoubleToShort(char value)1492*795d594fSAndroid Build Coastguard Worker public static short $noinline$charToDoubleToShort(char value) { 1493*795d594fSAndroid Build Coastguard Worker // Originally, this is char->double->int->short. The first conversion is lossless, 1494*795d594fSAndroid Build Coastguard Worker // so we merge this with the second one to char->int which we omit as it's an implicit 1495*795d594fSAndroid Build Coastguard Worker // conversion. Then we are left with the resulting char->short conversion. 1496*795d594fSAndroid Build Coastguard Worker return (short) (double) value; 1497*795d594fSAndroid Build Coastguard Worker } 1498*795d594fSAndroid Build Coastguard Worker 1499*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (before) 1500*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1501*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1502*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] 1503*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1504*795d594fSAndroid Build Coastguard Worker 1505*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (after) 1506*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1507*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1508*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] 1509*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1510*795d594fSAndroid Build Coastguard Worker $noinline$floatToIntToShort(float value)1511*795d594fSAndroid Build Coastguard Worker public static short $noinline$floatToIntToShort(float value) { 1512*795d594fSAndroid Build Coastguard Worker // Lossy FP to integral conversion followed by another conversion: no simplification. 1513*795d594fSAndroid Build Coastguard Worker return (short) value; 1514*795d594fSAndroid Build Coastguard Worker } 1515*795d594fSAndroid Build Coastguard Worker 1516*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (before) 1517*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1518*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Float:f\d+>> TypeConversion [<<Arg>>] 1519*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Float>>] 1520*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1521*795d594fSAndroid Build Coastguard Worker 1522*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (after) 1523*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1524*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Float:f\d+>> TypeConversion [<<Arg>>] 1525*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Float>>] 1526*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1527*795d594fSAndroid Build Coastguard Worker $noinline$intToFloatToInt(int value)1528*795d594fSAndroid Build Coastguard Worker public static int $noinline$intToFloatToInt(int value) { 1529*795d594fSAndroid Build Coastguard Worker // Lossy integral to FP conversion followed another conversion: no simplification. 1530*795d594fSAndroid Build Coastguard Worker return (int) (float) value; 1531*795d594fSAndroid Build Coastguard Worker } 1532*795d594fSAndroid Build Coastguard Worker 1533*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (before) 1534*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1535*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1536*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Int>>] 1537*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Double>>] 1538*795d594fSAndroid Build Coastguard Worker 1539*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (after) 1540*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1541*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1542*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Int>>] 1543*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Double>>] 1544*795d594fSAndroid Build Coastguard Worker $noinline$longToIntToDouble(long value)1545*795d594fSAndroid Build Coastguard Worker public static double $noinline$longToIntToDouble(long value) { 1546*795d594fSAndroid Build Coastguard Worker // Lossy long-to-int conversion followed an integral to FP conversion: no simplification. 1547*795d594fSAndroid Build Coastguard Worker return (double) (int) value; 1548*795d594fSAndroid Build Coastguard Worker } 1549*795d594fSAndroid Build Coastguard Worker 1550*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (before) 1551*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1552*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1553*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Int>>] 1554*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Long>>] 1555*795d594fSAndroid Build Coastguard Worker 1556*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (after) 1557*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1558*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] 1559*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Int>>] 1560*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Long>>] 1561*795d594fSAndroid Build Coastguard Worker $noinline$longToIntToLong(long value)1562*795d594fSAndroid Build Coastguard Worker public static long $noinline$longToIntToLong(long value) { 1563*795d594fSAndroid Build Coastguard Worker // Lossy long-to-int conversion followed an int-to-long conversion: no simplification. 1564*795d594fSAndroid Build Coastguard Worker return (long) (int) value; 1565*795d594fSAndroid Build Coastguard Worker } 1566*795d594fSAndroid Build Coastguard Worker 1567*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (before) 1568*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1569*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] 1570*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Char>>] 1571*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1572*795d594fSAndroid Build Coastguard Worker 1573*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (after) 1574*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1575*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 1576*795d594fSAndroid Build Coastguard Worker $noinline$shortToCharToShort(short value)1577*795d594fSAndroid Build Coastguard Worker public static short $noinline$shortToCharToShort(short value) { 1578*795d594fSAndroid Build Coastguard Worker // Integral conversion followed by non-widening integral conversion to original type. 1579*795d594fSAndroid Build Coastguard Worker return (short) (char) value; 1580*795d594fSAndroid Build Coastguard Worker } 1581*795d594fSAndroid Build Coastguard Worker 1582*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (before) 1583*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1584*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] 1585*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Long>>] 1586*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Int>>] 1587*795d594fSAndroid Build Coastguard Worker 1588*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (after) 1589*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1590*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] 1591*795d594fSAndroid Build Coastguard Worker $noinline$shortToLongToInt(short value)1592*795d594fSAndroid Build Coastguard Worker public static int $noinline$shortToLongToInt(short value) { 1593*795d594fSAndroid Build Coastguard Worker // Integral conversion followed by non-widening integral conversion, use implicit conversion. 1594*795d594fSAndroid Build Coastguard Worker return (int) (long) value; 1595*795d594fSAndroid Build Coastguard Worker } 1596*795d594fSAndroid Build Coastguard Worker 1597*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (before) 1598*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1599*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] 1600*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Char>>] 1601*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Byte>>] 1602*795d594fSAndroid Build Coastguard Worker 1603*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (after) 1604*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1605*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Arg>>] 1606*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Byte>>] 1607*795d594fSAndroid Build Coastguard Worker $noinline$shortToCharToByte(short value)1608*795d594fSAndroid Build Coastguard Worker public static byte $noinline$shortToCharToByte(short value) { 1609*795d594fSAndroid Build Coastguard Worker // Integral conversion followed by non-widening integral conversion losing bits 1610*795d594fSAndroid Build Coastguard Worker // from the original type. Simplify to use only one conversion. 1611*795d594fSAndroid Build Coastguard Worker return (byte) (char) value; 1612*795d594fSAndroid Build Coastguard Worker } 1613*795d594fSAndroid Build Coastguard Worker 1614*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (before) 1615*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1616*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] 1617*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{b\d+}} TypeConversion [<<Char>>] 1618*795d594fSAndroid Build Coastguard Worker 1619*795d594fSAndroid Build Coastguard Worker /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (after) 1620*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1621*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] 1622*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: {{b\d+}} TypeConversion [<<Char>>] 1623*795d594fSAndroid Build Coastguard Worker $noinline$shortToCharToBytePrint(short value)1624*795d594fSAndroid Build Coastguard Worker public static String $noinline$shortToCharToBytePrint(short value) { 1625*795d594fSAndroid Build Coastguard Worker // Integral conversion followed by non-widening integral conversion losing bits 1626*795d594fSAndroid Build Coastguard Worker // from the original type with an extra use of the intermediate result. 1627*795d594fSAndroid Build Coastguard Worker char c = (char) value; 1628*795d594fSAndroid Build Coastguard Worker byte b = (byte) c; 1629*795d594fSAndroid Build Coastguard Worker return "c=" + ((int) c) + ", b=" + ((int) b); // implicit conversions. 1630*795d594fSAndroid Build Coastguard Worker } 1631*795d594fSAndroid Build Coastguard Worker 1632*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (before) 1633*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1634*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:j\d+>> LongConstant -12345678 1635*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] 1636*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] 1637*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 1638*795d594fSAndroid Build Coastguard Worker 1639*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (after) 1640*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1641*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:i\d+>> IntConstant -12345678 1642*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Mask>>] 1643*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<And>>] 1644*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Long>>] 1645*795d594fSAndroid Build Coastguard Worker $noinline$intAndSmallLongConstant(int value)1646*795d594fSAndroid Build Coastguard Worker public static long $noinline$intAndSmallLongConstant(int value) { 1647*795d594fSAndroid Build Coastguard Worker return value & -12345678L; // Shall be simplified (constant is 32-bit). 1648*795d594fSAndroid Build Coastguard Worker } 1649*795d594fSAndroid Build Coastguard Worker 1650*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (before) 1651*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1652*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:j\d+>> LongConstant 9876543210 1653*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] 1654*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] 1655*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 1656*795d594fSAndroid Build Coastguard Worker 1657*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (after) 1658*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1659*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:j\d+>> LongConstant 9876543210 1660*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] 1661*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] 1662*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 1663*795d594fSAndroid Build Coastguard Worker $noinline$intAndLargeLongConstant(int value)1664*795d594fSAndroid Build Coastguard Worker public static long $noinline$intAndLargeLongConstant(int value) { 1665*795d594fSAndroid Build Coastguard Worker return value & 9876543210L; // Shall not be simplified (constant is not 32-bit). 1666*795d594fSAndroid Build Coastguard Worker } 1667*795d594fSAndroid Build Coastguard Worker 1668*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (before) 1669*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1670*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shift:i\d+>> IntConstant 28 1671*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:j\d+>> LongConstant 15 1672*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shifted:i\d+>> Shr [<<Arg>>,<<Shift>>] 1673*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Shifted>>] 1674*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] 1675*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 1676*795d594fSAndroid Build Coastguard Worker 1677*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (after) 1678*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1679*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shift:i\d+>> IntConstant 28 1680*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shifted:i\d+>> UShr [<<Arg>>,<<Shift>>] 1681*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Shifted>>] 1682*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Long>>] 1683*795d594fSAndroid Build Coastguard Worker $noinline$intShr28And15L(int value)1684*795d594fSAndroid Build Coastguard Worker public static long $noinline$intShr28And15L(int value) { 1685*795d594fSAndroid Build Coastguard Worker return (value >> 28) & 15L; 1686*795d594fSAndroid Build Coastguard Worker } 1687*795d594fSAndroid Build Coastguard Worker 1688*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (before) 1689*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1690*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:j\d+>> LongConstant 255 1691*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:j\d+>> And [<<Mask>>,<<Arg>>] 1692*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<And>>] 1693*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Int>>] 1694*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Byte>>] 1695*795d594fSAndroid Build Coastguard Worker 1696*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) 1697*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1698*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Arg>>] 1699*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Byte>>] 1700*795d594fSAndroid Build Coastguard Worker 1701*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) 1702*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 1703*795d594fSAndroid Build Coastguard Worker $noinline$longAnd0xffToByte(long value)1704*795d594fSAndroid Build Coastguard Worker public static byte $noinline$longAnd0xffToByte(long value) { 1705*795d594fSAndroid Build Coastguard Worker return (byte) (value & 0xff); 1706*795d594fSAndroid Build Coastguard Worker } 1707*795d594fSAndroid Build Coastguard Worker 1708*795d594fSAndroid Build Coastguard Worker /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (before) 1709*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1710*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:i\d+>> IntConstant 131071 1711*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] 1712*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<And>>] 1713*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Char>>] 1714*795d594fSAndroid Build Coastguard Worker 1715*795d594fSAndroid Build Coastguard Worker /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) 1716*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1717*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] 1718*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Char>>] 1719*795d594fSAndroid Build Coastguard Worker 1720*795d594fSAndroid Build Coastguard Worker /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) 1721*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 1722*795d594fSAndroid Build Coastguard Worker $noinline$intAnd0x1ffffToChar(int value)1723*795d594fSAndroid Build Coastguard Worker public static char $noinline$intAnd0x1ffffToChar(int value) { 1724*795d594fSAndroid Build Coastguard Worker // Keeping all significant bits and one more. 1725*795d594fSAndroid Build Coastguard Worker return (char) (value & 0x1ffff); 1726*795d594fSAndroid Build Coastguard Worker } 1727*795d594fSAndroid Build Coastguard Worker 1728*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (before) 1729*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1730*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:i\d+>> IntConstant 98303 1731*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] 1732*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<And>>] 1733*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1734*795d594fSAndroid Build Coastguard Worker 1735*795d594fSAndroid Build Coastguard Worker /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (after) 1736*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1737*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:i\d+>> IntConstant 98303 1738*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] 1739*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<And>>] 1740*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Short>>] 1741*795d594fSAndroid Build Coastguard Worker $noinline$intAnd0x17fffToShort(int value)1742*795d594fSAndroid Build Coastguard Worker public static short $noinline$intAnd0x17fffToShort(int value) { 1743*795d594fSAndroid Build Coastguard Worker // No simplification: clearing a significant bit. 1744*795d594fSAndroid Build Coastguard Worker return (short) (value & 0x17fff); 1745*795d594fSAndroid Build Coastguard Worker } 1746*795d594fSAndroid Build Coastguard Worker 1747*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (before) 1748*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1749*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Mask:i\d+>> IntConstant 65535 1750*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] 1751*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Same:s\d+>> TypeConversion [<<And>>] 1752*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Same>>] 1753*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Double>>] 1754*795d594fSAndroid Build Coastguard Worker 1755*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (after) 1756*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:s\d+>> ParameterValue 1757*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] 1758*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Double>>] 1759*795d594fSAndroid Build Coastguard Worker $noinline$shortAnd0xffffToShortToDouble(short value)1760*795d594fSAndroid Build Coastguard Worker public static double $noinline$shortAnd0xffffToShortToDouble(short value) { 1761*795d594fSAndroid Build Coastguard Worker short same = (short) (value & 0xffff); 1762*795d594fSAndroid Build Coastguard Worker return (double) same; 1763*795d594fSAndroid Build Coastguard Worker } 1764*795d594fSAndroid Build Coastguard Worker 1765*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (before) 1766*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1767*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1768*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Const42>>,<<Arg>>] 1769*795d594fSAndroid Build Coastguard Worker 1770*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (after) 1771*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1772*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 1773*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<GE:z\d+>> GreaterThanOrEqual [<<Arg>>,<<Const42>>] 1774*795d594fSAndroid Build Coastguard Worker $noinline$intReverseCondition(int i)1775*795d594fSAndroid Build Coastguard Worker public static int $noinline$intReverseCondition(int i) { 1776*795d594fSAndroid Build Coastguard Worker return (42 > i) ? 13 : 54; 1777*795d594fSAndroid Build Coastguard Worker } 1778*795d594fSAndroid Build Coastguard Worker 1779*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (before) 1780*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 1781*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect 1782*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<CMP:i\d+>> Compare [<<Const42>>,<<Result>>] 1783*795d594fSAndroid Build Coastguard Worker 1784*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (after) 1785*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 1786*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect 1787*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<EQ:z\d+>> Equal [<<Result>>,<<Const42>>] 1788*795d594fSAndroid Build Coastguard Worker $noinline$intReverseConditionNaN(int i)1789*795d594fSAndroid Build Coastguard Worker public static int $noinline$intReverseConditionNaN(int i) { 1790*795d594fSAndroid Build Coastguard Worker return (42 != Math.sqrt(i)) ? 13 : 54; 1791*795d594fSAndroid Build Coastguard Worker } 1792*795d594fSAndroid Build Coastguard Worker $noinline$runSmaliTest(String name, boolean input)1793*795d594fSAndroid Build Coastguard Worker public static int $noinline$runSmaliTest(String name, boolean input) { 1794*795d594fSAndroid Build Coastguard Worker try { 1795*795d594fSAndroid Build Coastguard Worker Class<?> c = Class.forName("SmaliTests"); 1796*795d594fSAndroid Build Coastguard Worker Method m = c.getMethod(name, boolean.class); 1797*795d594fSAndroid Build Coastguard Worker return (Integer) m.invoke(null, input); 1798*795d594fSAndroid Build Coastguard Worker } catch (Exception ex) { 1799*795d594fSAndroid Build Coastguard Worker throw new Error(ex); 1800*795d594fSAndroid Build Coastguard Worker } 1801*795d594fSAndroid Build Coastguard Worker } 1802*795d594fSAndroid Build Coastguard Worker $noinline$runSmaliTest2Boolean(String name, boolean input)1803*795d594fSAndroid Build Coastguard Worker public static boolean $noinline$runSmaliTest2Boolean(String name, boolean input) { 1804*795d594fSAndroid Build Coastguard Worker try { 1805*795d594fSAndroid Build Coastguard Worker Class<?> c = Class.forName("SmaliTests2"); 1806*795d594fSAndroid Build Coastguard Worker Method m = c.getMethod(name, boolean.class); 1807*795d594fSAndroid Build Coastguard Worker return (Boolean) m.invoke(null, input); 1808*795d594fSAndroid Build Coastguard Worker } catch (Exception ex) { 1809*795d594fSAndroid Build Coastguard Worker throw new Error(ex); 1810*795d594fSAndroid Build Coastguard Worker } 1811*795d594fSAndroid Build Coastguard Worker } 1812*795d594fSAndroid Build Coastguard Worker $noinline$runSmaliTestInt(String postfix, String name, int arg)1813*795d594fSAndroid Build Coastguard Worker public static int $noinline$runSmaliTestInt(String postfix, String name, int arg) { 1814*795d594fSAndroid Build Coastguard Worker try { 1815*795d594fSAndroid Build Coastguard Worker Class<?> c = Class.forName("SmaliTests" + postfix); 1816*795d594fSAndroid Build Coastguard Worker Method m = c.getMethod(name, int.class); 1817*795d594fSAndroid Build Coastguard Worker return (Integer) m.invoke(null, arg); 1818*795d594fSAndroid Build Coastguard Worker } catch (Exception ex) { 1819*795d594fSAndroid Build Coastguard Worker throw new Error(ex); 1820*795d594fSAndroid Build Coastguard Worker } 1821*795d594fSAndroid Build Coastguard Worker } 1822*795d594fSAndroid Build Coastguard Worker $noinline$runSmaliTestInt(String name, int arg)1823*795d594fSAndroid Build Coastguard Worker public static int $noinline$runSmaliTestInt(String name, int arg) { 1824*795d594fSAndroid Build Coastguard Worker return $noinline$runSmaliTestInt("", name, arg); 1825*795d594fSAndroid Build Coastguard Worker } 1826*795d594fSAndroid Build Coastguard Worker $noinline$runSmaliTest2Long(String name, long arg)1827*795d594fSAndroid Build Coastguard Worker public static long $noinline$runSmaliTest2Long(String name, long arg) { 1828*795d594fSAndroid Build Coastguard Worker try { 1829*795d594fSAndroid Build Coastguard Worker Class<?> c = Class.forName("SmaliTests2"); 1830*795d594fSAndroid Build Coastguard Worker Method m = c.getMethod(name, long.class); 1831*795d594fSAndroid Build Coastguard Worker return (Long) m.invoke(null, arg); 1832*795d594fSAndroid Build Coastguard Worker } catch (Exception ex) { 1833*795d594fSAndroid Build Coastguard Worker throw new Error(ex); 1834*795d594fSAndroid Build Coastguard Worker } 1835*795d594fSAndroid Build Coastguard Worker } 1836*795d594fSAndroid Build Coastguard Worker 1837*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (before) 1838*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1839*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1840*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 1841*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] 1842*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Value>>,<<And>>] 1843*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 1844*795d594fSAndroid Build Coastguard Worker 1845*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (after) 1846*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1847*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1848*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Value>>,<<Shift>>] 1849*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 1850*795d594fSAndroid Build Coastguard Worker $noinline$intUnnecessaryShiftMasking(int value, int shift)1851*795d594fSAndroid Build Coastguard Worker public static int $noinline$intUnnecessaryShiftMasking(int value, int shift) { 1852*795d594fSAndroid Build Coastguard Worker return value << (shift & 31); 1853*795d594fSAndroid Build Coastguard Worker } 1854*795d594fSAndroid Build Coastguard Worker 1855*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (before) 1856*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:j\d+>> ParameterValue 1857*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1858*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const63:i\d+>> IntConstant 63 1859*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const63>>] 1860*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Value>>,<<And>>] 1861*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shr>>] 1862*795d594fSAndroid Build Coastguard Worker 1863*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (after) 1864*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:j\d+>> ParameterValue 1865*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1866*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Value>>,<<Shift>>] 1867*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shr>>] 1868*795d594fSAndroid Build Coastguard Worker $noinline$longUnnecessaryShiftMasking(long value, int shift)1869*795d594fSAndroid Build Coastguard Worker public static long $noinline$longUnnecessaryShiftMasking(long value, int shift) { 1870*795d594fSAndroid Build Coastguard Worker return value >> (shift & 63); 1871*795d594fSAndroid Build Coastguard Worker } 1872*795d594fSAndroid Build Coastguard Worker 1873*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (before) 1874*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1875*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1876*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 1877*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const255>>] 1878*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Value>>,<<And>>] 1879*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 1880*795d594fSAndroid Build Coastguard Worker 1881*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (after) 1882*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1883*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1884*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Value>>,<<Shift>>] 1885*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<UShr>>] 1886*795d594fSAndroid Build Coastguard Worker $noinline$intUnnecessaryWiderShiftMasking(int value, int shift)1887*795d594fSAndroid Build Coastguard Worker public static int $noinline$intUnnecessaryWiderShiftMasking(int value, int shift) { 1888*795d594fSAndroid Build Coastguard Worker return value >>> (shift & 0xff); 1889*795d594fSAndroid Build Coastguard Worker } 1890*795d594fSAndroid Build Coastguard Worker 1891*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (before) 1892*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:j\d+>> ParameterValue 1893*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1894*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 1895*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const3>>] 1896*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Value>>,<<And>>] 1897*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 1898*795d594fSAndroid Build Coastguard Worker 1899*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (after) 1900*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:j\d+>> ParameterValue 1901*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1902*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 1903*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const3>>] 1904*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Value>>,<<And>>] 1905*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Shl>>] 1906*795d594fSAndroid Build Coastguard Worker $noinline$longSmallerShiftMasking(long value, int shift)1907*795d594fSAndroid Build Coastguard Worker public static long $noinline$longSmallerShiftMasking(long value, int shift) { 1908*795d594fSAndroid Build Coastguard Worker return value << (shift & 3); 1909*795d594fSAndroid Build Coastguard Worker } 1910*795d594fSAndroid Build Coastguard Worker 1911*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (before) 1912*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1913*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1914*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 1915*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] 1916*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Value>>,<<And>>] 1917*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Shr>>,<<And>>] 1918*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 1919*795d594fSAndroid Build Coastguard Worker 1920*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (after) 1921*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1922*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1923*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 1924*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] 1925*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Value>>,<<Shift>>] 1926*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Shr>>,<<And>>] 1927*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 1928*795d594fSAndroid Build Coastguard Worker $noinline$otherUseOfUnnecessaryShiftMasking(int value, int shift)1929*795d594fSAndroid Build Coastguard Worker public static int $noinline$otherUseOfUnnecessaryShiftMasking(int value, int shift) { 1930*795d594fSAndroid Build Coastguard Worker int temp = shift & 31; 1931*795d594fSAndroid Build Coastguard Worker return (value >> temp) + temp; 1932*795d594fSAndroid Build Coastguard Worker } 1933*795d594fSAndroid Build Coastguard Worker 1934*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (before) 1935*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1936*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1937*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const32:i\d+>> IntConstant 32 1938*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const64:i\d+>> IntConstant 64 1939*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const96:i\d+>> IntConstant 96 1940*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const128:i\d+>> IntConstant 128 1941*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const32>>] 1942*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const64>>] 1943*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const96>>] 1944*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const128>>] 1945*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Shift>>] 1946*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Or>>] 1947*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] 1948*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: UShr [<<Value>>,<<Add>>] 1949*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] 1950*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Conv>>] 1951*795d594fSAndroid Build Coastguard Worker 1952*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (after) 1953*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1954*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1955*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Shift>>] 1956*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Shift>>] 1957*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: UShr [<<Value>>,<<Shift>>] 1958*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Shift>>] 1959*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Shift>>] 1960*795d594fSAndroid Build Coastguard Worker $noinline$intUnnecessaryShiftModifications(int value, int shift)1961*795d594fSAndroid Build Coastguard Worker public static int $noinline$intUnnecessaryShiftModifications(int value, int shift) { 1962*795d594fSAndroid Build Coastguard Worker int c128 = 128; 1963*795d594fSAndroid Build Coastguard Worker return (value << (shift | 32)) + 1964*795d594fSAndroid Build Coastguard Worker (value >> (shift ^ 64)) + 1965*795d594fSAndroid Build Coastguard Worker (value >>> (shift + 96)) + 1966*795d594fSAndroid Build Coastguard Worker (value << (shift - c128)) + // Needs a named constant to generate Sub. 1967*795d594fSAndroid Build Coastguard Worker (value >> ((byte) shift)); 1968*795d594fSAndroid Build Coastguard Worker } 1969*795d594fSAndroid Build Coastguard Worker 1970*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (before) 1971*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1972*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1973*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1974*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const65:i\d+>> IntConstant 65 1975*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const97:i\d+>> IntConstant 97 1976*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const129:i\d+>> IntConstant 129 1977*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const33>>] 1978*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const65>>] 1979*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const97>>] 1980*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const129>>] 1981*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Or>>] 1982*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] 1983*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: UShr [<<Value>>,<<Add>>] 1984*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] 1985*795d594fSAndroid Build Coastguard Worker 1986*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (after) 1987*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Value:i\d+>> ParameterValue 1988*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shift:i\d+>> ParameterValue 1989*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1990*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const65:i\d+>> IntConstant 65 1991*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const97:i\d+>> IntConstant 97 1992*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const129:i\d+>> IntConstant 129 1993*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const33>>] 1994*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const65>>] 1995*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const97>>] 1996*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const129>>] 1997*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Or>>] 1998*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] 1999*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: UShr [<<Value>>,<<Add>>] 2000*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] 2001*795d594fSAndroid Build Coastguard Worker $noinline$intNecessaryShiftModifications(int value, int shift)2002*795d594fSAndroid Build Coastguard Worker public static int $noinline$intNecessaryShiftModifications(int value, int shift) { 2003*795d594fSAndroid Build Coastguard Worker int c129 = 129; 2004*795d594fSAndroid Build Coastguard Worker return (value << (shift | 33)) + 2005*795d594fSAndroid Build Coastguard Worker (value >> (shift ^ 65)) + 2006*795d594fSAndroid Build Coastguard Worker (value >>> (shift + 97)) + 2007*795d594fSAndroid Build Coastguard Worker (value << (shift - c129)); // Needs a named constant to generate Sub. 2008*795d594fSAndroid Build Coastguard Worker } 2009*795d594fSAndroid Build Coastguard Worker 2010*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (before) 2011*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2012*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2013*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] 2014*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:i\d+>> Sub [<<Sum>>,<<X>>] 2015*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2016*795d594fSAndroid Build Coastguard Worker 2017*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (after) 2018*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2019*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2020*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] 2021*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Y>>] 2022*795d594fSAndroid Build Coastguard Worker $noinline$intAddSubSimplifyArg1(int x, int y)2023*795d594fSAndroid Build Coastguard Worker public static int $noinline$intAddSubSimplifyArg1(int x, int y) { 2024*795d594fSAndroid Build Coastguard Worker int sum = x + y; 2025*795d594fSAndroid Build Coastguard Worker return sum - x; 2026*795d594fSAndroid Build Coastguard Worker } 2027*795d594fSAndroid Build Coastguard Worker 2028*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (before) 2029*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2030*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2031*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] 2032*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:i\d+>> Sub [<<Sum>>,<<Y>>] 2033*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2034*795d594fSAndroid Build Coastguard Worker 2035*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (after) 2036*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2037*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2038*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] 2039*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<X>>] 2040*795d594fSAndroid Build Coastguard Worker $noinline$intAddSubSimplifyArg2(int x, int y)2041*795d594fSAndroid Build Coastguard Worker public static int $noinline$intAddSubSimplifyArg2(int x, int y) { 2042*795d594fSAndroid Build Coastguard Worker int sum = x + y; 2043*795d594fSAndroid Build Coastguard Worker return sum - y; 2044*795d594fSAndroid Build Coastguard Worker } 2045*795d594fSAndroid Build Coastguard Worker 2046*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (before) 2047*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2048*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2049*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] 2050*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:i\d+>> Add [<<Sub>>,<<Y>>] 2051*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2052*795d594fSAndroid Build Coastguard Worker 2053*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (after) 2054*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2055*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2056*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] 2057*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<X>>] 2058*795d594fSAndroid Build Coastguard Worker $noinline$intSubAddSimplifyLeft(int x, int y)2059*795d594fSAndroid Build Coastguard Worker public static int $noinline$intSubAddSimplifyLeft(int x, int y) { 2060*795d594fSAndroid Build Coastguard Worker int sub = x - y; 2061*795d594fSAndroid Build Coastguard Worker return sub + y; 2062*795d594fSAndroid Build Coastguard Worker } 2063*795d594fSAndroid Build Coastguard Worker 2064*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (before) 2065*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2066*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2067*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] 2068*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:i\d+>> Add [<<Y>>,<<Sub>>] 2069*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2070*795d594fSAndroid Build Coastguard Worker 2071*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (after) 2072*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:i\d+>> ParameterValue 2073*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:i\d+>> ParameterValue 2074*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] 2075*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<X>>] 2076*795d594fSAndroid Build Coastguard Worker $noinline$intSubAddSimplifyRight(int x, int y)2077*795d594fSAndroid Build Coastguard Worker public static int $noinline$intSubAddSimplifyRight(int x, int y) { 2078*795d594fSAndroid Build Coastguard Worker int sub = x - y; 2079*795d594fSAndroid Build Coastguard Worker return y + sub; 2080*795d594fSAndroid Build Coastguard Worker } 2081*795d594fSAndroid Build Coastguard Worker 2082*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (before) 2083*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2084*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2085*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] 2086*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<X>>] 2087*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2088*795d594fSAndroid Build Coastguard Worker 2089*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (after) 2090*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2091*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2092*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] 2093*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<X>>] 2094*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2095*795d594fSAndroid Build Coastguard Worker $noinline$floatAddSubSimplifyArg1(float x, float y)2096*795d594fSAndroid Build Coastguard Worker public static float $noinline$floatAddSubSimplifyArg1(float x, float y) { 2097*795d594fSAndroid Build Coastguard Worker float sum = x + y; 2098*795d594fSAndroid Build Coastguard Worker return sum - x; 2099*795d594fSAndroid Build Coastguard Worker } 2100*795d594fSAndroid Build Coastguard Worker 2101*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (before) 2102*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2103*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2104*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] 2105*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<Y>>] 2106*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2107*795d594fSAndroid Build Coastguard Worker 2108*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (after) 2109*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2110*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2111*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] 2112*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<Y>>] 2113*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2114*795d594fSAndroid Build Coastguard Worker $noinline$floatAddSubSimplifyArg2(float x, float y)2115*795d594fSAndroid Build Coastguard Worker public static float $noinline$floatAddSubSimplifyArg2(float x, float y) { 2116*795d594fSAndroid Build Coastguard Worker float sum = x + y; 2117*795d594fSAndroid Build Coastguard Worker return sum - y; 2118*795d594fSAndroid Build Coastguard Worker } 2119*795d594fSAndroid Build Coastguard Worker 2120*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (before) 2121*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2122*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2123*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] 2124*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Add [<<Sub>>,<<Y>>] 2125*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2126*795d594fSAndroid Build Coastguard Worker 2127*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (after) 2128*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2129*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2130*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] 2131*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Add [<<Sub>>,<<Y>>] 2132*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2133*795d594fSAndroid Build Coastguard Worker $noinline$floatSubAddSimplifyLeft(float x, float y)2134*795d594fSAndroid Build Coastguard Worker public static float $noinline$floatSubAddSimplifyLeft(float x, float y) { 2135*795d594fSAndroid Build Coastguard Worker float sub = x - y; 2136*795d594fSAndroid Build Coastguard Worker return sub + y; 2137*795d594fSAndroid Build Coastguard Worker } 2138*795d594fSAndroid Build Coastguard Worker 2139*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (before) 2140*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2141*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2142*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] 2143*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Add [<<Y>>,<<Sub>>] 2144*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2145*795d594fSAndroid Build Coastguard Worker 2146*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (after) 2147*795d594fSAndroid Build Coastguard Worker /// CHECK: <<X:f\d+>> ParameterValue 2148*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Y:f\d+>> ParameterValue 2149*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] 2150*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Res:f\d+>> Add [<<Y>>,<<Sub>>] 2151*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Res>>] 2152*795d594fSAndroid Build Coastguard Worker $noinline$floatSubAddSimplifyRight(float x, float y)2153*795d594fSAndroid Build Coastguard Worker public static float $noinline$floatSubAddSimplifyRight(float x, float y) { 2154*795d594fSAndroid Build Coastguard Worker float sub = x - y; 2155*795d594fSAndroid Build Coastguard Worker return y + sub; 2156*795d594fSAndroid Build Coastguard Worker } 2157*795d594fSAndroid Build Coastguard Worker 2158*795d594fSAndroid Build Coastguard Worker // Sub/Add and Sub/Sub simplifications 2159*795d594fSAndroid Build Coastguard Worker 2160*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddInt(int, int) instruction_simplifier (before) 2161*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2162*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2163*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:i\d+>> Add [<<x>>,<<y>>] 2164*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub:i\d+>> Sub [<<y>>,<<add>>] 2165*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub>>] 2166*795d594fSAndroid Build Coastguard Worker 2167*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddInt(int, int) instruction_simplifier (after) 2168*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2169*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2170*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:i\d+>> Add [<<x>>,<<y>>] 2171*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:i\d+>> Neg [<<x>>] 2172*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2173*795d594fSAndroid Build Coastguard Worker 2174*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddInt(int, int) instruction_simplifier (after) 2175*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2176*795d594fSAndroid Build Coastguard Worker 2177*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddInt(int, int) dead_code_elimination$initial (after) 2178*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add $noinline$testSubAddInt(int x, int y)2179*795d594fSAndroid Build Coastguard Worker static int $noinline$testSubAddInt(int x, int y) { 2180*795d594fSAndroid Build Coastguard Worker return y - (x + y); 2181*795d594fSAndroid Build Coastguard Worker } 2182*795d594fSAndroid Build Coastguard Worker 2183*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddOtherVersionInt(int, int) instruction_simplifier (before) 2184*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2185*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2186*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:i\d+>> Add [<<x>>,<<y>>] 2187*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub:i\d+>> Sub [<<x>>,<<add>>] 2188*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub>>] 2189*795d594fSAndroid Build Coastguard Worker 2190*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddOtherVersionInt(int, int) instruction_simplifier (after) 2191*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2192*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2193*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:i\d+>> Add [<<x>>,<<y>>] 2194*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:i\d+>> Neg [<<y>>] 2195*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2196*795d594fSAndroid Build Coastguard Worker 2197*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddOtherVersionInt(int, int) instruction_simplifier (after) 2198*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2199*795d594fSAndroid Build Coastguard Worker 2200*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubAddOtherVersionInt(int, int) dead_code_elimination$initial (after) 2201*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add $noinline$testSubAddOtherVersionInt(int x, int y)2202*795d594fSAndroid Build Coastguard Worker static int $noinline$testSubAddOtherVersionInt(int x, int y) { 2203*795d594fSAndroid Build Coastguard Worker return x - (x + y); 2204*795d594fSAndroid Build Coastguard Worker } 2205*795d594fSAndroid Build Coastguard Worker 2206*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubInt(int, int) instruction_simplifier (before) 2207*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2208*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2209*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:i\d+>> Sub [<<x>>,<<y>>] 2210*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub2:i\d+>> Sub [<<sub1>>,<<x>>] 2211*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub2>>] 2212*795d594fSAndroid Build Coastguard Worker 2213*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubInt(int, int) instruction_simplifier (after) 2214*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2215*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2216*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:i\d+>> Sub [<<x>>,<<y>>] 2217*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:i\d+>> Neg [<<y>>] 2218*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2219*795d594fSAndroid Build Coastguard Worker 2220*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubInt(int, int) instruction_simplifier (after) 2221*795d594fSAndroid Build Coastguard Worker /// CHECK: Sub 2222*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2223*795d594fSAndroid Build Coastguard Worker 2224*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubInt(int, int) dead_code_elimination$initial (after) 2225*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub $noinline$testSubSubInt(int x, int y)2226*795d594fSAndroid Build Coastguard Worker static int $noinline$testSubSubInt(int x, int y) { 2227*795d594fSAndroid Build Coastguard Worker return (x - y) - x; 2228*795d594fSAndroid Build Coastguard Worker } 2229*795d594fSAndroid Build Coastguard Worker 2230*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubOtherVersionInt(int, int) instruction_simplifier (before) 2231*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2232*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2233*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:i\d+>> Sub [<<x>>,<<y>>] 2234*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub2:i\d+>> Sub [<<x>>,<<sub1>>] 2235*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub2>>] 2236*795d594fSAndroid Build Coastguard Worker 2237*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubOtherVersionInt(int, int) instruction_simplifier (after) 2238*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:i\d+>> ParameterValue 2239*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:i\d+>> ParameterValue 2240*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:i\d+>> Sub [<<x>>,<<y>>] 2241*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<y>>] 2242*795d594fSAndroid Build Coastguard Worker 2243*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubOtherVersionInt(int, int) instruction_simplifier (after) 2244*795d594fSAndroid Build Coastguard Worker /// CHECK: Sub 2245*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2246*795d594fSAndroid Build Coastguard Worker 2247*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSubSubOtherVersionInt(int, int) dead_code_elimination$initial (after) 2248*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub $noinline$testSubSubOtherVersionInt(int x, int y)2249*795d594fSAndroid Build Coastguard Worker static int $noinline$testSubSubOtherVersionInt(int x, int y) { 2250*795d594fSAndroid Build Coastguard Worker return x - (x - y); 2251*795d594fSAndroid Build Coastguard Worker } 2252*795d594fSAndroid Build Coastguard Worker 2253*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddLong(long, long) instruction_simplifier (before) 2254*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2255*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2256*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:j\d+>> Add [<<x>>,<<y>>] 2257*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub:j\d+>> Sub [<<y>>,<<add>>] 2258*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub>>] 2259*795d594fSAndroid Build Coastguard Worker 2260*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddLong(long, long) instruction_simplifier (after) 2261*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2262*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2263*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:j\d+>> Add [<<x>>,<<y>>] 2264*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:j\d+>> Neg [<<x>>] 2265*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2266*795d594fSAndroid Build Coastguard Worker 2267*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddLong(long, long) instruction_simplifier (after) 2268*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2269*795d594fSAndroid Build Coastguard Worker 2270*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddLong(long, long) dead_code_elimination$initial (after) 2271*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add $noinline$testSubAddLong(long x, long y)2272*795d594fSAndroid Build Coastguard Worker static long $noinline$testSubAddLong(long x, long y) { 2273*795d594fSAndroid Build Coastguard Worker return y - (x + y); 2274*795d594fSAndroid Build Coastguard Worker } 2275*795d594fSAndroid Build Coastguard Worker 2276*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddOtherVersionLong(long, long) instruction_simplifier (before) 2277*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2278*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2279*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:j\d+>> Add [<<x>>,<<y>>] 2280*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub:j\d+>> Sub [<<x>>,<<add>>] 2281*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub>>] 2282*795d594fSAndroid Build Coastguard Worker 2283*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddOtherVersionLong(long, long) instruction_simplifier (after) 2284*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2285*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2286*795d594fSAndroid Build Coastguard Worker /// CHECK: <<add:j\d+>> Add [<<x>>,<<y>>] 2287*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:j\d+>> Neg [<<y>>] 2288*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2289*795d594fSAndroid Build Coastguard Worker 2290*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddOtherVersionLong(long, long) instruction_simplifier (after) 2291*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2292*795d594fSAndroid Build Coastguard Worker 2293*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubAddOtherVersionLong(long, long) dead_code_elimination$initial (after) 2294*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add $noinline$testSubAddOtherVersionLong(long x, long y)2295*795d594fSAndroid Build Coastguard Worker static long $noinline$testSubAddOtherVersionLong(long x, long y) { 2296*795d594fSAndroid Build Coastguard Worker return x - (x + y); 2297*795d594fSAndroid Build Coastguard Worker } 2298*795d594fSAndroid Build Coastguard Worker 2299*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubLong(long, long) instruction_simplifier (before) 2300*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2301*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2302*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:j\d+>> Sub [<<x>>,<<y>>] 2303*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub2:j\d+>> Sub [<<sub1>>,<<x>>] 2304*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub2>>] 2305*795d594fSAndroid Build Coastguard Worker 2306*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubLong(long, long) instruction_simplifier (after) 2307*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2308*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2309*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:j\d+>> Sub [<<x>>,<<y>>] 2310*795d594fSAndroid Build Coastguard Worker /// CHECK: <<neg:j\d+>> Neg [<<y>>] 2311*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<neg>>] 2312*795d594fSAndroid Build Coastguard Worker 2313*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubLong(long, long) instruction_simplifier (after) 2314*795d594fSAndroid Build Coastguard Worker /// CHECK: Sub 2315*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2316*795d594fSAndroid Build Coastguard Worker 2317*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubLong(long, long) dead_code_elimination$initial (after) 2318*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub $noinline$testSubSubLong(long x, long y)2319*795d594fSAndroid Build Coastguard Worker static long $noinline$testSubSubLong(long x, long y) { 2320*795d594fSAndroid Build Coastguard Worker return (x - y) - x; 2321*795d594fSAndroid Build Coastguard Worker } 2322*795d594fSAndroid Build Coastguard Worker 2323*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubOtherVersionLong(long, long) instruction_simplifier (before) 2324*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2325*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2326*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:j\d+>> Sub [<<x>>,<<y>>] 2327*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub2:j\d+>> Sub [<<x>>,<<sub1>>] 2328*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<sub2>>] 2329*795d594fSAndroid Build Coastguard Worker 2330*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubOtherVersionLong(long, long) instruction_simplifier (after) 2331*795d594fSAndroid Build Coastguard Worker /// CHECK: <<x:j\d+>> ParameterValue 2332*795d594fSAndroid Build Coastguard Worker /// CHECK: <<y:j\d+>> ParameterValue 2333*795d594fSAndroid Build Coastguard Worker /// CHECK: <<sub1:j\d+>> Sub [<<x>>,<<y>>] 2334*795d594fSAndroid Build Coastguard Worker /// CHECK: Return [<<y>>] 2335*795d594fSAndroid Build Coastguard Worker 2336*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubOtherVersionLong(long, long) instruction_simplifier (after) 2337*795d594fSAndroid Build Coastguard Worker /// CHECK: Sub 2338*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub 2339*795d594fSAndroid Build Coastguard Worker 2340*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSubSubOtherVersionLong(long, long) dead_code_elimination$initial (after) 2341*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Sub $noinline$testSubSubOtherVersionLong(long x, long y)2342*795d594fSAndroid Build Coastguard Worker static long $noinline$testSubSubOtherVersionLong(long x, long y) { 2343*795d594fSAndroid Build Coastguard Worker return x - (x - y); 2344*795d594fSAndroid Build Coastguard Worker } 2345*795d594fSAndroid Build Coastguard Worker 2346*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (before) 2347*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2348*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet 2349*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2350*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2351*795d594fSAndroid Build Coastguard Worker 2352*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) 2353*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:a\d+>> InstanceFieldGet 2354*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2355*795d594fSAndroid Build Coastguard Worker 2356*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) 2357*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2358*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint8FromInstanceByteField(Main m)2359*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint8FromInstanceByteField(Main m) { 2360*795d594fSAndroid Build Coastguard Worker return m.instanceByteField & 0xff; 2361*795d594fSAndroid Build Coastguard Worker } 2362*795d594fSAndroid Build Coastguard Worker 2363*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (before) 2364*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2365*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet 2366*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2367*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2368*795d594fSAndroid Build Coastguard Worker 2369*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) 2370*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet 2371*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2372*795d594fSAndroid Build Coastguard Worker 2373*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) 2374*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2375*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint8FromStaticByteField()2376*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint8FromStaticByteField() { 2377*795d594fSAndroid Build Coastguard Worker return staticByteField & 0xff; 2378*795d594fSAndroid Build Coastguard Worker } 2379*795d594fSAndroid Build Coastguard Worker 2380*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (before) 2381*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2382*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> ArrayGet 2383*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2384*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2385*795d594fSAndroid Build Coastguard Worker 2386*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) 2387*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:a\d+>> ArrayGet 2388*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2389*795d594fSAndroid Build Coastguard Worker 2390*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) 2391*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2392*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint8FromByteArray(byte[] a)2393*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint8FromByteArray(byte[] a) { 2394*795d594fSAndroid Build Coastguard Worker return a[0] & 0xff; 2395*795d594fSAndroid Build Coastguard Worker } 2396*795d594fSAndroid Build Coastguard Worker 2397*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (before) 2398*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 2399*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> InstanceFieldGet 2400*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] 2401*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2402*795d594fSAndroid Build Coastguard Worker 2403*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) 2404*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet 2405*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2406*795d594fSAndroid Build Coastguard Worker 2407*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) 2408*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2409*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint16FromInstanceShortField(Main m)2410*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint16FromInstanceShortField(Main m) { 2411*795d594fSAndroid Build Coastguard Worker return m.instanceShortField & 0xffff; 2412*795d594fSAndroid Build Coastguard Worker } 2413*795d594fSAndroid Build Coastguard Worker 2414*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (before) 2415*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 2416*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> StaticFieldGet 2417*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] 2418*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2419*795d594fSAndroid Build Coastguard Worker 2420*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) 2421*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet 2422*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2423*795d594fSAndroid Build Coastguard Worker 2424*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) 2425*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2426*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint16FromStaticShortField()2427*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint16FromStaticShortField() { 2428*795d594fSAndroid Build Coastguard Worker return staticShortField & 0xffff; 2429*795d594fSAndroid Build Coastguard Worker } 2430*795d594fSAndroid Build Coastguard Worker 2431*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (before) 2432*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 2433*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> ArrayGet 2434*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] 2435*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2436*795d594fSAndroid Build Coastguard Worker 2437*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) 2438*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> ArrayGet 2439*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2440*795d594fSAndroid Build Coastguard Worker 2441*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) 2442*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2443*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getUint16FromShortArray(short[] a)2444*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint16FromShortArray(short[] a) { 2445*795d594fSAndroid Build Coastguard Worker return a[0] & 0xffff; 2446*795d594fSAndroid Build Coastguard Worker } 2447*795d594fSAndroid Build Coastguard Worker 2448*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (before) 2449*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet 2450*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] 2451*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2452*795d594fSAndroid Build Coastguard Worker 2453*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) 2454*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> InstanceFieldGet 2455*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2456*795d594fSAndroid Build Coastguard Worker 2457*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) 2458*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2459*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getInt16FromInstanceCharField(Main m)2460*795d594fSAndroid Build Coastguard Worker public static int $noinline$getInt16FromInstanceCharField(Main m) { 2461*795d594fSAndroid Build Coastguard Worker return (short) m.instanceCharField; 2462*795d594fSAndroid Build Coastguard Worker } 2463*795d594fSAndroid Build Coastguard Worker 2464*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (before) 2465*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet 2466*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] 2467*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2468*795d594fSAndroid Build Coastguard Worker 2469*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) 2470*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> StaticFieldGet 2471*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2472*795d594fSAndroid Build Coastguard Worker 2473*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) 2474*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2475*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getInt16FromStaticCharField()2476*795d594fSAndroid Build Coastguard Worker public static int $noinline$getInt16FromStaticCharField() { 2477*795d594fSAndroid Build Coastguard Worker return (short) staticCharField; 2478*795d594fSAndroid Build Coastguard Worker } 2479*795d594fSAndroid Build Coastguard Worker 2480*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (before) 2481*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> ArrayGet 2482*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] 2483*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2484*795d594fSAndroid Build Coastguard Worker 2485*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) 2486*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:s\d+>> ArrayGet 2487*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] 2488*795d594fSAndroid Build Coastguard Worker 2489*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) 2490*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And 2491*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$getInt16FromCharArray(char[] a)2492*795d594fSAndroid Build Coastguard Worker public static int $noinline$getInt16FromCharArray(char[] a) { 2493*795d594fSAndroid Build Coastguard Worker return (short) a[0]; 2494*795d594fSAndroid Build Coastguard Worker } 2495*795d594fSAndroid Build Coastguard Worker 2496*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (before) 2497*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2498*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet 2499*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2500*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect [<<And>>{{(,[ij]\d+)?}}] 2501*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Invoke>>] 2502*795d594fSAndroid Build Coastguard Worker 2503*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (after) 2504*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet 2505*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect [<<Get>>{{(,[ij]\d+)?}}] 2506*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Invoke>>] 2507*795d594fSAndroid Build Coastguard Worker 2508*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (before) 2509*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet 2510*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Get>>] 2511*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2512*795d594fSAndroid Build Coastguard Worker 2513*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (after) 2514*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet 2515*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] $noinline$byteToUint8AndBack()2516*795d594fSAndroid Build Coastguard Worker public static int $noinline$byteToUint8AndBack() { 2517*795d594fSAndroid Build Coastguard Worker return $inline$toByte(staticByteField & 0xff); 2518*795d594fSAndroid Build Coastguard Worker } 2519*795d594fSAndroid Build Coastguard Worker $inline$toByte(int value)2520*795d594fSAndroid Build Coastguard Worker public static int $inline$toByte(int value) { 2521*795d594fSAndroid Build Coastguard Worker return (byte) value; 2522*795d594fSAndroid Build Coastguard Worker } 2523*795d594fSAndroid Build Coastguard Worker 2524*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (before) 2525*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2526*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet 2527*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2528*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2529*795d594fSAndroid Build Coastguard Worker 2530*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) 2531*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2532*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet 2533*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cnv:a\d+>> TypeConversion [<<Get>>] 2534*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Cnv>>] 2535*795d594fSAndroid Build Coastguard Worker 2536*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) 2537*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: {{a\d+}} StaticFieldGet $noinline$getStaticCharFieldAnd0xff()2538*795d594fSAndroid Build Coastguard Worker public static int $noinline$getStaticCharFieldAnd0xff() { 2539*795d594fSAndroid Build Coastguard Worker return staticCharField & 0xff; 2540*795d594fSAndroid Build Coastguard Worker } 2541*795d594fSAndroid Build Coastguard Worker 2542*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (before) 2543*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 2544*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2545*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet 2546*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] 2547*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,<<Const8>>] 2548*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<And>>,<<Shl>>] 2549*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 2550*795d594fSAndroid Build Coastguard Worker 2551*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) 2552*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 2553*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2554*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet 2555*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cnv:a\d+>> TypeConversion [<<Get>>] 2556*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,<<Const8>>] 2557*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Add:i\d+>> Add [<<Cnv>>,<<Shl>>] 2558*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Add>>] 2559*795d594fSAndroid Build Coastguard Worker 2560*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) 2561*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: {{a\d+}} InstanceFieldGet $noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main m)2562*795d594fSAndroid Build Coastguard Worker public static int $noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main m) { 2563*795d594fSAndroid Build Coastguard Worker byte b = m.instanceByteField; 2564*795d594fSAndroid Build Coastguard Worker int v1 = b & 0xff; 2565*795d594fSAndroid Build Coastguard Worker int v2 = (b << 8); 2566*795d594fSAndroid Build Coastguard Worker return v1 + v2; 2567*795d594fSAndroid Build Coastguard Worker } 2568*795d594fSAndroid Build Coastguard Worker 2569*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (before) 2570*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2571*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 2572*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const255>>] 2573*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:c\d+>> TypeConversion [<<And>>] 2574*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2575*795d594fSAndroid Build Coastguard Worker 2576*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (after) 2577*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2578*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:a\d+>> TypeConversion [<<Arg>>] 2579*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] $noinline$intAnd0xffToChar(int value)2580*795d594fSAndroid Build Coastguard Worker public static int $noinline$intAnd0xffToChar(int value) { 2581*795d594fSAndroid Build Coastguard Worker return (char) (value & 0xff); 2582*795d594fSAndroid Build Coastguard Worker } 2583*795d594fSAndroid Build Coastguard Worker 2584*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (before) 2585*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2586*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const511:i\d+>> IntConstant 511 2587*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const511>>] 2588*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:c\d+>> TypeConversion [<<And>>] 2589*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2590*795d594fSAndroid Build Coastguard Worker 2591*795d594fSAndroid Build Coastguard Worker // TODO: Simplify this. Unlike the $noinline$intAnd0xffToChar(), the TypeConversion 2592*795d594fSAndroid Build Coastguard Worker // to `char` is not eliminated despite the result of the And being within the `char` range. 2593*795d594fSAndroid Build Coastguard Worker 2594*795d594fSAndroid Build Coastguard Worker // CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (after) 2595*795d594fSAndroid Build Coastguard Worker // CHECK-DAG: <<Arg:i\d+>> ParameterValue 2596*795d594fSAndroid Build Coastguard Worker // CHECK-DAG: <<Const511:i\d+>> IntConstant 511 2597*795d594fSAndroid Build Coastguard Worker // CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const511>>] 2598*795d594fSAndroid Build Coastguard Worker // CHECK-DAG: Return [<<And>>] $noinline$intAnd0x1ffToChar(int value)2599*795d594fSAndroid Build Coastguard Worker public static int $noinline$intAnd0x1ffToChar(int value) { 2600*795d594fSAndroid Build Coastguard Worker return (char) (value & 0x1ff); 2601*795d594fSAndroid Build Coastguard Worker } 2602*795d594fSAndroid Build Coastguard Worker 2603*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (before) 2604*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Cst1ffff:i\d+>> IntConstant 131071 2605*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet 2606*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst1ffff>>] 2607*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<And>>] 2608*795d594fSAndroid Build Coastguard Worker 2609*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (after) 2610*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet 2611*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Get>>] $noinline$getInstanceCharFieldAnd0x1ffff(Main m)2612*795d594fSAndroid Build Coastguard Worker public static int $noinline$getInstanceCharFieldAnd0x1ffff(Main m) { 2613*795d594fSAndroid Build Coastguard Worker return m.instanceCharField & 0x1ffff; 2614*795d594fSAndroid Build Coastguard Worker } 2615*795d594fSAndroid Build Coastguard Worker 2616*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$bug68142795Byte(byte) instruction_simplifier (before) 2617*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 2618*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const:i\d+>> IntConstant 255 2619*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And1:i\d+>> And [<<Arg>>,<<Const>>] 2620*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And2:i\d+>> And [<<And1>>,<<Const>>] 2621*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<And2>>] 2622*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv>>] 2623*795d594fSAndroid Build Coastguard Worker 2624*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$bug68142795Byte(byte) instruction_simplifier (after) 2625*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 2626*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] $noinline$bug68142795Byte(byte b)2627*795d594fSAndroid Build Coastguard Worker public static int $noinline$bug68142795Byte(byte b) { 2628*795d594fSAndroid Build Coastguard Worker return (byte)(0xff & (b & 0xff)); 2629*795d594fSAndroid Build Coastguard Worker } 2630*795d594fSAndroid Build Coastguard Worker 2631*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$bug68142795Elaborate(byte) instruction_simplifier (before) 2632*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 2633*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Int255:i\d+>> IntConstant 255 2634*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Long255:j\d+>> LongConstant 255 2635*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And1:i\d+>> And [<<Arg>>,<<Int255>>] 2636*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv1:j\d+>> TypeConversion [<<And1>>] 2637*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<And2:j\d+>> And [<<Conv1>>,<<Long255>>] 2638*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv2:i\d+>> TypeConversion [<<And2>>] 2639*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Conv3:b\d+>> TypeConversion [<<Conv2>>] 2640*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Conv3>>] 2641*795d594fSAndroid Build Coastguard Worker 2642*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$bug68142795Elaborate(byte) instruction_simplifier (after) 2643*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:b\d+>> ParameterValue 2644*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Arg>>] $noinline$bug68142795Elaborate(byte b)2645*795d594fSAndroid Build Coastguard Worker public static int $noinline$bug68142795Elaborate(byte b) { 2646*795d594fSAndroid Build Coastguard Worker return (byte)((int)(((long)(b & 0xff)) & 255L)); 2647*795d594fSAndroid Build Coastguard Worker } 2648*795d594fSAndroid Build Coastguard Worker 2649*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (before) 2650*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2651*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Empty:l\d+>> LoadString 2652*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Equals:i\d+>> InvokeVirtual [<<Empty>>,<<Arg>>] intrinsic:StringIndexOf 2653*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Equals>>] 2654*795d594fSAndroid Build Coastguard Worker 2655*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (after) 2656*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InvokeVirtual 2657*795d594fSAndroid Build Coastguard Worker 2658*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (after) 2659*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Minus1:i\d+>> IntConstant -1 2660*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Minus1>>] $noinline$emptyStringIndexOf(int ch)2661*795d594fSAndroid Build Coastguard Worker public static int $noinline$emptyStringIndexOf(int ch) { 2662*795d594fSAndroid Build Coastguard Worker return "".indexOf(ch); 2663*795d594fSAndroid Build Coastguard Worker } 2664*795d594fSAndroid Build Coastguard Worker 2665*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (before) 2666*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 2667*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 2668*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Empty:l\d+>> LoadString 2669*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Equals:i\d+>> InvokeVirtual [<<Empty>>,<<Arg1>>,<<Arg2>>] intrinsic:StringIndexOfAfter 2670*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Equals>>] 2671*795d594fSAndroid Build Coastguard Worker 2672*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (after) 2673*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InvokeVirtual 2674*795d594fSAndroid Build Coastguard Worker 2675*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (after) 2676*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Minus1:i\d+>> IntConstant -1 2677*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Minus1>>] $noinline$emptyStringIndexOfAfter(int ch, int fromIndex)2678*795d594fSAndroid Build Coastguard Worker public static int $noinline$emptyStringIndexOfAfter(int ch, int fromIndex) { 2679*795d594fSAndroid Build Coastguard Worker return "".indexOf(ch, fromIndex); 2680*795d594fSAndroid Build Coastguard Worker } 2681*795d594fSAndroid Build Coastguard Worker 2682*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (before) 2683*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2684*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Empty:l\d+>> LoadString 2685*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Equals:i\d+>> InvokeVirtual [<<Empty>>,<<Arg>>] intrinsic:StringIndexOf 2686*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Equals>>] 2687*795d594fSAndroid Build Coastguard Worker 2688*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (after) 2689*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: InvokeVirtual 2690*795d594fSAndroid Build Coastguard Worker 2691*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (after) 2692*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 2693*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<x:i\d+>> IntConstant 120 2694*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Zero:i\d+>> IntConstant 0 2695*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Minus1:i\d+>> IntConstant -1 2696*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Eq:z\d+>> Equal [<<Arg>>,<<x>>] 2697*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Select:i\d+>> Select [<<Minus1>>,<<Zero>>,<<Eq>>] 2698*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Select>>] $noinline$singleCharStringIndexOf(int ch)2699*795d594fSAndroid Build Coastguard Worker public static int $noinline$singleCharStringIndexOf(int ch) { 2700*795d594fSAndroid Build Coastguard Worker return "x".indexOf(ch); 2701*795d594fSAndroid Build Coastguard Worker } 2702*795d594fSAndroid Build Coastguard Worker 2703*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$singleCharStringIndexOfAfter(int, int) instruction_simplifier (before) 2704*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 2705*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 2706*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Empty:l\d+>> LoadString 2707*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Equals:i\d+>> InvokeVirtual [<<Empty>>,<<Arg1>>,<<Arg2>>] intrinsic:StringIndexOfAfter 2708*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Equals>>] 2709*795d594fSAndroid Build Coastguard Worker 2710*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$singleCharStringIndexOfAfter(int, int) instruction_simplifier (after) 2711*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue 2712*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 2713*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Empty:l\d+>> LoadString 2714*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Equals:i\d+>> InvokeVirtual [<<Empty>>,<<Arg1>>,<<Arg2>>] intrinsic:StringIndexOfAfter 2715*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Return [<<Equals>>] $noinline$singleCharStringIndexOfAfter(int ch, int fromIndex)2716*795d594fSAndroid Build Coastguard Worker public static int $noinline$singleCharStringIndexOfAfter(int ch, int fromIndex) { 2717*795d594fSAndroid Build Coastguard Worker return "x".indexOf(ch, fromIndex); // Not simplified. 2718*795d594fSAndroid Build Coastguard Worker } 2719*795d594fSAndroid Build Coastguard Worker 2720*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndNotRedundant(int) instruction_simplifier (before) 2721*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2722*795d594fSAndroid Build Coastguard Worker 2723*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndNotRedundant(int) instruction_simplifier (after) 2724*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And $noinline$redundantAndNotRedundant(int value)2725*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndNotRedundant(int value) { 2726*795d594fSAndroid Build Coastguard Worker // Here the AND is not redundant. This test checks that it is not removed. 2727*795d594fSAndroid Build Coastguard Worker // 0xf500 = 1111 0101 0000 0000 - bits [11:8] of value will be changed by 2728*795d594fSAndroid Build Coastguard Worker // the AND with 0101. These bits are kept following the SHR and TypeConversion. 2729*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xf500) >> 8); 2730*795d594fSAndroid Build Coastguard Worker } 2731*795d594fSAndroid Build Coastguard Worker 2732*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndOtherUse(int) instruction_simplifier (before) 2733*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2734*795d594fSAndroid Build Coastguard Worker 2735*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndOtherUse(int) instruction_simplifier (after) 2736*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And $noinline$redundantAndOtherUse(int value)2737*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndOtherUse(int value){ 2738*795d594fSAndroid Build Coastguard Worker int v1 = value & 0xff00; 2739*795d594fSAndroid Build Coastguard Worker // Above AND is redundant in the context of calculating v2. 2740*795d594fSAndroid Build Coastguard Worker byte v2 = (byte) (v1 >> 8); 2741*795d594fSAndroid Build Coastguard Worker byte v3 = (byte) (v1 - 0x6eef); 2742*795d594fSAndroid Build Coastguard Worker // Use of AND result (v1) in calculating v3 means AND must not be removed. 2743*795d594fSAndroid Build Coastguard Worker return (byte) (v2 - v3); 2744*795d594fSAndroid Build Coastguard Worker } 2745*795d594fSAndroid Build Coastguard Worker 2746*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift2(short) instruction_simplifier (before) 2747*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2748*795d594fSAndroid Build Coastguard Worker 2749*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift2(short) instruction_simplifier (after) 2750*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift2(short value)2751*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift2(short value) { 2752*795d594fSAndroid Build Coastguard Worker // & 0xfff only changes bits higher than bit number 12 inclusive. 2753*795d594fSAndroid Build Coastguard Worker // These bits are discarded during Type Conversion to byte. 2754*795d594fSAndroid Build Coastguard Worker // Therefore AND is redundant and should be removed. 2755*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfff) >> 2); 2756*795d594fSAndroid Build Coastguard Worker } 2757*795d594fSAndroid Build Coastguard Worker 2758*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift5(short) instruction_simplifier (before) 2759*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2760*795d594fSAndroid Build Coastguard Worker 2761*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift5(short) instruction_simplifier (after) 2762*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift5(short value)2763*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift5(short value) { 2764*795d594fSAndroid Build Coastguard Worker // & 0xffe0 changes bits [4:0] and bits higher than 16 inclusive. 2765*795d594fSAndroid Build Coastguard Worker // These bits are discarded by the right shift and type conversion. 2766*795d594fSAndroid Build Coastguard Worker // Therefore AND is redundant and should be removed. 2767*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xffe0) >> 5); 2768*795d594fSAndroid Build Coastguard Worker } 2769*795d594fSAndroid Build Coastguard Worker 2770*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift8(short) instruction_simplifier (before) 2771*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2772*795d594fSAndroid Build Coastguard Worker 2773*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift8(short) instruction_simplifier (after) 2774*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift8(short value)2775*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift8(short value) { 2776*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xff00) >> 8); 2777*795d594fSAndroid Build Coastguard Worker } 2778*795d594fSAndroid Build Coastguard Worker 2779*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift9NotRedundant(short) instruction_simplifier (before) 2780*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2781*795d594fSAndroid Build Coastguard Worker 2782*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift9NotRedundant(short) instruction_simplifier (after) 2783*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And $noinline$redundantAndShortToByteShift9NotRedundant(short value)2784*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift9NotRedundant(short value) { 2785*795d594fSAndroid Build Coastguard Worker // Byte and Short operands for bitwise operations (e.g. &,>>) are promoted to Int32 prior to operation. 2786*795d594fSAndroid Build Coastguard Worker // Negative operands will be sign extended accordingly: (short: 0xff45) --> (int: 0xffffff45) 2787*795d594fSAndroid Build Coastguard Worker // & fe00 will clear bits [31:16]. For negative 'value', this will clear sign bits. 2788*795d594fSAndroid Build Coastguard Worker // Without the AND, the right shift will move the sign extended ones into the result instead of zeros. 2789*795d594fSAndroid Build Coastguard Worker // Therefore AND is not redundant and should not be removed. 2790*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfe00) >> 9); 2791*795d594fSAndroid Build Coastguard Worker } 2792*795d594fSAndroid Build Coastguard Worker 2793*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift10NotRedundant(short) instruction_simplifier (before) 2794*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2795*795d594fSAndroid Build Coastguard Worker 2796*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift10NotRedundant(short) instruction_simplifier (after) 2797*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And $noinline$redundantAndShortToByteShift10NotRedundant(short value)2798*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift10NotRedundant(short value) { 2799*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0x1ffff) >> 10); 2800*795d594fSAndroid Build Coastguard Worker } 2801*795d594fSAndroid Build Coastguard Worker 2802*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift12(short) instruction_simplifier (before) 2803*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2804*795d594fSAndroid Build Coastguard Worker 2805*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift12(short) instruction_simplifier (after) 2806*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift12(short value)2807*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift12(short value) { 2808*795d594fSAndroid Build Coastguard Worker // & fff00 preserves bits [19:8] and clears all others. 2809*795d594fSAndroid Build Coastguard Worker // Here the AND preserves enough ones; such that zeros are moved into the result. 2810*795d594fSAndroid Build Coastguard Worker // Therefore AND is redundant and can be removed. 2811*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfff00) >> 12); 2812*795d594fSAndroid Build Coastguard Worker } 2813*795d594fSAndroid Build Coastguard Worker 2814*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift15(short) instruction_simplifier (before) 2815*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2816*795d594fSAndroid Build Coastguard Worker 2817*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift15(short) instruction_simplifier (after) 2818*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift15(short value)2819*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift15(short value) { 2820*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xffff00) >> 15); 2821*795d594fSAndroid Build Coastguard Worker } 2822*795d594fSAndroid Build Coastguard Worker 2823*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift16(short) instruction_simplifier (before) 2824*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2825*795d594fSAndroid Build Coastguard Worker 2826*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShift16(short) instruction_simplifier (after) 2827*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShift16(short value)2828*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShift16(short value) { 2829*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xf0ffff00) >> 16); 2830*795d594fSAndroid Build Coastguard Worker } 2831*795d594fSAndroid Build Coastguard Worker 2832*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift2(int) instruction_simplifier (before) 2833*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2834*795d594fSAndroid Build Coastguard Worker 2835*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift2(int) instruction_simplifier (after) 2836*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift2(int value)2837*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift2(int value) { 2838*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfff) >> 2); 2839*795d594fSAndroid Build Coastguard Worker } 2840*795d594fSAndroid Build Coastguard Worker 2841*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift5(int) instruction_simplifier (before) 2842*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2843*795d594fSAndroid Build Coastguard Worker 2844*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift5(int) instruction_simplifier (after) 2845*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift5(int value)2846*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift5(int value) { 2847*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xffe0) >> 5); 2848*795d594fSAndroid Build Coastguard Worker } 2849*795d594fSAndroid Build Coastguard Worker 2850*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift8(int) instruction_simplifier (before) 2851*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2852*795d594fSAndroid Build Coastguard Worker 2853*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift8(int) instruction_simplifier (after) 2854*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift8(int value)2855*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift8(int value) { 2856*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xffffff00) >> 8); 2857*795d594fSAndroid Build Coastguard Worker } 2858*795d594fSAndroid Build Coastguard Worker 2859*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift9(int) instruction_simplifier (before) 2860*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2861*795d594fSAndroid Build Coastguard Worker 2862*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift9(int) instruction_simplifier (after) 2863*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift9(int value)2864*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift9(int value) { 2865*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xf001fe00) >> 9); 2866*795d594fSAndroid Build Coastguard Worker } 2867*795d594fSAndroid Build Coastguard Worker 2868*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift16(int) instruction_simplifier (before) 2869*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2870*795d594fSAndroid Build Coastguard Worker 2871*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift16(int) instruction_simplifier (after) 2872*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift16(int value)2873*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift16(int value) { 2874*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xf0ff0000) >> 16); 2875*795d594fSAndroid Build Coastguard Worker } 2876*795d594fSAndroid Build Coastguard Worker 2877*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift20(int) instruction_simplifier (before) 2878*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2879*795d594fSAndroid Build Coastguard Worker 2880*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift20(int) instruction_simplifier (after) 2881*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift20(int value)2882*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift20(int value) { 2883*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfff00000) >> 20); 2884*795d594fSAndroid Build Coastguard Worker } 2885*795d594fSAndroid Build Coastguard Worker 2886*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift25(int) instruction_simplifier (before) 2887*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2888*795d594fSAndroid Build Coastguard Worker 2889*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift25(int) instruction_simplifier (after) 2890*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift25(int value)2891*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift25(int value) { 2892*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xfe000000) >> 25); 2893*795d594fSAndroid Build Coastguard Worker } 2894*795d594fSAndroid Build Coastguard Worker 2895*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift24(int) instruction_simplifier (before) 2896*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2897*795d594fSAndroid Build Coastguard Worker 2898*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift24(int) instruction_simplifier (after) 2899*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift24(int value)2900*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift24(int value) { 2901*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xff000000) >> 24); 2902*795d594fSAndroid Build Coastguard Worker } 2903*795d594fSAndroid Build Coastguard Worker 2904*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift31(int) instruction_simplifier (before) 2905*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2906*795d594fSAndroid Build Coastguard Worker 2907*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShift31(int) instruction_simplifier (after) 2908*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShift31(int value)2909*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShift31(int value) { 2910*795d594fSAndroid Build Coastguard Worker return (byte) ((value & 0xff000000) >> 31); 2911*795d594fSAndroid Build Coastguard Worker } 2912*795d594fSAndroid Build Coastguard Worker 2913*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShortAndConstant(short) instruction_simplifier (before) 2914*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2915*795d594fSAndroid Build Coastguard Worker 2916*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndShortToByteShortAndConstant(short) instruction_simplifier (after) 2917*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndShortToByteShortAndConstant(short value)2918*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndShortToByteShortAndConstant(short value) { 2919*795d594fSAndroid Build Coastguard Worker short and_constant = (short) 0xff00; 2920*795d594fSAndroid Build Coastguard Worker return (byte) ((value & and_constant) >> 16); 2921*795d594fSAndroid Build Coastguard Worker } 2922*795d594fSAndroid Build Coastguard Worker 2923*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShortAndConstant(int) instruction_simplifier (before) 2924*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2925*795d594fSAndroid Build Coastguard Worker 2926*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndIntToByteShortAndConstant(int) instruction_simplifier (after) 2927*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: And $noinline$redundantAndIntToByteShortAndConstant(int value)2928*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndIntToByteShortAndConstant(int value) { 2929*795d594fSAndroid Build Coastguard Worker short and_constant = (short) 0xff00; 2930*795d594fSAndroid Build Coastguard Worker return (byte) ((value & and_constant) >> 16); 2931*795d594fSAndroid Build Coastguard Worker } 2932*795d594fSAndroid Build Coastguard Worker 2933*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndRegressionNotConstant(int, int) instruction_simplifier (before) 2934*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And 2935*795d594fSAndroid Build Coastguard Worker 2936*795d594fSAndroid Build Coastguard Worker /// CHECK-START: byte Main.$noinline$redundantAndRegressionNotConstant(int, int) instruction_simplifier (after) 2937*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: And $noinline$redundantAndRegressionNotConstant(int value, int mask)2938*795d594fSAndroid Build Coastguard Worker public static byte $noinline$redundantAndRegressionNotConstant(int value, int mask) { 2939*795d594fSAndroid Build Coastguard Worker return (byte) ((value & mask) >> 8); 2940*795d594fSAndroid Build Coastguard Worker } 2941*795d594fSAndroid Build Coastguard Worker 2942*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$deadAddAfterUnrollingAndSimplification(int[]) dead_code_elimination$before_codegen (before) 2943*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Param:l\d+>> ParameterValue loop:none 2944*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 loop:none 2945*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 loop:none 2946*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 loop:none 2947*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<IndexPhi:i\d+>> Phi [<<Const0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none 2948*795d594fSAndroid Build Coastguard Worker // Induction variable: 2949*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Add [<<IndexPhi>>,<<Const2>>] loop:<<Loop>> outer_loop:none 2950*795d594fSAndroid Build Coastguard Worker // Array Element Addition: 2951*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Store1:i\d+>> Add [{{i\d+}},<<Const1>>] loop:<<Loop>> outer_loop:none 2952*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Store2:i\d+>> Add [{{i\d+}},<<Const2>>] loop:<<Loop>> outer_loop:none 2953*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: ArraySet [<<Param>>,<<Const0>>,<<Store2>>] loop:<<Loop>> outer_loop:none 2954*795d594fSAndroid Build Coastguard Worker 2955*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$deadAddAfterUnrollingAndSimplification(int[]) dead_code_elimination$before_codegen (before) 2956*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2957*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2958*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2959*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2960*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add 2961*795d594fSAndroid Build Coastguard Worker 2962*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$deadAddAfterUnrollingAndSimplification(int[]) dead_code_elimination$before_codegen (after) 2963*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Param:l\d+>> ParameterValue loop:none 2964*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 loop:none 2965*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 loop:none 2966*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<IndexPhi:i\d+>> Phi [<<Const0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none 2967*795d594fSAndroid Build Coastguard Worker // Induction variable: 2968*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: Add [<<IndexPhi>>,<<Const2>>] loop:<<Loop>> outer_loop:none 2969*795d594fSAndroid Build Coastguard Worker // Array Element Addition: 2970*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: <<Store:i\d+>> Add [{{i\d+}},<<Const2>>] loop:<<Loop>> outer_loop:none 2971*795d594fSAndroid Build Coastguard Worker /// CHECK-DAG: ArraySet [<<Param>>,<<Const0>>,<<Store>>] loop:<<Loop>> outer_loop:none 2972*795d594fSAndroid Build Coastguard Worker 2973*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$deadAddAfterUnrollingAndSimplification(int[]) dead_code_elimination$before_codegen (after) 2974*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2975*795d594fSAndroid Build Coastguard Worker /// CHECK: Add 2976*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Add $noinline$deadAddAfterUnrollingAndSimplification(int[] array)2977*795d594fSAndroid Build Coastguard Worker public static int $noinline$deadAddAfterUnrollingAndSimplification(int[] array) { 2978*795d594fSAndroid Build Coastguard Worker for (int i = 0; i < 50; ++i) { 2979*795d594fSAndroid Build Coastguard Worker // Array access prevents transformation to closed-form expression 2980*795d594fSAndroid Build Coastguard Worker array[0]++; 2981*795d594fSAndroid Build Coastguard Worker } 2982*795d594fSAndroid Build Coastguard Worker return array[0]; 2983*795d594fSAndroid Build Coastguard Worker } 2984*795d594fSAndroid Build Coastguard Worker 2985*795d594fSAndroid Build Coastguard Worker // If a == b returns b (which is equal to a) else returns a. This can be simplified to just 2986*795d594fSAndroid Build Coastguard Worker // return a. 2987*795d594fSAndroid Build Coastguard Worker 2988*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (before) 2989*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 2990*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 2991*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:i\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 2992*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 2993*795d594fSAndroid Build Coastguard Worker 2994*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (after) 2995*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 2996*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 2997*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param1>>] 2998*795d594fSAndroid Build Coastguard Worker 2999*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (after) 3000*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Select $noinline$returnSecondIfEqualElseFirstInt(int a, int b)3001*795d594fSAndroid Build Coastguard Worker private static int $noinline$returnSecondIfEqualElseFirstInt(int a, int b) { 3002*795d594fSAndroid Build Coastguard Worker return a == b ? b : a; 3003*795d594fSAndroid Build Coastguard Worker } 3004*795d594fSAndroid Build Coastguard Worker 3005*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (before) 3006*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:j\d+>> ParameterValue 3007*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:j\d+>> ParameterValue 3008*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:j\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3009*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3010*795d594fSAndroid Build Coastguard Worker 3011*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (after) 3012*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:j\d+>> ParameterValue 3013*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:j\d+>> ParameterValue 3014*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param1>>] 3015*795d594fSAndroid Build Coastguard Worker 3016*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (after) 3017*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Select $noinline$returnSecondIfEqualElseFirstLong(long a, long b)3018*795d594fSAndroid Build Coastguard Worker private static long $noinline$returnSecondIfEqualElseFirstLong(long a, long b) { 3019*795d594fSAndroid Build Coastguard Worker return a == b ? b : a; 3020*795d594fSAndroid Build Coastguard Worker } 3021*795d594fSAndroid Build Coastguard Worker 3022*795d594fSAndroid Build Coastguard Worker // Note that we do not do the optimization for Float/Double. 3023*795d594fSAndroid Build Coastguard Worker 3024*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$returnSecondIfEqualElseFirstFloat(float, float) instruction_simplifier$after_gvn (before) 3025*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:f\d+>> ParameterValue 3026*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:f\d+>> ParameterValue 3027*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:f\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3028*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3029*795d594fSAndroid Build Coastguard Worker 3030*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$returnSecondIfEqualElseFirstFloat(float, float) disassembly (after) 3031*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:f\d+>> ParameterValue 3032*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:f\d+>> ParameterValue 3033*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:f\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3034*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] $noinline$returnSecondIfEqualElseFirstFloat(float a, float b)3035*795d594fSAndroid Build Coastguard Worker private static float $noinline$returnSecondIfEqualElseFirstFloat(float a, float b) { 3036*795d594fSAndroid Build Coastguard Worker return a == b ? b : a; 3037*795d594fSAndroid Build Coastguard Worker } 3038*795d594fSAndroid Build Coastguard Worker 3039*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$returnSecondIfEqualElseFirstDouble(double, double) instruction_simplifier$after_gvn (before) 3040*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:d\d+>> ParameterValue 3041*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:d\d+>> ParameterValue 3042*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:d\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3043*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3044*795d594fSAndroid Build Coastguard Worker 3045*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$returnSecondIfEqualElseFirstDouble(double, double) disassembly (after) 3046*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:d\d+>> ParameterValue 3047*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:d\d+>> ParameterValue 3048*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:d\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3049*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] $noinline$returnSecondIfEqualElseFirstDouble(double a, double b)3050*795d594fSAndroid Build Coastguard Worker private static double $noinline$returnSecondIfEqualElseFirstDouble(double a, double b) { 3051*795d594fSAndroid Build Coastguard Worker return a == b ? b : a; 3052*795d594fSAndroid Build Coastguard Worker } 3053*795d594fSAndroid Build Coastguard Worker 3054*795d594fSAndroid Build Coastguard Worker // If a != b returns b else returns a (which is equal to b). This can be simplified to just 3055*795d594fSAndroid Build Coastguard Worker // return b. 3056*795d594fSAndroid Build Coastguard Worker 3057*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfNotEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (before) 3058*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 3059*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 3060*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:i\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3061*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3062*795d594fSAndroid Build Coastguard Worker 3063*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfNotEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (after) 3064*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 3065*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 3066*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param2>>] 3067*795d594fSAndroid Build Coastguard Worker 3068*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$returnSecondIfNotEqualElseFirstInt(int, int) instruction_simplifier$after_gvn (after) 3069*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Select $noinline$returnSecondIfNotEqualElseFirstInt(int a, int b)3070*795d594fSAndroid Build Coastguard Worker private static int $noinline$returnSecondIfNotEqualElseFirstInt(int a, int b) { 3071*795d594fSAndroid Build Coastguard Worker return a != b ? b : a; 3072*795d594fSAndroid Build Coastguard Worker } 3073*795d594fSAndroid Build Coastguard Worker 3074*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfNotEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (before) 3075*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:j\d+>> ParameterValue 3076*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:j\d+>> ParameterValue 3077*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:j\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3078*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3079*795d594fSAndroid Build Coastguard Worker 3080*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfNotEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (after) 3081*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:j\d+>> ParameterValue 3082*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:j\d+>> ParameterValue 3083*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param2>>] 3084*795d594fSAndroid Build Coastguard Worker 3085*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$returnSecondIfNotEqualElseFirstLong(long, long) instruction_simplifier$after_gvn (after) 3086*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Select $noinline$returnSecondIfNotEqualElseFirstLong(long a, long b)3087*795d594fSAndroid Build Coastguard Worker private static long $noinline$returnSecondIfNotEqualElseFirstLong(long a, long b) { 3088*795d594fSAndroid Build Coastguard Worker return a != b ? b : a; 3089*795d594fSAndroid Build Coastguard Worker } 3090*795d594fSAndroid Build Coastguard Worker 3091*795d594fSAndroid Build Coastguard Worker // Note that we do not do the optimization for Float/Double. 3092*795d594fSAndroid Build Coastguard Worker 3093*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$returnSecondIfNotEqualElseFirstFloat(float, float) instruction_simplifier$after_gvn (before) 3094*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:f\d+>> ParameterValue 3095*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:f\d+>> ParameterValue 3096*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:f\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3097*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3098*795d594fSAndroid Build Coastguard Worker 3099*795d594fSAndroid Build Coastguard Worker /// CHECK-START: float Main.$noinline$returnSecondIfNotEqualElseFirstFloat(float, float) disassembly (after) 3100*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:f\d+>> ParameterValue 3101*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:f\d+>> ParameterValue 3102*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:f\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3103*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] $noinline$returnSecondIfNotEqualElseFirstFloat(float a, float b)3104*795d594fSAndroid Build Coastguard Worker private static float $noinline$returnSecondIfNotEqualElseFirstFloat(float a, float b) { 3105*795d594fSAndroid Build Coastguard Worker return a != b ? b : a; 3106*795d594fSAndroid Build Coastguard Worker } 3107*795d594fSAndroid Build Coastguard Worker 3108*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$returnSecondIfNotEqualElseFirstDouble(double, double) instruction_simplifier$after_gvn (before) 3109*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:d\d+>> ParameterValue 3110*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:d\d+>> ParameterValue 3111*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:d\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3112*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] 3113*795d594fSAndroid Build Coastguard Worker 3114*795d594fSAndroid Build Coastguard Worker /// CHECK-START: double Main.$noinline$returnSecondIfNotEqualElseFirstDouble(double, double) disassembly (after) 3115*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:d\d+>> ParameterValue 3116*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:d\d+>> ParameterValue 3117*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Select:d\d+>> Select [<<Param2>>,<<Param1>>,<<Cond:z\d+>>] 3118*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Select>>] $noinline$returnSecondIfNotEqualElseFirstDouble(double a, double b)3119*795d594fSAndroid Build Coastguard Worker private static double $noinline$returnSecondIfNotEqualElseFirstDouble(double a, double b) { 3120*795d594fSAndroid Build Coastguard Worker return a != b ? b : a; 3121*795d594fSAndroid Build Coastguard Worker } 3122*795d594fSAndroid Build Coastguard Worker 3123*795d594fSAndroid Build Coastguard Worker // Check that (x << N >>> N) and (x << N >> N) are simplified to corresponding TypeConversion. 3124*795d594fSAndroid Build Coastguard Worker 3125*795d594fSAndroid Build Coastguard Worker // Check T -> int -> Unsigned<T> -> int cases. 3126*795d594fSAndroid Build Coastguard Worker 3127*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsUnsigned(byte) instruction_simplifier (before) 3128*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3129*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3130*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3131*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3132*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3133*795d594fSAndroid Build Coastguard Worker 3134*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsUnsigned(byte) instruction_simplifier (after) 3135*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3136*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3137*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3138*795d594fSAndroid Build Coastguard Worker 3139*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsUnsigned(byte) instruction_simplifier (after) 3140*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3141*795d594fSAndroid Build Coastguard Worker 3142*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsUnsigned(byte) instruction_simplifier (after) 3143*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testByteToIntAsUnsigned(byte arg)3144*795d594fSAndroid Build Coastguard Worker private static int $noinline$testByteToIntAsUnsigned(byte arg) { 3145*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3146*795d594fSAndroid Build Coastguard Worker } 3147*795d594fSAndroid Build Coastguard Worker 3148*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsUnsigned(short) instruction_simplifier (before) 3149*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3150*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3151*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3152*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3153*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3154*795d594fSAndroid Build Coastguard Worker 3155*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsUnsigned(short) instruction_simplifier (after) 3156*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3157*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Param>>] 3158*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3159*795d594fSAndroid Build Coastguard Worker 3160*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsUnsigned(short) instruction_simplifier (after) 3161*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3162*795d594fSAndroid Build Coastguard Worker 3163*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsUnsigned(short) instruction_simplifier (after) 3164*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testShortToIntAsUnsigned(short arg)3165*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToIntAsUnsigned(short arg) { 3166*795d594fSAndroid Build Coastguard Worker return arg << 16 >>> 16; 3167*795d594fSAndroid Build Coastguard Worker } 3168*795d594fSAndroid Build Coastguard Worker 3169*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsUnsigned(char) instruction_simplifier (before) 3170*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3171*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3172*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3173*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3174*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3175*795d594fSAndroid Build Coastguard Worker 3176*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsUnsigned(char) instruction_simplifier (after) 3177*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3178*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3179*795d594fSAndroid Build Coastguard Worker 3180*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsUnsigned(char) instruction_simplifier (after) 3181*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3182*795d594fSAndroid Build Coastguard Worker 3183*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsUnsigned(char) instruction_simplifier (after) 3184*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testCharToIntAsUnsigned(char arg)3185*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToIntAsUnsigned(char arg) { 3186*795d594fSAndroid Build Coastguard Worker return arg << 16 >>> 16; 3187*795d594fSAndroid Build Coastguard Worker } 3188*795d594fSAndroid Build Coastguard Worker 3189*795d594fSAndroid Build Coastguard Worker // Check T -> int -> Signed<T> -> int cases. 3190*795d594fSAndroid Build Coastguard Worker 3191*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsSigned(byte) instruction_simplifier (before) 3192*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3193*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3194*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3195*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3196*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3197*795d594fSAndroid Build Coastguard Worker 3198*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsSigned(byte) instruction_simplifier (after) 3199*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3200*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3201*795d594fSAndroid Build Coastguard Worker 3202*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsSigned(byte) instruction_simplifier (after) 3203*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3204*795d594fSAndroid Build Coastguard Worker 3205*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToIntAsSigned(byte) instruction_simplifier (after) 3206*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testByteToIntAsSigned(byte arg)3207*795d594fSAndroid Build Coastguard Worker private static int $noinline$testByteToIntAsSigned(byte arg) { 3208*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3209*795d594fSAndroid Build Coastguard Worker } 3210*795d594fSAndroid Build Coastguard Worker 3211*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsSigned(short) instruction_simplifier (before) 3212*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3213*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3214*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3215*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3216*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3217*795d594fSAndroid Build Coastguard Worker 3218*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsSigned(short) instruction_simplifier (after) 3219*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3220*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3221*795d594fSAndroid Build Coastguard Worker 3222*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsSigned(short) instruction_simplifier (after) 3223*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3224*795d594fSAndroid Build Coastguard Worker 3225*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToIntAsSigned(short) instruction_simplifier (after) 3226*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testShortToIntAsSigned(short arg)3227*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToIntAsSigned(short arg) { 3228*795d594fSAndroid Build Coastguard Worker return arg << 16 >> 16; 3229*795d594fSAndroid Build Coastguard Worker } 3230*795d594fSAndroid Build Coastguard Worker 3231*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsSigned(char) instruction_simplifier (before) 3232*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3233*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3234*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3235*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3236*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3237*795d594fSAndroid Build Coastguard Worker 3238*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsSigned(char) instruction_simplifier (after) 3239*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3240*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:s\d+>> TypeConversion [<<Param>>] 3241*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3242*795d594fSAndroid Build Coastguard Worker 3243*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsSigned(char) instruction_simplifier (after) 3244*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3245*795d594fSAndroid Build Coastguard Worker 3246*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToIntAsSigned(char) instruction_simplifier (after) 3247*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testCharToIntAsSigned(char arg)3248*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToIntAsSigned(char arg) { 3249*795d594fSAndroid Build Coastguard Worker return arg << 16 >> 16; 3250*795d594fSAndroid Build Coastguard Worker } 3251*795d594fSAndroid Build Coastguard Worker 3252*795d594fSAndroid Build Coastguard Worker // Check T -> U (narrowing) -> int cases where M is unsigned type. 3253*795d594fSAndroid Build Coastguard Worker 3254*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsUnsigned(short) instruction_simplifier (before) 3255*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3256*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3257*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3258*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3259*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3260*795d594fSAndroid Build Coastguard Worker 3261*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsUnsigned(short) instruction_simplifier (after) 3262*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3263*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3264*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3265*795d594fSAndroid Build Coastguard Worker 3266*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsUnsigned(short) instruction_simplifier (after) 3267*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3268*795d594fSAndroid Build Coastguard Worker 3269*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsUnsigned(short) instruction_simplifier (after) 3270*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testShortToByteToIntAsUnsigned(short arg)3271*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToByteToIntAsUnsigned(short arg) { 3272*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3273*795d594fSAndroid Build Coastguard Worker } 3274*795d594fSAndroid Build Coastguard Worker 3275*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsUnsigned(char) instruction_simplifier (before) 3276*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3277*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3278*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3279*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3280*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3281*795d594fSAndroid Build Coastguard Worker 3282*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsUnsigned(char) instruction_simplifier (after) 3283*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3284*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3285*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3286*795d594fSAndroid Build Coastguard Worker 3287*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsUnsigned(char) instruction_simplifier (after) 3288*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3289*795d594fSAndroid Build Coastguard Worker 3290*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsUnsigned(char) instruction_simplifier (after) 3291*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testCharToByteToIntAsUnsigned(char arg)3292*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToByteToIntAsUnsigned(char arg) { 3293*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3294*795d594fSAndroid Build Coastguard Worker } 3295*795d594fSAndroid Build Coastguard Worker 3296*795d594fSAndroid Build Coastguard Worker // Check T -> S (narrowing) -> int cases where S is signed type. 3297*795d594fSAndroid Build Coastguard Worker 3298*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsSigned(short) instruction_simplifier (before) 3299*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3300*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3301*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3302*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3303*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3304*795d594fSAndroid Build Coastguard Worker 3305*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsSigned(short) instruction_simplifier (after) 3306*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3307*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3308*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3309*795d594fSAndroid Build Coastguard Worker 3310*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsSigned(short) instruction_simplifier (after) 3311*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3312*795d594fSAndroid Build Coastguard Worker 3313*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToByteToIntAsSigned(short) instruction_simplifier (after) 3314*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testShortToByteToIntAsSigned(short arg)3315*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToByteToIntAsSigned(short arg) { 3316*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3317*795d594fSAndroid Build Coastguard Worker } 3318*795d594fSAndroid Build Coastguard Worker 3319*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsSigned(char) instruction_simplifier (before) 3320*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3321*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3322*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3323*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3324*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3325*795d594fSAndroid Build Coastguard Worker 3326*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsSigned(char) instruction_simplifier (after) 3327*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3328*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3329*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3330*795d594fSAndroid Build Coastguard Worker 3331*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsSigned(char) instruction_simplifier (after) 3332*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3333*795d594fSAndroid Build Coastguard Worker 3334*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToByteToIntAsSigned(char) instruction_simplifier (after) 3335*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testCharToByteToIntAsSigned(char arg)3336*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToByteToIntAsSigned(char arg) { 3337*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3338*795d594fSAndroid Build Coastguard Worker } 3339*795d594fSAndroid Build Coastguard Worker 3340*795d594fSAndroid Build Coastguard Worker // Check int -> U -> int cases where U is a unsigned type. 3341*795d594fSAndroid Build Coastguard Worker 3342*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedByteToInt(int) instruction_simplifier (before) 3343*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3344*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3345*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3346*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3347*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3348*795d594fSAndroid Build Coastguard Worker 3349*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedByteToInt(int) instruction_simplifier (after) 3350*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3351*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3352*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3353*795d594fSAndroid Build Coastguard Worker 3354*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedByteToInt(int) instruction_simplifier (after) 3355*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3356*795d594fSAndroid Build Coastguard Worker 3357*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedByteToInt(int) instruction_simplifier (after) 3358*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testIntToUnsignedByteToInt(int arg)3359*795d594fSAndroid Build Coastguard Worker private static int $noinline$testIntToUnsignedByteToInt(int arg) { 3360*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3361*795d594fSAndroid Build Coastguard Worker } 3362*795d594fSAndroid Build Coastguard Worker 3363*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedShortToInt(int) instruction_simplifier (before) 3364*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3365*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3366*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3367*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3368*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3369*795d594fSAndroid Build Coastguard Worker 3370*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedShortToInt(int) instruction_simplifier (after) 3371*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3372*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Param>>] 3373*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3374*795d594fSAndroid Build Coastguard Worker 3375*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedShortToInt(int) instruction_simplifier (after) 3376*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3377*795d594fSAndroid Build Coastguard Worker 3378*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToUnsignedShortToInt(int) instruction_simplifier (after) 3379*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testIntToUnsignedShortToInt(int arg)3380*795d594fSAndroid Build Coastguard Worker private static int $noinline$testIntToUnsignedShortToInt(int arg) { 3381*795d594fSAndroid Build Coastguard Worker return arg << 16 >>> 16; 3382*795d594fSAndroid Build Coastguard Worker } 3383*795d594fSAndroid Build Coastguard Worker 3384*795d594fSAndroid Build Coastguard Worker // Check int -> S -> int cases where S is a signed type. 3385*795d594fSAndroid Build Coastguard Worker 3386*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedByteToInt(int) instruction_simplifier (before) 3387*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3388*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3389*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3390*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3391*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3392*795d594fSAndroid Build Coastguard Worker 3393*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedByteToInt(int) instruction_simplifier (after) 3394*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3395*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3396*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3397*795d594fSAndroid Build Coastguard Worker 3398*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedByteToInt(int) instruction_simplifier (after) 3399*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3400*795d594fSAndroid Build Coastguard Worker 3401*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedByteToInt(int) instruction_simplifier (after) 3402*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testIntToSignedByteToInt(int arg)3403*795d594fSAndroid Build Coastguard Worker private static int $noinline$testIntToSignedByteToInt(int arg) { 3404*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3405*795d594fSAndroid Build Coastguard Worker } 3406*795d594fSAndroid Build Coastguard Worker 3407*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedShortToInt(int) instruction_simplifier (before) 3408*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3409*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3410*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3411*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3412*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3413*795d594fSAndroid Build Coastguard Worker 3414*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedShortToInt(int) instruction_simplifier (after) 3415*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3416*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:s\d+>> TypeConversion [<<Param>>] 3417*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3418*795d594fSAndroid Build Coastguard Worker 3419*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedShortToInt(int) instruction_simplifier (after) 3420*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3421*795d594fSAndroid Build Coastguard Worker 3422*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testIntToSignedShortToInt(int) instruction_simplifier (after) 3423*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testIntToSignedShortToInt(int arg)3424*795d594fSAndroid Build Coastguard Worker private static int $noinline$testIntToSignedShortToInt(int arg) { 3425*795d594fSAndroid Build Coastguard Worker return arg << 16 >> 16; 3426*795d594fSAndroid Build Coastguard Worker } 3427*795d594fSAndroid Build Coastguard Worker 3428*795d594fSAndroid Build Coastguard Worker // Check T -> U -> int cases where U is a unsigned type. 3429*795d594fSAndroid Build Coastguard Worker 3430*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToUnsignedByteToInt(char) instruction_simplifier (before) 3431*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3432*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3433*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3434*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3435*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3436*795d594fSAndroid Build Coastguard Worker 3437*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToUnsignedByteToInt(char) instruction_simplifier (after) 3438*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3439*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3440*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3441*795d594fSAndroid Build Coastguard Worker 3442*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToUnsignedByteToInt(char) instruction_simplifier (after) 3443*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3444*795d594fSAndroid Build Coastguard Worker 3445*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToUnsignedByteToInt(char) instruction_simplifier (after) 3446*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testCharToUnsignedByteToInt(char arg)3447*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToUnsignedByteToInt(char arg) { 3448*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3449*795d594fSAndroid Build Coastguard Worker } 3450*795d594fSAndroid Build Coastguard Worker 3451*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToUnsignedByteToInt(short) instruction_simplifier (before) 3452*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3453*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3454*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3455*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3456*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3457*795d594fSAndroid Build Coastguard Worker 3458*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToUnsignedByteToInt(short) instruction_simplifier (after) 3459*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3460*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:a\d+>> TypeConversion [<<Param>>] 3461*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3462*795d594fSAndroid Build Coastguard Worker 3463*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToUnsignedByteToInt(short) instruction_simplifier (after) 3464*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3465*795d594fSAndroid Build Coastguard Worker 3466*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToUnsignedByteToInt(short) instruction_simplifier (after) 3467*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testShortToUnsignedByteToInt(short arg)3468*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToUnsignedByteToInt(short arg) { 3469*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 24; 3470*795d594fSAndroid Build Coastguard Worker } 3471*795d594fSAndroid Build Coastguard Worker 3472*795d594fSAndroid Build Coastguard Worker // Check T -> S -> int cases where S is a signed type. 3473*795d594fSAndroid Build Coastguard Worker 3474*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToSignedByteToInt(char) instruction_simplifier (before) 3475*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3476*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3477*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3478*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3479*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3480*795d594fSAndroid Build Coastguard Worker 3481*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToSignedByteToInt(char) instruction_simplifier (after) 3482*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3483*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3484*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3485*795d594fSAndroid Build Coastguard Worker 3486*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToSignedByteToInt(char) instruction_simplifier (after) 3487*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3488*795d594fSAndroid Build Coastguard Worker 3489*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToSignedByteToInt(char) instruction_simplifier (after) 3490*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testCharToSignedByteToInt(char arg)3491*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToSignedByteToInt(char arg) { 3492*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3493*795d594fSAndroid Build Coastguard Worker } 3494*795d594fSAndroid Build Coastguard Worker 3495*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToSignedByteToInt(short) instruction_simplifier (before) 3496*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3497*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3498*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3499*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3500*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3501*795d594fSAndroid Build Coastguard Worker 3502*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToSignedByteToInt(short) instruction_simplifier (after) 3503*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3504*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3505*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3506*795d594fSAndroid Build Coastguard Worker 3507*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToSignedByteToInt(short) instruction_simplifier (after) 3508*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3509*795d594fSAndroid Build Coastguard Worker 3510*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToSignedByteToInt(short) instruction_simplifier (after) 3511*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testShortToSignedByteToInt(short arg)3512*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToSignedByteToInt(short arg) { 3513*795d594fSAndroid Build Coastguard Worker return arg << 24 >> 24; 3514*795d594fSAndroid Build Coastguard Worker } 3515*795d594fSAndroid Build Coastguard Worker 3516*795d594fSAndroid Build Coastguard Worker // Check cases with shift amounts > 32. 3517*795d594fSAndroid Build Coastguard Worker 3518*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeShiftAmount(int) instruction_simplifier (before) 3519*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3520*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const48:i\d+>> IntConstant 48 3521*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const48>>] 3522*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const48>>] 3523*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3524*795d594fSAndroid Build Coastguard Worker 3525*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeShiftAmount(int) instruction_simplifier (after) 3526*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3527*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Param>>] 3528*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3529*795d594fSAndroid Build Coastguard Worker 3530*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeShiftAmount(int) instruction_simplifier (after) 3531*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3532*795d594fSAndroid Build Coastguard Worker 3533*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeShiftAmount(int) instruction_simplifier (after) 3534*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testUnsignedPromotionWithHugeShiftAmount(int arg)3535*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionWithHugeShiftAmount(int arg) { 3536*795d594fSAndroid Build Coastguard Worker return arg << 48 >>> 48; 3537*795d594fSAndroid Build Coastguard Worker } 3538*795d594fSAndroid Build Coastguard Worker 3539*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int) instruction_simplifier (before) 3540*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3541*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const48:i\d+>> IntConstant 48 3542*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3543*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const48>>] 3544*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3545*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3546*795d594fSAndroid Build Coastguard Worker 3547*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int) instruction_simplifier (after) 3548*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3549*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Param>>] 3550*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3551*795d594fSAndroid Build Coastguard Worker 3552*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int) instruction_simplifier (after) 3553*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3554*795d594fSAndroid Build Coastguard Worker 3555*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int) instruction_simplifier (after) 3556*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: UShr $noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int arg)3557*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(int arg) { 3558*795d594fSAndroid Build Coastguard Worker return arg << 48 >>> 16; 3559*795d594fSAndroid Build Coastguard Worker } 3560*795d594fSAndroid Build Coastguard Worker 3561*795d594fSAndroid Build Coastguard Worker // Negative checks. 3562*795d594fSAndroid Build Coastguard Worker 3563*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testUnsignedPromotionToLong(long) instruction_simplifier (after) 3564*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:j\d+>> ParameterValue 3565*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const56:i\d+>> IntConstant 56 3566*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:j\d+>> Shl [<<Param>>,<<Const56>>] 3567*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:j\d+>> UShr [<<Shl>>,<<Const56>>] 3568*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] $noinline$testUnsignedPromotionToLong(long arg)3569*795d594fSAndroid Build Coastguard Worker private static long $noinline$testUnsignedPromotionToLong(long arg) { 3570*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of unsigned promotion to long. 3571*795d594fSAndroid Build Coastguard Worker return arg << 56 >>> 56; 3572*795d594fSAndroid Build Coastguard Worker } 3573*795d594fSAndroid Build Coastguard Worker 3574*795d594fSAndroid Build Coastguard Worker /// CHECK-START: long Main.$noinline$testSignedPromotionToLong(long) instruction_simplifier (after) 3575*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:j\d+>> ParameterValue 3576*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const56:i\d+>> IntConstant 56 3577*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:j\d+>> Shl [<<Param>>,<<Const56>>] 3578*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:j\d+>> Shr [<<Shl>>,<<Const56>>] 3579*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] $noinline$testSignedPromotionToLong(long arg)3580*795d594fSAndroid Build Coastguard Worker private static long $noinline$testSignedPromotionToLong(long arg) { 3581*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of signed promotion to long. 3582*795d594fSAndroid Build Coastguard Worker return arg << 56 >> 56; 3583*795d594fSAndroid Build Coastguard Worker } 3584*795d594fSAndroid Build Coastguard Worker 3585*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithNonConstantShiftAmount(int, int) instruction_simplifier (after) 3586*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 3587*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 3588*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param1>>,<<Param2>>] 3589*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Param2>>] 3590*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3591*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionWithNonConstantShiftAmount(int value, int shift_amount)3592*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionWithNonConstantShiftAmount(int value, int shift_amount) { 3593*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of unsigned promotion with 3594*795d594fSAndroid Build Coastguard Worker // non constant shift amount. 3595*795d594fSAndroid Build Coastguard Worker return value << shift_amount >>> shift_amount; 3596*795d594fSAndroid Build Coastguard Worker } 3597*795d594fSAndroid Build Coastguard Worker 3598*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSignedPromotionWithNonConstantShiftAmount(int, int) instruction_simplifier (after) 3599*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param1:i\d+>> ParameterValue 3600*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param2:i\d+>> ParameterValue 3601*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param1>>,<<Param2>>] 3602*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Param2>>] 3603*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3604*795d594fSAndroid Build Coastguard Worker private static int $noinline$testSignedPromotionWithNonConstantShiftAmount(int value, int shift_amount)3605*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionWithNonConstantShiftAmount(int value, int shift_amount) { 3606*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of signed promotion with 3607*795d594fSAndroid Build Coastguard Worker // non constant shift amount. 3608*795d594fSAndroid Build Coastguard Worker return value << shift_amount >> shift_amount; 3609*795d594fSAndroid Build Coastguard Worker } 3610*795d594fSAndroid Build Coastguard Worker 3611*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionWithShlUse(int) instruction_simplifier (after) 3612*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3613*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3614*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3615*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3616*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Add:i\d+>> Add [<<UShr>>,<<Shl>>] 3617*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Add>>] $noinline$testUnsignedPromotionWithShlUse(int arg)3618*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionWithShlUse(int arg) { 3619*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of unsigned promotion 3620*795d594fSAndroid Build Coastguard Worker // with shl instruction that has more than 1 user. 3621*795d594fSAndroid Build Coastguard Worker int tmp = arg << 24; 3622*795d594fSAndroid Build Coastguard Worker return (tmp >>> 24) + tmp; 3623*795d594fSAndroid Build Coastguard Worker } 3624*795d594fSAndroid Build Coastguard Worker 3625*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSignedPromotionWithShlUse(int) instruction_simplifier (after) 3626*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3627*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3628*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3629*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3630*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Add:i\d+>> Add [<<Shr>>,<<Shl>>] 3631*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Add>>] $noinline$testSignedPromotionWithShlUse(int arg)3632*795d594fSAndroid Build Coastguard Worker private static int $noinline$testSignedPromotionWithShlUse(int arg) { 3633*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of signed promotion 3634*795d594fSAndroid Build Coastguard Worker // with shl instruction that has more than 1 user. 3635*795d594fSAndroid Build Coastguard Worker int tmp = arg << 24; 3636*795d594fSAndroid Build Coastguard Worker return (tmp >> 24) + tmp; 3637*795d594fSAndroid Build Coastguard Worker } 3638*795d594fSAndroid Build Coastguard Worker 3639*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionPatternWithIncorrectShiftAmountConstant(int) instruction_simplifier (after) 3640*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3641*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const25:i\d+>> IntConstant 25 3642*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const25>>] 3643*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const25>>] 3644*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3645*795d594fSAndroid Build Coastguard Worker 3646*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionPatternWithIncorrectShiftAmountConstant(int arg)3647*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionPatternWithIncorrectShiftAmountConstant(int arg) { 3648*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of 32 - N doesn't correspond 3649*795d594fSAndroid Build Coastguard Worker // to the size of an integral type. 3650*795d594fSAndroid Build Coastguard Worker return arg << 25 >>> 25; 3651*795d594fSAndroid Build Coastguard Worker } 3652*795d594fSAndroid Build Coastguard Worker 3653*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSignedPromotionPatternWithIncorrectShiftAmountConstant(int) instruction_simplifier (after) 3654*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3655*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const25:i\d+>> IntConstant 25 3656*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const25>>] 3657*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const25>>] 3658*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3659*795d594fSAndroid Build Coastguard Worker 3660*795d594fSAndroid Build Coastguard Worker private static int $noinline$testSignedPromotionPatternWithIncorrectShiftAmountConstant(int arg)3661*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionPatternWithIncorrectShiftAmountConstant(int arg) { 3662*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of 32 - N doesn't correspond 3663*795d594fSAndroid Build Coastguard Worker // to the size of an integral type. 3664*795d594fSAndroid Build Coastguard Worker return arg << 25 >> 25; 3665*795d594fSAndroid Build Coastguard Worker } 3666*795d594fSAndroid Build Coastguard Worker 3667*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedPromotionPatternWithDifferentShiftAmountConstants(int) instruction_simplifier (after) 3668*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3669*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3670*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3671*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3672*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3673*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<UShr>>] 3674*795d594fSAndroid Build Coastguard Worker 3675*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedPromotionPatternWithDifferentShiftAmountConstants(int arg)3676*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionPatternWithDifferentShiftAmountConstants(int arg) { 3677*795d594fSAndroid Build Coastguard Worker // Check that we don't do simplification in the case of different shift amounts. 3678*795d594fSAndroid Build Coastguard Worker return arg << 24 >>> 16; 3679*795d594fSAndroid Build Coastguard Worker } 3680*795d594fSAndroid Build Coastguard Worker 3681*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testSignedPromotionPatternWithDifferentShiftAmountConstants(int) instruction_simplifier (after) 3682*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:i\d+>> ParameterValue 3683*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const25:i\d+>> IntConstant 25 3684*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const26:i\d+>> IntConstant 26 3685*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const25>>] 3686*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const26>>] 3687*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Shr>>] 3688*795d594fSAndroid Build Coastguard Worker 3689*795d594fSAndroid Build Coastguard Worker private static $noinline$testSignedPromotionPatternWithDifferentShiftAmountConstants(int arg)3690*795d594fSAndroid Build Coastguard Worker int $noinline$testSignedPromotionPatternWithDifferentShiftAmountConstants(int arg) { 3691*795d594fSAndroid Build Coastguard Worker // Check that we do not simplification in the case of different shift amounts. 3692*795d594fSAndroid Build Coastguard Worker return arg << 25 >> 26; 3693*795d594fSAndroid Build Coastguard Worker } 3694*795d594fSAndroid Build Coastguard Worker 3695*795d594fSAndroid Build Coastguard Worker // Check that we don't introduce new implicit type conversions so the following pattern 3696*795d594fSAndroid Build Coastguard Worker // does not occur in the graph: 3697*795d594fSAndroid Build Coastguard Worker // 3698*795d594fSAndroid Build Coastguard Worker // <<ImplicitConv>> TypeConversion 3699*795d594fSAndroid Build Coastguard Worker // <<ExplicitConv>> TypeConversonn [<<ImplicitConv>>] 3700*795d594fSAndroid Build Coastguard Worker // 3701*795d594fSAndroid Build Coastguard Worker // That will lead to a crash because InstructionSimplifier removes implicit type conversions 3702*795d594fSAndroid Build Coastguard Worker // and during visiting TypeConversion instruction expects that its inputs have been already 3703*795d594fSAndroid Build Coastguard Worker // simplified. 3704*795d594fSAndroid Build Coastguard Worker // 3705*795d594fSAndroid Build Coastguard Worker // The structure of the following tests is 3706*795d594fSAndroid Build Coastguard Worker // 3707*795d594fSAndroid Build Coastguard Worker // (T) ((x << N) >> N) or (T) ((x << N) >>> N) 3708*795d594fSAndroid Build Coastguard Worker // 3709*795d594fSAndroid Build Coastguard Worker // where 3710*795d594fSAndroid Build Coastguard Worker // * K is a type of x 3711*795d594fSAndroid Build Coastguard Worker // * Shifts correspond to implicit type conversion K -> M 3712*795d594fSAndroid Build Coastguard Worker // * M -> T conversion is explicit 3713*795d594fSAndroid Build Coastguard Worker // 3714*795d594fSAndroid Build Coastguard Worker // T itself doesn't matter, the only important thing is that M -> T is explicit. 3715*795d594fSAndroid Build Coastguard Worker // 3716*795d594fSAndroid Build Coastguard Worker // We check cases when shifts correspond to the following implicit type conversions: 3717*795d594fSAndroid Build Coastguard Worker // byte -> byte 3718*795d594fSAndroid Build Coastguard Worker // byte -> short 3719*795d594fSAndroid Build Coastguard Worker // unsigned byte -> unsigned byte 3720*795d594fSAndroid Build Coastguard Worker // unsigned byte -> short 3721*795d594fSAndroid Build Coastguard Worker // unsigned byte -> char 3722*795d594fSAndroid Build Coastguard Worker // short -> short 3723*795d594fSAndroid Build Coastguard Worker // char -> char 3724*795d594fSAndroid Build Coastguard Worker // 3725*795d594fSAndroid Build Coastguard Worker // To produce unsigned byte bitwise AND with 0xFF is used. 3726*795d594fSAndroid Build Coastguard Worker 3727*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToByteToChar(byte) instruction_simplifier (before) 3728*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3729*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3730*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const24>>] 3731*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const24>>] 3732*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Shr>>] 3733*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3734*795d594fSAndroid Build Coastguard Worker 3735*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToByteToChar(byte) instruction_simplifier (after) 3736*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3737*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:c\d+>> TypeConversion [<<Param>>] 3738*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3739*795d594fSAndroid Build Coastguard Worker 3740*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToByteToChar(byte) instruction_simplifier (after) 3741*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3742*795d594fSAndroid Build Coastguard Worker 3743*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToByteToChar(byte) instruction_simplifier (after) 3744*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testByteToByteToChar(byte arg)3745*795d594fSAndroid Build Coastguard Worker private static int $noinline$testByteToByteToChar(byte arg) { 3746*795d594fSAndroid Build Coastguard Worker return (char) ((arg << 24) >> 24); 3747*795d594fSAndroid Build Coastguard Worker } 3748*795d594fSAndroid Build Coastguard Worker 3749*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToShortToByte(byte) instruction_simplifier (before) 3750*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3751*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3752*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3753*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3754*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Shr>>] 3755*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3756*795d594fSAndroid Build Coastguard Worker 3757*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToShortToByte(byte) instruction_simplifier (after) 3758*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3759*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3760*795d594fSAndroid Build Coastguard Worker 3761*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToShortToByte(byte) instruction_simplifier (after) 3762*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3763*795d594fSAndroid Build Coastguard Worker 3764*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToShortToByte(byte) instruction_simplifier (after) 3765*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 3766*795d594fSAndroid Build Coastguard Worker 3767*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testByteToShortToByte(byte) instruction_simplifier (after) 3768*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$testByteToShortToByte(byte arg)3769*795d594fSAndroid Build Coastguard Worker private static int $noinline$testByteToShortToByte(byte arg) { 3770*795d594fSAndroid Build Coastguard Worker return (byte) ((arg << 16) >> 16); 3771*795d594fSAndroid Build Coastguard Worker } 3772*795d594fSAndroid Build Coastguard Worker 3773*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToUnsignedByteToByte(byte) instruction_simplifier (before) 3774*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3775*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const255:i\d+>> IntConstant 255 3776*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const24:i\d+>> IntConstant 24 3777*795d594fSAndroid Build Coastguard Worker /// CHECK: <<And:i\d+>> And [<<Param>>,<<Const255>>] 3778*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<And>>,<<Const24>>] 3779*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const24>>] 3780*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<UShr>>] 3781*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3782*795d594fSAndroid Build Coastguard Worker 3783*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToUnsignedByteToByte(byte) instruction_simplifier (after) 3784*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3785*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3786*795d594fSAndroid Build Coastguard Worker 3787*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToUnsignedByteToByte(byte) instruction_simplifier (after) 3788*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3789*795d594fSAndroid Build Coastguard Worker 3790*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToUnsignedByteToByte(byte) instruction_simplifier (after) 3791*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 3792*795d594fSAndroid Build Coastguard Worker 3793*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToUnsignedByteToByte(byte) instruction_simplifier (after) 3794*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$testUnsignedByteToUnsignedByteToByte(byte arg)3795*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedByteToUnsignedByteToByte(byte arg) { 3796*795d594fSAndroid Build Coastguard Worker return (byte) (((arg & 0xFF) << 24) >>> 24); 3797*795d594fSAndroid Build Coastguard Worker } 3798*795d594fSAndroid Build Coastguard Worker 3799*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToShortToByte(byte) instruction_simplifier (before) 3800*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3801*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const255:i\d+>> IntConstant 255 3802*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3803*795d594fSAndroid Build Coastguard Worker /// CHECK: <<And:i\d+>> And [<<Param>>,<<Const255>>] 3804*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<And>>,<<Const16>>] 3805*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3806*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Shr>>] 3807*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3808*795d594fSAndroid Build Coastguard Worker 3809*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToShortToByte(byte) instruction_simplifier (after) 3810*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3811*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3812*795d594fSAndroid Build Coastguard Worker 3813*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToShortToByte(byte) instruction_simplifier (after) 3814*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3815*795d594fSAndroid Build Coastguard Worker 3816*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToShortToByte(byte) instruction_simplifier (after) 3817*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 3818*795d594fSAndroid Build Coastguard Worker 3819*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToShortToByte(byte) instruction_simplifier (after) 3820*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$testUnsignedByteToShortToByte(byte arg)3821*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedByteToShortToByte(byte arg) { 3822*795d594fSAndroid Build Coastguard Worker return (byte) (((arg & 0xFF) << 16) >> 16); 3823*795d594fSAndroid Build Coastguard Worker } 3824*795d594fSAndroid Build Coastguard Worker 3825*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToCharToByte(byte) instruction_simplifier (before) 3826*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3827*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const255:i\d+>> IntConstant 255 3828*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3829*795d594fSAndroid Build Coastguard Worker /// CHECK: <<And:i\d+>> And [<<Param>>,<<Const255>>] 3830*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<And>>,<<Const16>>] 3831*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3832*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<UShr>>] 3833*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3834*795d594fSAndroid Build Coastguard Worker 3835*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToCharToByte(byte) instruction_simplifier (after) 3836*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:b\d+>> ParameterValue 3837*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Param>>] 3838*795d594fSAndroid Build Coastguard Worker 3839*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToCharToByte(byte) instruction_simplifier (after) 3840*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3841*795d594fSAndroid Build Coastguard Worker 3842*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToCharToByte(byte) instruction_simplifier (after) 3843*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr 3844*795d594fSAndroid Build Coastguard Worker 3845*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testUnsignedByteToCharToByte(byte) instruction_simplifier (after) 3846*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: TypeConversion $noinline$testUnsignedByteToCharToByte(byte arg)3847*795d594fSAndroid Build Coastguard Worker private static int $noinline$testUnsignedByteToCharToByte(byte arg) { 3848*795d594fSAndroid Build Coastguard Worker return (byte) (((arg & 0xFF) << 16) >>> 16); 3849*795d594fSAndroid Build Coastguard Worker } 3850*795d594fSAndroid Build Coastguard Worker 3851*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToShortToByte(short) instruction_simplifier (before) 3852*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3853*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3854*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3855*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shr:i\d+>> Shr [<<Shl>>,<<Const16>>] 3856*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Shr>>] 3857*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3858*795d594fSAndroid Build Coastguard Worker 3859*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToShortToByte(short) instruction_simplifier (after) 3860*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:s\d+>> ParameterValue 3861*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3862*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3863*795d594fSAndroid Build Coastguard Worker 3864*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToShortToByte(short) instruction_simplifier (after) 3865*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3866*795d594fSAndroid Build Coastguard Worker 3867*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testShortToShortToByte(short) instruction_simplifier (after) 3868*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testShortToShortToByte(short arg)3869*795d594fSAndroid Build Coastguard Worker private static int $noinline$testShortToShortToByte(short arg) { 3870*795d594fSAndroid Build Coastguard Worker return (byte) ((arg << 16) >> 16); 3871*795d594fSAndroid Build Coastguard Worker } 3872*795d594fSAndroid Build Coastguard Worker 3873*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToCharToByte(char) instruction_simplifier (before) 3874*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3875*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Const16:i\d+>> IntConstant 16 3876*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Shl:i\d+>> Shl [<<Param>>,<<Const16>>] 3877*795d594fSAndroid Build Coastguard Worker /// CHECK: <<UShr:i\d+>> UShr [<<Shl>>,<<Const16>>] 3878*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<UShr>>] 3879*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3880*795d594fSAndroid Build Coastguard Worker 3881*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToCharToByte(char) instruction_simplifier (after) 3882*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Param:c\d+>> ParameterValue 3883*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Conv:b\d+>> TypeConversion [<<Param>>] 3884*795d594fSAndroid Build Coastguard Worker /// CHECK: <<Return:v\d+>> Return [<<Conv>>] 3885*795d594fSAndroid Build Coastguard Worker 3886*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToCharToByte(char) instruction_simplifier (after) 3887*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shl 3888*795d594fSAndroid Build Coastguard Worker 3889*795d594fSAndroid Build Coastguard Worker /// CHECK-START: int Main.$noinline$testCharToCharToByte(char) instruction_simplifier (after) 3890*795d594fSAndroid Build Coastguard Worker /// CHECK-NOT: Shr $noinline$testCharToCharToByte(char arg)3891*795d594fSAndroid Build Coastguard Worker private static int $noinline$testCharToCharToByte(char arg) { 3892*795d594fSAndroid Build Coastguard Worker return (byte) ((arg << 16) >>> 16); 3893*795d594fSAndroid Build Coastguard Worker } 3894*795d594fSAndroid Build Coastguard Worker main(String[] args)3895*795d594fSAndroid Build Coastguard Worker public static void main(String[] args) throws Exception { 3896*795d594fSAndroid Build Coastguard Worker Class smaliTests2 = Class.forName("SmaliTests2"); 3897*795d594fSAndroid Build Coastguard Worker Method $noinline$XorAllOnes = smaliTests2.getMethod("$noinline$XorAllOnes", int.class); 3898*795d594fSAndroid Build Coastguard Worker Method $noinline$NotNot1 = smaliTests2.getMethod("$noinline$NotNot1", long.class); 3899*795d594fSAndroid Build Coastguard Worker Method $noinline$NotNot2 = smaliTests2.getMethod("$noinline$NotNot2", int.class); 3900*795d594fSAndroid Build Coastguard Worker Method $noinline$NotNotBool = smaliTests2.getMethod("$noinline$NotNotBool", boolean.class); 3901*795d594fSAndroid Build Coastguard Worker Method $noinline$bug68142795Short = smaliTests2.getMethod("$noinline$bug68142795Short", short.class); 3902*795d594fSAndroid Build Coastguard Worker Method $noinline$bug68142795Boolean = smaliTests2.getMethod("$noinline$bug68142795Boolean", boolean.class); 3903*795d594fSAndroid Build Coastguard Worker 3904*795d594fSAndroid Build Coastguard Worker int arg = 123456; 3905*795d594fSAndroid Build Coastguard Worker float floatArg = 123456.125f; 3906*795d594fSAndroid Build Coastguard Worker 3907*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Add0(arg)); 3908*795d594fSAndroid Build Coastguard Worker assertIntEquals(5, $noinline$AddAddSubAddConst(1)); 3909*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$AndAllOnes(arg)); 3910*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Div1(arg)); 3911*795d594fSAndroid Build Coastguard Worker assertIntEquals(-arg, $noinline$DivN1(arg)); 3912*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Mul1(arg)); 3913*795d594fSAndroid Build Coastguard Worker assertIntEquals(-arg, $noinline$MulN1(arg)); 3914*795d594fSAndroid Build Coastguard Worker assertLongEquals((128 * arg), $noinline$MulPowerOfTwo128(arg)); 3915*795d594fSAndroid Build Coastguard Worker assertLongEquals(2640, $noinline$MulMulMulConst(2)); 3916*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$Or0(arg)); 3917*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$OrSame(arg)); 3918*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$Shl0(arg)); 3919*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Shr0(arg)); 3920*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Shr64(arg)); 3921*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$Sub0(arg)); 3922*795d594fSAndroid Build Coastguard Worker assertIntEquals(-arg, $noinline$SubAliasNeg(arg)); 3923*795d594fSAndroid Build Coastguard Worker assertIntEquals(9, $noinline$SubAddConst1(2)); 3924*795d594fSAndroid Build Coastguard Worker assertIntEquals(-2, $noinline$SubAddConst2(3)); 3925*795d594fSAndroid Build Coastguard Worker assertLongEquals(3, $noinline$SubSubConst(4)); 3926*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$UShr0(arg)); 3927*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$Xor0(arg)); 3928*795d594fSAndroid Build Coastguard Worker assertIntEquals(~arg, (int)$noinline$XorAllOnes.invoke(null, arg)); 3929*795d594fSAndroid Build Coastguard Worker assertIntEquals(-(arg + arg + 1), $noinline$AddNegs1(arg, arg + 1)); 3930*795d594fSAndroid Build Coastguard Worker assertIntEquals(-(arg + arg + 1), $noinline$AddNegs2(arg, arg + 1)); 3931*795d594fSAndroid Build Coastguard Worker assertLongEquals(-(2 * arg + 1), $noinline$AddNegs3(arg, arg + 1)); 3932*795d594fSAndroid Build Coastguard Worker assertLongEquals(1, $noinline$AddNeg1(arg, arg + 1)); 3933*795d594fSAndroid Build Coastguard Worker assertLongEquals(-1, $noinline$AddNeg2(arg, arg + 1)); 3934*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$NegNeg1(arg)); 3935*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$NegNeg2(arg)); 3936*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$NegNeg3(arg)); 3937*795d594fSAndroid Build Coastguard Worker assertIntEquals(1, $noinline$NegSub1(arg, arg + 1)); 3938*795d594fSAndroid Build Coastguard Worker assertIntEquals(1, $noinline$NegSub2(arg, arg + 1)); 3939*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, (long)$noinline$NotNot1.invoke(null, arg)); 3940*795d594fSAndroid Build Coastguard Worker assertLongEquals(arg, $noinline$runSmaliTest2Long("$noinline$NotNot1", arg)); 3941*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, (int)$noinline$NotNot2.invoke(null, arg)); 3942*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$runSmaliTestInt("2", "$noinline$NotNot2", arg)); 3943*795d594fSAndroid Build Coastguard Worker assertIntEquals(-(arg + arg + 1), $noinline$SubNeg1(arg, arg + 1)); 3944*795d594fSAndroid Build Coastguard Worker assertIntEquals(-(arg + arg + 1), $noinline$SubNeg2(arg, arg + 1)); 3945*795d594fSAndroid Build Coastguard Worker assertLongEquals(-(2 * arg + 1), $noinline$SubNeg3(arg, arg + 1)); 3946*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(true, $noinline$EqualBoolVsIntConst(true)); 3947*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(true, $noinline$EqualBoolVsIntConst(true)); 3948*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(false, $noinline$NotEqualBoolVsIntConst(false)); 3949*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(false, $noinline$NotEqualBoolVsIntConst(false)); 3950*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(true, (boolean)$noinline$NotNotBool.invoke(null, true)); 3951*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(true, $noinline$runSmaliTest2Boolean("$noinline$NotNotBool", true)); 3952*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(false, (boolean)$noinline$NotNotBool.invoke(null, false)); 3953*795d594fSAndroid Build Coastguard Worker assertBooleanEquals(false, $noinline$runSmaliTest2Boolean("$noinline$NotNotBool", false)); 3954*795d594fSAndroid Build Coastguard Worker assertFloatEquals(50.0f, $noinline$Div2(100.0f)); 3955*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(75.0, $noinline$Div2(150.0)); 3956*795d594fSAndroid Build Coastguard Worker assertFloatEquals(-400.0f, $noinline$DivMP25(100.0f)); 3957*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(-600.0, $noinline$DivMP25(150.0)); 3958*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xc, $noinline$UShr28And15(0xc1234567)); 3959*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xcL, $noinline$UShr60And15(0xc123456787654321L)); 3960*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x4, $noinline$UShr28And7(0xc1234567)); 3961*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x4L, $noinline$UShr60And7(0xc123456787654321L)); 3962*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xc1, $noinline$Shr24And255(0xc1234567)); 3963*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x60, $noinline$Shr25And127(0xc1234567)); 3964*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xc1L, $noinline$Shr56And255(0xc123456787654321L)); 3965*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x60L, $noinline$Shr57And127(0xc123456787654321L)); 3966*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x41, $noinline$Shr24And127(0xc1234567)); 3967*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x41L, $noinline$Shr56And127(0xc123456787654321L)); 3968*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$mulPow2Plus1(0)); 3969*795d594fSAndroid Build Coastguard Worker assertIntEquals(9, $noinline$mulPow2Plus1(1)); 3970*795d594fSAndroid Build Coastguard Worker assertIntEquals(18, $noinline$mulPow2Plus1(2)); 3971*795d594fSAndroid Build Coastguard Worker assertIntEquals(900, $noinline$mulPow2Plus1(100)); 3972*795d594fSAndroid Build Coastguard Worker assertIntEquals(111105, $noinline$mulPow2Plus1(12345)); 3973*795d594fSAndroid Build Coastguard Worker assertLongEquals(0, $noinline$mulPow2Minus1(0)); 3974*795d594fSAndroid Build Coastguard Worker assertLongEquals(31, $noinline$mulPow2Minus1(1)); 3975*795d594fSAndroid Build Coastguard Worker assertLongEquals(62, $noinline$mulPow2Minus1(2)); 3976*795d594fSAndroid Build Coastguard Worker assertLongEquals(3100, $noinline$mulPow2Minus1(100)); 3977*795d594fSAndroid Build Coastguard Worker assertLongEquals(382695, $noinline$mulPow2Minus1(12345)); 3978*795d594fSAndroid Build Coastguard Worker 3979*795d594fSAndroid Build Coastguard Worker booleanField = false; 3980*795d594fSAndroid Build Coastguard Worker assertIntEquals($noinline$booleanFieldNotEqualOne(), 54); 3981*795d594fSAndroid Build Coastguard Worker assertIntEquals($noinline$booleanFieldEqualZero(), 54); 3982*795d594fSAndroid Build Coastguard Worker booleanField = true; 3983*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$booleanFieldNotEqualOne()); 3984*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$booleanFieldEqualZero()); 3985*795d594fSAndroid Build Coastguard Worker assertIntEquals(54, $noinline$intConditionNotEqualOne(6)); 3986*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$intConditionNotEqualOne(43)); 3987*795d594fSAndroid Build Coastguard Worker assertIntEquals(54, $noinline$intConditionEqualZero(6)); 3988*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$intConditionEqualZero(43)); 3989*795d594fSAndroid Build Coastguard Worker assertIntEquals(54, $noinline$floatConditionNotEqualOne(6.0f)); 3990*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$floatConditionNotEqualOne(43.0f)); 3991*795d594fSAndroid Build Coastguard Worker assertIntEquals(54, $noinline$doubleConditionEqualZero(6.0)); 3992*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$doubleConditionEqualZero(43.0)); 3993*795d594fSAndroid Build Coastguard Worker 3994*795d594fSAndroid Build Coastguard Worker assertIntEquals(1234567, $noinline$intToDoubleToInt(1234567)); 3995*795d594fSAndroid Build Coastguard Worker assertIntEquals(Integer.MIN_VALUE, $noinline$intToDoubleToInt(Integer.MIN_VALUE)); 3996*795d594fSAndroid Build Coastguard Worker assertIntEquals(Integer.MAX_VALUE, $noinline$intToDoubleToInt(Integer.MAX_VALUE)); 3997*795d594fSAndroid Build Coastguard Worker assertStringEquals("d=7654321.0, i=7654321", $noinline$intToDoubleToIntPrint(7654321)); 3998*795d594fSAndroid Build Coastguard Worker assertIntEquals(12, $noinline$byteToDoubleToInt((byte) 12)); 3999*795d594fSAndroid Build Coastguard Worker assertIntEquals(Byte.MIN_VALUE, $noinline$byteToDoubleToInt(Byte.MIN_VALUE)); 4000*795d594fSAndroid Build Coastguard Worker assertIntEquals(Byte.MAX_VALUE, $noinline$byteToDoubleToInt(Byte.MAX_VALUE)); 4001*795d594fSAndroid Build Coastguard Worker assertIntEquals(11, $noinline$floatToDoubleToInt(11.3f)); 4002*795d594fSAndroid Build Coastguard Worker assertStringEquals("d=12.25, i=12", $noinline$floatToDoubleToIntPrint(12.25f)); 4003*795d594fSAndroid Build Coastguard Worker assertIntEquals(123, $noinline$byteToDoubleToShort((byte) 123)); 4004*795d594fSAndroid Build Coastguard Worker assertIntEquals(Byte.MIN_VALUE, $noinline$byteToDoubleToShort(Byte.MIN_VALUE)); 4005*795d594fSAndroid Build Coastguard Worker assertIntEquals(Byte.MAX_VALUE, $noinline$byteToDoubleToShort(Byte.MAX_VALUE)); 4006*795d594fSAndroid Build Coastguard Worker assertIntEquals(1234, $noinline$charToDoubleToShort((char) 1234)); 4007*795d594fSAndroid Build Coastguard Worker assertIntEquals(Character.MIN_VALUE, $noinline$charToDoubleToShort(Character.MIN_VALUE)); 4008*795d594fSAndroid Build Coastguard Worker assertIntEquals(/* sign-extended */ -1, $noinline$charToDoubleToShort(Character.MAX_VALUE)); 4009*795d594fSAndroid Build Coastguard Worker assertIntEquals(12345, $noinline$floatToIntToShort(12345.75f)); 4010*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MAX_VALUE, $noinline$floatToIntToShort((float)(Short.MIN_VALUE - 1))); 4011*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MIN_VALUE, $noinline$floatToIntToShort((float)(Short.MAX_VALUE + 1))); 4012*795d594fSAndroid Build Coastguard Worker assertIntEquals(-54321, $noinline$intToFloatToInt(-54321)); 4013*795d594fSAndroid Build Coastguard Worker assertDoubleEquals((double) 0x12345678, $noinline$longToIntToDouble(0x1234567812345678L)); 4014*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(0.0, $noinline$longToIntToDouble(Long.MIN_VALUE)); 4015*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(-1.0, $noinline$longToIntToDouble(Long.MAX_VALUE)); 4016*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x0000000012345678L, $noinline$longToIntToLong(0x1234567812345678L)); 4017*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xffffffff87654321L, $noinline$longToIntToLong(0x1234567887654321L)); 4018*795d594fSAndroid Build Coastguard Worker assertLongEquals(0L, $noinline$longToIntToLong(Long.MIN_VALUE)); 4019*795d594fSAndroid Build Coastguard Worker assertLongEquals(-1L, $noinline$longToIntToLong(Long.MAX_VALUE)); 4020*795d594fSAndroid Build Coastguard Worker assertIntEquals((short) -5678, $noinline$shortToCharToShort((short) -5678)); 4021*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MIN_VALUE, $noinline$shortToCharToShort(Short.MIN_VALUE)); 4022*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MAX_VALUE, $noinline$shortToCharToShort(Short.MAX_VALUE)); 4023*795d594fSAndroid Build Coastguard Worker assertIntEquals(5678, $noinline$shortToLongToInt((short) 5678)); 4024*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MIN_VALUE, $noinline$shortToLongToInt(Short.MIN_VALUE)); 4025*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MAX_VALUE, $noinline$shortToLongToInt(Short.MAX_VALUE)); 4026*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x34, $noinline$shortToCharToByte((short) 0x1234)); 4027*795d594fSAndroid Build Coastguard Worker assertIntEquals(-0x10, $noinline$shortToCharToByte((short) 0x12f0)); 4028*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$shortToCharToByte(Short.MIN_VALUE)); 4029*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$shortToCharToByte(Short.MAX_VALUE)); 4030*795d594fSAndroid Build Coastguard Worker assertStringEquals("c=1025, b=1", $noinline$shortToCharToBytePrint((short) 1025)); 4031*795d594fSAndroid Build Coastguard Worker assertStringEquals("c=1023, b=-1", $noinline$shortToCharToBytePrint((short) 1023)); 4032*795d594fSAndroid Build Coastguard Worker assertStringEquals("c=65535, b=-1", $noinline$shortToCharToBytePrint((short) -1)); 4033*795d594fSAndroid Build Coastguard Worker 4034*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x55411410L, $noinline$intAndSmallLongConstant(0x55555555)); 4035*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xffffffffaa028aa2L, $noinline$intAndSmallLongConstant(0xaaaaaaaa)); 4036*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x44101440L, $noinline$intAndLargeLongConstant(0x55555555)); 4037*795d594fSAndroid Build Coastguard Worker assertLongEquals(0x208a002aaL, $noinline$intAndLargeLongConstant(0xaaaaaaaa)); 4038*795d594fSAndroid Build Coastguard Worker assertLongEquals(7L, $noinline$intShr28And15L(0x76543210)); 4039*795d594fSAndroid Build Coastguard Worker 4040*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x21, $noinline$longAnd0xffToByte(0x1234432112344321L)); 4041*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$longAnd0xffToByte(Long.MIN_VALUE)); 4042*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$longAnd0xffToByte(Long.MAX_VALUE)); 4043*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x1234, $noinline$intAnd0x1ffffToChar(0x43211234)); 4044*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$intAnd0x1ffffToChar(Integer.MIN_VALUE)); 4045*795d594fSAndroid Build Coastguard Worker assertIntEquals(Character.MAX_VALUE, $noinline$intAnd0x1ffffToChar(Integer.MAX_VALUE)); 4046*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x4321, $noinline$intAnd0x17fffToShort(0x87654321)); 4047*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0888, $noinline$intAnd0x17fffToShort(0x88888888)); 4048*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$intAnd0x17fffToShort(Integer.MIN_VALUE)); 4049*795d594fSAndroid Build Coastguard Worker assertIntEquals(Short.MAX_VALUE, $noinline$intAnd0x17fffToShort(Integer.MAX_VALUE)); 4050*795d594fSAndroid Build Coastguard Worker 4051*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(0.0, $noinline$shortAnd0xffffToShortToDouble((short) 0)); 4052*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(1.0, $noinline$shortAnd0xffffToShortToDouble((short) 1)); 4053*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(-2.0, $noinline$shortAnd0xffffToShortToDouble((short) -2)); 4054*795d594fSAndroid Build Coastguard Worker assertDoubleEquals(12345.0, $noinline$shortAnd0xffffToShortToDouble((short) 12345)); 4055*795d594fSAndroid Build Coastguard Worker assertDoubleEquals((double)Short.MAX_VALUE, 4056*795d594fSAndroid Build Coastguard Worker $noinline$shortAnd0xffffToShortToDouble(Short.MAX_VALUE)); 4057*795d594fSAndroid Build Coastguard Worker assertDoubleEquals((double)Short.MIN_VALUE, 4058*795d594fSAndroid Build Coastguard Worker $noinline$shortAnd0xffffToShortToDouble(Short.MIN_VALUE)); 4059*795d594fSAndroid Build Coastguard Worker 4060*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$intReverseCondition(41)); 4061*795d594fSAndroid Build Coastguard Worker assertIntEquals(13, $noinline$intReverseConditionNaN(-5)); 4062*795d594fSAndroid Build Coastguard Worker 4063*795d594fSAndroid Build Coastguard Worker for (String condition : new String[] { "Equal", "NotEqual" }) { 4064*795d594fSAndroid Build Coastguard Worker for (String constant : new String[] { "True", "False" }) { 4065*795d594fSAndroid Build Coastguard Worker for (String side : new String[] { "Rhs", "Lhs" }) { 4066*795d594fSAndroid Build Coastguard Worker String name = condition + constant + side; 4067*795d594fSAndroid Build Coastguard Worker assertIntEquals(5, $noinline$runSmaliTest(name, true)); 4068*795d594fSAndroid Build Coastguard Worker assertIntEquals(3, $noinline$runSmaliTest(name, false)); 4069*795d594fSAndroid Build Coastguard Worker } 4070*795d594fSAndroid Build Coastguard Worker } 4071*795d594fSAndroid Build Coastguard Worker } 4072*795d594fSAndroid Build Coastguard Worker 4073*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$runSmaliTestInt("AddSubConst", 1)); 4074*795d594fSAndroid Build Coastguard Worker assertIntEquals(3, $noinline$runSmaliTestInt("SubAddConst", 2)); 4075*795d594fSAndroid Build Coastguard Worker assertIntEquals(-16, $noinline$runSmaliTestInt("SubSubConst1", 3)); 4076*795d594fSAndroid Build Coastguard Worker assertIntEquals(-5, $noinline$runSmaliTestInt("SubSubConst2", 4)); 4077*795d594fSAndroid Build Coastguard Worker assertIntEquals(26, $noinline$runSmaliTestInt("SubSubConst3", 5)); 4078*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x5e6f7808, $noinline$intUnnecessaryShiftMasking(0xabcdef01, 3)); 4079*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x5e6f7808, $noinline$intUnnecessaryShiftMasking(0xabcdef01, 3 + 32)); 4080*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xffffffffffffeaf3L, 4081*795d594fSAndroid Build Coastguard Worker $noinline$longUnnecessaryShiftMasking(0xabcdef0123456789L, 50)); 4082*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xffffffffffffeaf3L, 4083*795d594fSAndroid Build Coastguard Worker $noinline$longUnnecessaryShiftMasking(0xabcdef0123456789L, 50 + 64)); 4084*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x2af37b, $noinline$intUnnecessaryWiderShiftMasking(0xabcdef01, 10)); 4085*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x2af37b, $noinline$intUnnecessaryWiderShiftMasking(0xabcdef01, 10 + 128)); 4086*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xaf37bc048d159e24L, 4087*795d594fSAndroid Build Coastguard Worker $noinline$longSmallerShiftMasking(0xabcdef0123456789L, 2)); 4088*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xaf37bc048d159e24L, 4089*795d594fSAndroid Build Coastguard Worker $noinline$longSmallerShiftMasking(0xabcdef0123456789L, 2 + 256)); 4090*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffd5e7c, $noinline$otherUseOfUnnecessaryShiftMasking(0xabcdef01, 13)); 4091*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffd5e7c, $noinline$otherUseOfUnnecessaryShiftMasking(0xabcdef01, 13 + 512)); 4092*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x5f49eb48, $noinline$intUnnecessaryShiftModifications(0xabcdef01, 2)); 4093*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xbd4c29b0, $noinline$intUnnecessaryShiftModifications(0xabcdef01, 3)); 4094*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xc0fed1ca, $noinline$intNecessaryShiftModifications(0xabcdef01, 2)); 4095*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x03578ebc, $noinline$intNecessaryShiftModifications(0xabcdef01, 3)); 4096*795d594fSAndroid Build Coastguard Worker 4097*795d594fSAndroid Build Coastguard Worker assertIntEquals(654321, $noinline$intAddSubSimplifyArg1(arg, 654321)); 4098*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$intAddSubSimplifyArg2(arg, 654321)); 4099*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$intSubAddSimplifyLeft(arg, 654321)); 4100*795d594fSAndroid Build Coastguard Worker assertIntEquals(arg, $noinline$intSubAddSimplifyRight(arg, 654321)); 4101*795d594fSAndroid Build Coastguard Worker assertFloatEquals(654321.125f, $noinline$floatAddSubSimplifyArg1(floatArg, 654321.125f)); 4102*795d594fSAndroid Build Coastguard Worker assertFloatEquals(floatArg, $noinline$floatAddSubSimplifyArg2(floatArg, 654321.125f)); 4103*795d594fSAndroid Build Coastguard Worker assertFloatEquals(floatArg, $noinline$floatSubAddSimplifyLeft(floatArg, 654321.125f)); 4104*795d594fSAndroid Build Coastguard Worker assertFloatEquals(floatArg, $noinline$floatSubAddSimplifyRight(floatArg, 654321.125f)); 4105*795d594fSAndroid Build Coastguard Worker 4106*795d594fSAndroid Build Coastguard Worker // Sub/Add and Sub/Sub simplifications 4107*795d594fSAndroid Build Coastguard Worker final int[] int_inputs = {0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE, 42, -9000}; 4108*795d594fSAndroid Build Coastguard Worker for (int x : int_inputs) { 4109*795d594fSAndroid Build Coastguard Worker for (int y : int_inputs) { 4110*795d594fSAndroid Build Coastguard Worker // y - (x + y) = -x 4111*795d594fSAndroid Build Coastguard Worker assertIntEquals(-x, $noinline$testSubAddInt(x, y)); 4112*795d594fSAndroid Build Coastguard Worker // x - (x + y) = -y. 4113*795d594fSAndroid Build Coastguard Worker assertIntEquals(-y, $noinline$testSubAddOtherVersionInt(x, y)); 4114*795d594fSAndroid Build Coastguard Worker // (x - y) - x = -y. 4115*795d594fSAndroid Build Coastguard Worker assertIntEquals(-y, $noinline$testSubSubInt(x, y)); 4116*795d594fSAndroid Build Coastguard Worker // x - (x - y) = y. 4117*795d594fSAndroid Build Coastguard Worker assertIntEquals(y, $noinline$testSubSubOtherVersionInt(x, y)); 4118*795d594fSAndroid Build Coastguard Worker } 4119*795d594fSAndroid Build Coastguard Worker } 4120*795d594fSAndroid Build Coastguard Worker 4121*795d594fSAndroid Build Coastguard Worker final long[] long_inputs = {0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE, 0x100000000L, 4122*795d594fSAndroid Build Coastguard Worker 0x100000001L, -9000L, 0x0123456789ABCDEFL}; 4123*795d594fSAndroid Build Coastguard Worker for (long x : long_inputs) { 4124*795d594fSAndroid Build Coastguard Worker for (long y : long_inputs) { 4125*795d594fSAndroid Build Coastguard Worker // y - (x + y) = -x 4126*795d594fSAndroid Build Coastguard Worker assertLongEquals(-x, $noinline$testSubAddLong(x, y)); 4127*795d594fSAndroid Build Coastguard Worker // x - (x + y) = -y. 4128*795d594fSAndroid Build Coastguard Worker assertLongEquals(-y, $noinline$testSubAddOtherVersionLong(x, y)); 4129*795d594fSAndroid Build Coastguard Worker // (x - y) - x = -y. 4130*795d594fSAndroid Build Coastguard Worker assertLongEquals(-y, $noinline$testSubSubLong(x, y)); 4131*795d594fSAndroid Build Coastguard Worker // x - (x - y) = y. 4132*795d594fSAndroid Build Coastguard Worker assertLongEquals(y, $noinline$testSubSubOtherVersionLong(x, y)); 4133*795d594fSAndroid Build Coastguard Worker } 4134*795d594fSAndroid Build Coastguard Worker } 4135*795d594fSAndroid Build Coastguard Worker 4136*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 4137*795d594fSAndroid Build Coastguard Worker m.instanceByteField = -1; 4138*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xff, $noinline$getUint8FromInstanceByteField(m)); 4139*795d594fSAndroid Build Coastguard Worker staticByteField = -2; 4140*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfe, $noinline$getUint8FromStaticByteField()); 4141*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfd, $noinline$getUint8FromByteArray(new byte[] { -3 })); 4142*795d594fSAndroid Build Coastguard Worker m.instanceShortField = -4; 4143*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffc, $noinline$getUint16FromInstanceShortField(m)); 4144*795d594fSAndroid Build Coastguard Worker staticShortField = -5; 4145*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffb, $noinline$getUint16FromStaticShortField()); 4146*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffa, $noinline$getUint16FromShortArray(new short[] { -6 })); 4147*795d594fSAndroid Build Coastguard Worker m.instanceCharField = 0xfff9; 4148*795d594fSAndroid Build Coastguard Worker assertIntEquals(-7, $noinline$getInt16FromInstanceCharField(m)); 4149*795d594fSAndroid Build Coastguard Worker staticCharField = 0xfff8; 4150*795d594fSAndroid Build Coastguard Worker assertIntEquals(-8, $noinline$getInt16FromStaticCharField()); 4151*795d594fSAndroid Build Coastguard Worker assertIntEquals(-9, $noinline$getInt16FromCharArray(new char[] { 0xfff7 })); 4152*795d594fSAndroid Build Coastguard Worker 4153*795d594fSAndroid Build Coastguard Worker staticCharField = 0xfff6; 4154*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xf6, $noinline$getStaticCharFieldAnd0xff()); 4155*795d594fSAndroid Build Coastguard Worker 4156*795d594fSAndroid Build Coastguard Worker staticByteField = -11; 4157*795d594fSAndroid Build Coastguard Worker assertIntEquals(-11, $noinline$byteToUint8AndBack()); 4158*795d594fSAndroid Build Coastguard Worker 4159*795d594fSAndroid Build Coastguard Worker m.instanceByteField = -12; 4160*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xfffff4f4, $noinline$getUint8FromInstanceByteFieldWithAnotherUse(m)); 4161*795d594fSAndroid Build Coastguard Worker 4162*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x21, $noinline$intAnd0xffToChar(0x87654321)); 4163*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x121, $noinline$intAnd0x1ffToChar(0x87654321)); 4164*795d594fSAndroid Build Coastguard Worker 4165*795d594fSAndroid Build Coastguard Worker m.instanceCharField = 'x'; 4166*795d594fSAndroid Build Coastguard Worker assertIntEquals('x', $noinline$getInstanceCharFieldAnd0x1ffff(m)); 4167*795d594fSAndroid Build Coastguard Worker 4168*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7f, $noinline$bug68142795Byte((byte) 0x7f)); 4169*795d594fSAndroid Build Coastguard Worker assertIntEquals((byte) 0x80, $noinline$bug68142795Byte((byte) 0x80)); 4170*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7fff, (int)$noinline$bug68142795Short.invoke(null, (short) 0x7fff)); 4171*795d594fSAndroid Build Coastguard Worker assertIntEquals((short) 0x8000, (int)$noinline$bug68142795Short.invoke(null, (short) 0x8000)); 4172*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, (int)$noinline$bug68142795Boolean.invoke(null, false)); 4173*795d594fSAndroid Build Coastguard Worker assertIntEquals(1, (int)$noinline$bug68142795Boolean.invoke(null, true)); 4174*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7f, $noinline$bug68142795Elaborate((byte) 0x7f)); 4175*795d594fSAndroid Build Coastguard Worker assertIntEquals((byte) 0x80, $noinline$bug68142795Elaborate((byte) 0x80)); 4176*795d594fSAndroid Build Coastguard Worker 4177*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$emptyStringIndexOf('a')); 4178*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$emptyStringIndexOf('Z')); 4179*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$emptyStringIndexOfAfter('a', 0)); 4180*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$emptyStringIndexOfAfter('Z', -1)); 4181*795d594fSAndroid Build Coastguard Worker 4182*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$singleCharStringIndexOf('a')); 4183*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$singleCharStringIndexOf('x')); 4184*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$singleCharStringIndexOf('Z')); 4185*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$singleCharStringIndexOfAfter('a', 0)); 4186*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$singleCharStringIndexOfAfter('x', -1)); 4187*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$singleCharStringIndexOfAfter('x', 1)); 4188*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$singleCharStringIndexOfAfter('Z', -1)); 4189*795d594fSAndroid Build Coastguard Worker 4190*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x65,$noinline$redundantAndNotRedundant(0x7fff6f45)); 4191*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x5e,$noinline$redundantAndOtherUse(0x7fff6f45)); 4192*795d594fSAndroid Build Coastguard Worker 4193*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x79, $noinline$redundantAndShortToByteShift2((short) 0x6de7)); 4194*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x79, $noinline$redundantAndShortToByteShift2((short) 0xfde7)); 4195*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7a, $noinline$redundantAndShortToByteShift5((short) 0x6f45)); 4196*795d594fSAndroid Build Coastguard Worker assertIntEquals(-6, $noinline$redundantAndShortToByteShift5((short) 0xff45)); 4197*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndShortToByteShift8((short) 0x6f45)); 4198*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndShortToByteShift8((short) 0xff45)); 4199*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x37, $noinline$redundantAndShortToByteShift9NotRedundant((short) 0x6f45)); 4200*795d594fSAndroid Build Coastguard Worker assertIntEquals(127, $noinline$redundantAndShortToByteShift9NotRedundant((short) 0xff45)); 4201*795d594fSAndroid Build Coastguard Worker assertIntEquals(127, $noinline$redundantAndShortToByteShift10NotRedundant((short) 0xffff)); 4202*795d594fSAndroid Build Coastguard Worker assertIntEquals(6, $noinline$redundantAndShortToByteShift12((short) 0x6f45)); 4203*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndShortToByteShift12((short) 0xff45)); 4204*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$redundantAndShortToByteShift15((short) 0x6f45)); 4205*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndShortToByteShift15((short) 0xff45)); 4206*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$redundantAndShortToByteShift16((short) 0x6f45)); 4207*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndShortToByteShift16((short) 0xff45)); 4208*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$redundantAndShortToByteShortAndConstant((short) 0x6f45)); 4209*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndShortToByteShortAndConstant((short) 0xff45)); 4210*795d594fSAndroid Build Coastguard Worker 4211*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x79, $noinline$redundantAndIntToByteShift2(0x7fff6de7)); 4212*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x79, $noinline$redundantAndIntToByteShift2(0xfffffde7)); 4213*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7a, $noinline$redundantAndIntToByteShift5(0x7fff6f45)); 4214*795d594fSAndroid Build Coastguard Worker assertIntEquals(-6, $noinline$redundantAndIntToByteShift5(0xffffff45)); 4215*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndIntToByteShift8(0x7fff6f45)); 4216*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShift8(0xffffff45)); 4217*795d594fSAndroid Build Coastguard Worker assertIntEquals(-73, $noinline$redundantAndIntToByteShift9(0x7fff6f45)); 4218*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShift9(0xffffff45)); 4219*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndIntToByteShift16(0x7f6fffff)); 4220*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndIntToByteShift16(0xff6fff45)); 4221*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndIntToByteShift20(0x76ffffff)); 4222*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x6f, $noinline$redundantAndIntToByteShift20(0xf6ffff45)); 4223*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x7f, $noinline$redundantAndIntToByteShift24(0x7fffffff)); 4224*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShift24(0xffffff45)); 4225*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x3f, $noinline$redundantAndIntToByteShift25(0x7fffffff)); 4226*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShift25(0xffffff45)); 4227*795d594fSAndroid Build Coastguard Worker assertIntEquals(0, $noinline$redundantAndIntToByteShift31(0x7fffffff)); 4228*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShift31(0xffffff45)); 4229*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShortAndConstant(0x7fffff45)); 4230*795d594fSAndroid Build Coastguard Worker assertIntEquals(-1, $noinline$redundantAndIntToByteShortAndConstant(0xffffff45)); 4231*795d594fSAndroid Build Coastguard Worker assertIntEquals(111, $noinline$redundantAndRegressionNotConstant(-1, 0x6f45)); 4232*795d594fSAndroid Build Coastguard Worker 4233*795d594fSAndroid Build Coastguard Worker assertIntEquals(50, $noinline$deadAddAfterUnrollingAndSimplification(new int[] { 0 })); 4234*795d594fSAndroid Build Coastguard Worker 4235*795d594fSAndroid Build Coastguard Worker for (int x : int_inputs) { 4236*795d594fSAndroid Build Coastguard Worker for (int y : int_inputs) { 4237*795d594fSAndroid Build Coastguard Worker assertIntEquals(x, $noinline$returnSecondIfEqualElseFirstInt(x, y)); 4238*795d594fSAndroid Build Coastguard Worker assertIntEquals(y, $noinline$returnSecondIfNotEqualElseFirstInt(x, y)); 4239*795d594fSAndroid Build Coastguard Worker } 4240*795d594fSAndroid Build Coastguard Worker } 4241*795d594fSAndroid Build Coastguard Worker 4242*795d594fSAndroid Build Coastguard Worker for (long x : long_inputs) { 4243*795d594fSAndroid Build Coastguard Worker for (long y : long_inputs) { 4244*795d594fSAndroid Build Coastguard Worker assertLongEquals(x, $noinline$returnSecondIfEqualElseFirstLong(x, y)); 4245*795d594fSAndroid Build Coastguard Worker assertLongEquals(y, $noinline$returnSecondIfNotEqualElseFirstLong(x, y)); 4246*795d594fSAndroid Build Coastguard Worker } 4247*795d594fSAndroid Build Coastguard Worker } 4248*795d594fSAndroid Build Coastguard Worker 4249*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xaa, $noinline$testByteToIntAsUnsigned((byte) 0xaa)); 4250*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xaabb, $noinline$testShortToIntAsUnsigned((short) 0xaabb)); 4251*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xaabb, $noinline$testCharToIntAsUnsigned((char) 0xaabb)); 4252*795d594fSAndroid Build Coastguard Worker 4253*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffaa, $noinline$testByteToIntAsSigned((byte) 0xaa)); 4254*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testByteToIntAsSigned((byte) 0x0a)); 4255*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffaabb, $noinline$testShortToIntAsSigned((short) 0xaabb)); 4256*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0abb, $noinline$testShortToIntAsSigned((short) 0x0abb)); 4257*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffaabb, $noinline$testCharToIntAsSigned((char) 0xaabb)); 4258*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0abb, $noinline$testCharToIntAsSigned((char) 0x0abb)); 4259*795d594fSAndroid Build Coastguard Worker 4260*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xbb, $noinline$testShortToByteToIntAsUnsigned((short) 0xaabb)); 4261*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xbb, $noinline$testCharToByteToIntAsUnsigned((char) 0x0abb)); 4262*795d594fSAndroid Build Coastguard Worker 4263*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testShortToByteToIntAsSigned((short) 0xaabb)); 4264*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testShortToByteToIntAsSigned((short) 0xaa0b)); 4265*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testCharToByteToIntAsSigned((char) 0x0abb)); 4266*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testCharToByteToIntAsSigned((char) 0x0a0b)); 4267*795d594fSAndroid Build Coastguard Worker 4268*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xdd, $noinline$testIntToUnsignedByteToInt(0xaabbccdd)); 4269*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xccdd, $noinline$testIntToUnsignedShortToInt(0xaabbccdd)); 4270*795d594fSAndroid Build Coastguard Worker 4271*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffdd, $noinline$testIntToSignedByteToInt(0xaabbccdd)); 4272*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testIntToSignedByteToInt(0x0a)); 4273*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffccdd, $noinline$testIntToSignedShortToInt(0xaabbccdd)); 4274*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0abb, $noinline$testIntToSignedShortToInt(0x0abb)); 4275*795d594fSAndroid Build Coastguard Worker 4276*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xbb, $noinline$testCharToUnsignedByteToInt((char) 0xaabb)); 4277*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xbb, $noinline$testShortToUnsignedByteToInt((short) 0xaabb)); 4278*795d594fSAndroid Build Coastguard Worker 4279*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testCharToSignedByteToInt((char) 0xaabb)); 4280*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testShortToSignedByteToInt((short) 0xaabb)); 4281*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testCharToSignedByteToInt((char) 0xaa0b)); 4282*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testShortToSignedByteToInt((short) 0xaa0b)); 4283*795d594fSAndroid Build Coastguard Worker 4284*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xccdd, 4285*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionWithHugeShiftAmount(0xaabbccdd)); 4286*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xccdd, 4287*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionWithHugeMismatchedShiftAmount(0xaabbccdd)); 4288*795d594fSAndroid Build Coastguard Worker 4289*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xdd, $noinline$testUnsignedPromotionToLong(0x11223344aabbccddL)); 4290*795d594fSAndroid Build Coastguard Worker assertLongEquals(0xffffffffffffffddL, 4291*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionToLong(0x11223344aabbccddL)); 4292*795d594fSAndroid Build Coastguard Worker 4293*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xccdd, 4294*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionWithNonConstantShiftAmount(0xaabbccdd, 16)); 4295*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffdd, 4296*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionWithNonConstantShiftAmount(0xaabbccdd, 24)); 4297*795d594fSAndroid Build Coastguard Worker 4298*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xdd0000dd, $noinline$testUnsignedPromotionWithShlUse(0xaabbccdd)); 4299*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xdcffffdd, $noinline$testSignedPromotionWithShlUse(0xaabbccdd)); 4300*795d594fSAndroid Build Coastguard Worker 4301*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x5d, 4302*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionPatternWithIncorrectShiftAmountConstant(0xaabbccdd)); 4303*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffdd, 4304*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionPatternWithIncorrectShiftAmountConstant(0xaabbccdd)); 4305*795d594fSAndroid Build Coastguard Worker 4306*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xdd00, 4307*795d594fSAndroid Build Coastguard Worker $noinline$testUnsignedPromotionPatternWithDifferentShiftAmountConstants(0xaabbccdd)); 4308*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffee, 4309*795d594fSAndroid Build Coastguard Worker $noinline$testSignedPromotionPatternWithDifferentShiftAmountConstants(0xaabbccdd)); 4310*795d594fSAndroid Build Coastguard Worker 4311*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffaa, $noinline$testByteToByteToChar((byte) 0xaa)); 4312*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testByteToByteToChar((byte) 0x0a)); 4313*795d594fSAndroid Build Coastguard Worker 4314*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testByteToShortToByte((byte) 0x0a)); 4315*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffaa, $noinline$testByteToShortToByte((byte) 0xaa)); 4316*795d594fSAndroid Build Coastguard Worker 4317*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testUnsignedByteToUnsignedByteToByte((byte) 0x0a)); 4318*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffaa, $noinline$testUnsignedByteToUnsignedByteToByte((byte) 0xaa)); 4319*795d594fSAndroid Build Coastguard Worker 4320*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testUnsignedByteToShortToByte((byte) 0x0a)); 4321*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffaa, $noinline$testUnsignedByteToShortToByte((byte) 0xaa)); 4322*795d594fSAndroid Build Coastguard Worker 4323*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0a, $noinline$testUnsignedByteToCharToByte((byte) 0x0a)); 4324*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffaa, $noinline$testUnsignedByteToCharToByte((byte) 0xaa)); 4325*795d594fSAndroid Build Coastguard Worker 4326*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testShortToShortToByte((short) 0xaa0b)); 4327*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testShortToShortToByte((short) 0xaabb)); 4328*795d594fSAndroid Build Coastguard Worker 4329*795d594fSAndroid Build Coastguard Worker assertIntEquals(0x0b, $noinline$testCharToCharToByte((char) 0xaa0b)); 4330*795d594fSAndroid Build Coastguard Worker assertIntEquals(0xffffffbb, $noinline$testCharToCharToByte((char) 0xaabb)); 4331*795d594fSAndroid Build Coastguard Worker } 4332*795d594fSAndroid Build Coastguard Worker $inline$true()4333*795d594fSAndroid Build Coastguard Worker private static boolean $inline$true() { return true; } $inline$false()4334*795d594fSAndroid Build Coastguard Worker private static boolean $inline$false() { return false; } 4335*795d594fSAndroid Build Coastguard Worker 4336*795d594fSAndroid Build Coastguard Worker public static boolean booleanField; 4337*795d594fSAndroid Build Coastguard Worker 4338*795d594fSAndroid Build Coastguard Worker public static byte staticByteField; 4339*795d594fSAndroid Build Coastguard Worker public static char staticCharField; 4340*795d594fSAndroid Build Coastguard Worker public static short staticShortField; 4341*795d594fSAndroid Build Coastguard Worker 4342*795d594fSAndroid Build Coastguard Worker public byte instanceByteField; 4343*795d594fSAndroid Build Coastguard Worker public char instanceCharField; 4344*795d594fSAndroid Build Coastguard Worker public short instanceShortField; 4345*795d594fSAndroid Build Coastguard Worker } 4346