1# Copyright (C) 2016 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15.class public LSmaliTests; 16.super Ljava/lang/Object; 17 18## CHECK-START: int SmaliTests.EqualTrueRhs(boolean) instruction_simplifier (before) 19## CHECK-DAG: <<Arg:z\d+>> ParameterValue 20## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 21## CHECK-DAG: <<Cond:z\d+>> Equal [<<Arg>>,<<Const1>>] 22## CHECK-DAG: If [<<Cond>>] 23 24## CHECK-START: int SmaliTests.EqualTrueRhs(boolean) instruction_simplifier (after) 25## CHECK-DAG: <<Arg:z\d+>> ParameterValue 26## CHECK-DAG: If [<<Arg>>] 27 28.method public static EqualTrueRhs(Z)I 29 .registers 3 30 31 const v0, 0x1 32 const v1, 0x5 33 if-eq p0, v0, :return 34 const v1, 0x3 35 :return 36 return v1 37 38.end method 39 40## CHECK-START: int SmaliTests.EqualTrueLhs(boolean) instruction_simplifier (before) 41## CHECK-DAG: <<Arg:z\d+>> ParameterValue 42## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 43## CHECK-DAG: <<Cond:z\d+>> Equal [<<Const1>>,<<Arg>>] 44## CHECK-DAG: If [<<Cond>>] 45 46## CHECK-START: int SmaliTests.EqualTrueLhs(boolean) instruction_simplifier (after) 47## CHECK-DAG: <<Arg:z\d+>> ParameterValue 48## CHECK-DAG: If [<<Arg>>] 49 50.method public static EqualTrueLhs(Z)I 51 .registers 3 52 53 const v0, 0x1 54 const v1, 0x5 55 if-eq v0, p0, :return 56 const v1, 0x3 57 :return 58 return v1 59 60.end method 61 62## CHECK-START: int SmaliTests.EqualFalseRhs(boolean) instruction_simplifier (before) 63## CHECK-DAG: <<Arg:z\d+>> ParameterValue 64## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 65## CHECK-DAG: <<Cond:z\d+>> Equal [<<Arg>>,<<Const0>>] 66## CHECK-DAG: If [<<Cond>>] 67 68## CHECK-START: int SmaliTests.EqualFalseRhs(boolean) instruction_simplifier (after) 69## CHECK-DAG: <<Arg:z\d+>> ParameterValue 70## CHECK-DAG: If [<<Arg>>] 71 72.method public static EqualFalseRhs(Z)I 73 .registers 3 74 75 const v0, 0x0 76 const v1, 0x3 77 if-eq p0, v0, :return 78 const v1, 0x5 79 :return 80 return v1 81 82.end method 83 84## CHECK-START: int SmaliTests.EqualFalseLhs(boolean) instruction_simplifier (before) 85## CHECK-DAG: <<Arg:z\d+>> ParameterValue 86## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 87## CHECK-DAG: <<Cond:z\d+>> Equal [<<Const0>>,<<Arg>>] 88## CHECK-DAG: If [<<Cond>>] 89 90## CHECK-START: int SmaliTests.EqualFalseLhs(boolean) instruction_simplifier (after) 91## CHECK-DAG: <<Arg:z\d+>> ParameterValue 92## CHECK-DAG: If [<<Arg>>] 93 94.method public static EqualFalseLhs(Z)I 95 .registers 3 96 97 const v0, 0x0 98 const v1, 0x3 99 if-eq v0, p0, :return 100 const v1, 0x5 101 :return 102 return v1 103 104.end method 105 106## CHECK-START: int SmaliTests.NotEqualTrueRhs(boolean) instruction_simplifier (before) 107## CHECK-DAG: <<Arg:z\d+>> ParameterValue 108## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 109## CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Arg>>,<<Const1>>] 110## CHECK-DAG: If [<<Cond>>] 111 112## CHECK-START: int SmaliTests.NotEqualTrueRhs(boolean) instruction_simplifier (after) 113## CHECK-DAG: <<Arg:z\d+>> ParameterValue 114## CHECK-DAG: If [<<Arg>>] 115 116.method public static NotEqualTrueRhs(Z)I 117 .registers 3 118 119 const v0, 0x1 120 const v1, 0x3 121 if-ne p0, v0, :return 122 const v1, 0x5 123 :return 124 return v1 125 126.end method 127 128## CHECK-START: int SmaliTests.NotEqualTrueLhs(boolean) instruction_simplifier (before) 129## CHECK-DAG: <<Arg:z\d+>> ParameterValue 130## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 131## CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Const1>>,<<Arg>>] 132## CHECK-DAG: If [<<Cond>>] 133 134## CHECK-START: int SmaliTests.NotEqualTrueLhs(boolean) instruction_simplifier (after) 135## CHECK-DAG: <<Arg:z\d+>> ParameterValue 136## CHECK-DAG: If [<<Arg>>] 137 138.method public static NotEqualTrueLhs(Z)I 139 .registers 3 140 141 const v0, 0x1 142 const v1, 0x3 143 if-ne v0, p0, :return 144 const v1, 0x5 145 :return 146 return v1 147 148.end method 149 150## CHECK-START: int SmaliTests.NotEqualFalseRhs(boolean) instruction_simplifier (before) 151## CHECK-DAG: <<Arg:z\d+>> ParameterValue 152## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 153## CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Arg>>,<<Const0>>] 154## CHECK-DAG: If [<<Cond>>] 155 156## CHECK-START: int SmaliTests.NotEqualFalseRhs(boolean) instruction_simplifier (after) 157## CHECK-DAG: <<Arg:z\d+>> ParameterValue 158## CHECK-DAG: If [<<Arg>>] 159 160.method public static NotEqualFalseRhs(Z)I 161 .registers 3 162 163 const v0, 0x0 164 const v1, 0x5 165 if-ne p0, v0, :return 166 const v1, 0x3 167 :return 168 return v1 169 170.end method 171 172## CHECK-START: int SmaliTests.NotEqualFalseLhs(boolean) instruction_simplifier (before) 173## CHECK-DAG: <<Arg:z\d+>> ParameterValue 174## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 175## CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Const0>>,<<Arg>>] 176## CHECK-DAG: If [<<Cond>>] 177 178## CHECK-START: int SmaliTests.NotEqualFalseLhs(boolean) instruction_simplifier (after) 179## CHECK-DAG: <<Arg:z\d+>> ParameterValue 180## CHECK-DAG: If [<<Arg>>] 181 182.method public static NotEqualFalseLhs(Z)I 183 .registers 3 184 185 const v0, 0x0 186 const v1, 0x5 187 if-ne v0, p0, :return 188 const v1, 0x3 189 :return 190 return v1 191 192.end method 193 194## CHECK-START: int SmaliTests.AddSubConst(int) instruction_simplifier (before) 195## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 196## CHECK-DAG: <<Const7:i\d+>> IntConstant 7 197## CHECK-DAG: <<Const8:i\d+>> IntConstant 8 198## CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const7>>] 199## CHECK-DAG: <<Sub:i\d+>> Sub [<<Add>>,<<Const8>>] 200## CHECK-DAG: Return [<<Sub>>] 201 202## CHECK-START: int SmaliTests.AddSubConst(int) instruction_simplifier (after) 203## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 204## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 205## CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<ConstM1>>] 206## CHECK-DAG: Return [<<Add>>] 207 208.method public static AddSubConst(I)I 209 .registers 3 210 211 .prologue 212 add-int/lit8 v0, p0, 7 213 214 const/16 v1, 8 215 216 sub-int v0, v0, v1 217 218 return v0 219.end method 220 221## CHECK-START: int SmaliTests.SubAddConst(int) instruction_simplifier (before) 222## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 223## CHECK-DAG: <<Const3:i\d+>> IntConstant 3 224## CHECK-DAG: <<Const4:i\d+>> IntConstant 4 225## CHECK-DAG: <<Sub:i\d+>> Sub [<<ArgValue>>,<<Const3>>] 226## CHECK-DAG: <<Add:i\d+>> Add [<<Sub>>,<<Const4>>] 227## CHECK-DAG: Return [<<Add>>] 228 229## CHECK-START: int SmaliTests.SubAddConst(int) instruction_simplifier (after) 230## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 231## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 232## CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const1>>] 233## CHECK-DAG: Return [<<Add>>] 234 235.method public static SubAddConst(I)I 236 .registers 2 237 238 .prologue 239 const/4 v0, 3 240 241 sub-int v0, p0, v0 242 243 add-int/lit8 v0, v0, 4 244 245 return v0 246.end method 247 248## CHECK-START: int SmaliTests.SubSubConst1(int) instruction_simplifier (before) 249## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 250## CHECK-DAG: <<Const9:i\d+>> IntConstant 9 251## CHECK-DAG: <<Const10:i\d+>> IntConstant 10 252## CHECK-DAG: <<Sub1:i\d+>> Sub [<<ArgValue>>,<<Const9>>] 253## CHECK-DAG: <<Sub2:i\d+>> Sub [<<Sub1>>,<<Const10>>] 254## CHECK-DAG: Return [<<Sub2>>] 255 256## CHECK-START: int SmaliTests.SubSubConst1(int) instruction_simplifier (after) 257## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 258## CHECK-DAG: <<ConstM19:i\d+>> IntConstant -19 259## CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<ConstM19>>] 260## CHECK-DAG: Return [<<Add>>] 261 262.method public static SubSubConst1(I)I 263 .registers 3 264 265 .prologue 266 const/16 v1, 9 267 268 sub-int v0, p0, v1 269 270 const/16 v1, 10 271 272 sub-int v0, v0, v1 273 274 return v0 275.end method 276 277## CHECK-START: int SmaliTests.SubSubConst2(int) instruction_simplifier (before) 278## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 279## CHECK-DAG: <<Const11:i\d+>> IntConstant 11 280## CHECK-DAG: <<Const12:i\d+>> IntConstant 12 281## CHECK-DAG: <<Sub1:i\d+>> Sub [<<Const11>>,<<ArgValue>>] 282## CHECK-DAG: <<Sub2:i\d+>> Sub [<<Sub1>>,<<Const12>>] 283## CHECK-DAG: Return [<<Sub2>>] 284 285## CHECK-START: int SmaliTests.SubSubConst2(int) instruction_simplifier (after) 286## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 287## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 288## CHECK-DAG: <<Sub:i\d+>> Sub [<<ConstM1>>,<<ArgValue>>] 289## CHECK-DAG: Return [<<Sub>>] 290 291.method public static SubSubConst2(I)I 292 .registers 3 293 294 .prologue 295 rsub-int/lit8 v0, p0, 11 296 297 const/16 v1, 12 298 299 sub-int v0, v0, v1 300 301 return v0 302.end method 303 304## CHECK-START: int SmaliTests.SubSubConst3(int) instruction_simplifier (before) 305## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 306## CHECK-DAG: <<Const15:i\d+>> IntConstant 15 307## CHECK-DAG: <<Const16:i\d+>> IntConstant 16 308## CHECK-DAG: <<Sub1:i\d+>> Sub [<<ArgValue>>,<<Const16>>] 309## CHECK-DAG: <<Sub2:i\d+>> Sub [<<Const15>>,<<Sub1>>] 310## CHECK-DAG: Return [<<Sub2>>] 311 312## CHECK-START: int SmaliTests.SubSubConst3(int) instruction_simplifier (after) 313## CHECK-DAG: <<ArgValue:i\d+>> ParameterValue 314## CHECK-DAG: <<Const31:i\d+>> IntConstant 31 315## CHECK-DAG: <<Sub:i\d+>> Sub [<<Const31>>,<<ArgValue>>] 316## CHECK-DAG: Return [<<Sub>>] 317 318.method public static SubSubConst3(I)I 319 .registers 2 320 321 .prologue 322 const/16 v0, 16 323 324 sub-int v0, p0, v0 325 326 rsub-int/lit8 v0, v0, 15 327 328 return v0 329.end method 330