Home | History | Annotate | Download | only in smali
      1 # Copyright (C) 2017 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 LSmali;
     16 .super Ljava/lang/Object;
     17 
     18 ##  CHECK-START: int Smali.testTrueBranch(int, int) dead_code_elimination$after_inlining (before)
     19 ##  CHECK-DAG:     <<ArgX:i\d+>>    ParameterValue
     20 ##  CHECK-DAG:     <<ArgY:i\d+>>    ParameterValue
     21 ##  CHECK-DAG:                      If
     22 ##  CHECK-DAG:     <<Add:i\d+>>     Add [<<ArgX>>,<<ArgY>>]
     23 ##  CHECK-DAG:     <<Sub:i\d+>>     Sub [<<ArgX>>,<<ArgY>>]
     24 ##  CHECK-DAG:     <<Phi:i\d+>>     Phi [<<Add>>,<<Sub>>]
     25 ##  CHECK-DAG:                      Return [<<Phi>>]
     26 
     27 ##  CHECK-START: int Smali.testTrueBranch(int, int) dead_code_elimination$after_inlining (after)
     28 ##  CHECK-DAG:     <<ArgX:i\d+>>    ParameterValue
     29 ##  CHECK-DAG:     <<ArgY:i\d+>>    ParameterValue
     30 ##  CHECK-DAG:     <<Add:i\d+>>     Add [<<ArgX>>,<<ArgY>>]
     31 ##  CHECK-DAG:                      Return [<<Add>>]
     32 
     33 ##  CHECK-START: int Smali.testTrueBranch(int, int) dead_code_elimination$after_inlining (after)
     34 ##  CHECK-NOT:                      If
     35 ##  CHECK-NOT:                      Sub
     36 ##  CHECK-NOT:                      Phi
     37 .method public static testTrueBranch(II)I
     38     # int z;
     39     # if (inlineTrue()) {
     40     #   z = x + y;
     41     # } else {
     42     #   z = x - y;
     43     #   // Prevent HSelect simplification by having a branch with multiple instructions.
     44     #   System.nanoTime();
     45     # }
     46     #return z;
     47 
     48     .registers 4
     49     .param p0, "x"    # I
     50     .param p1, "y"    # I
     51 
     52     invoke-static {}, LMain;->inlineTrue()Z
     53 
     54     move-result v1
     55 
     56     if-eqz v1, :cond_9
     57 
     58     add-int v0, p0, p1
     59 
     60     :goto_8
     61     return v0
     62 
     63     :cond_9
     64     sub-int v0, p0, p1
     65 
     66     invoke-static {}, Ljava/lang/System;->nanoTime()J
     67 
     68     goto :goto_8
     69 .end method
     70 
     71 ##  CHECK-START: int Smali.testFalseBranch(int, int) dead_code_elimination$after_inlining (before)
     72 ##  CHECK-DAG:     <<ArgX:i\d+>>    ParameterValue
     73 ##  CHECK-DAG:     <<ArgY:i\d+>>    ParameterValue
     74 ##  CHECK-DAG:                      If
     75 ##  CHECK-DAG:     <<Add:i\d+>>     Add [<<ArgX>>,<<ArgY>>]
     76 ##  CHECK-DAG:     <<Sub:i\d+>>     Sub [<<ArgX>>,<<ArgY>>]
     77 ##  CHECK-DAG:     <<Phi:i\d+>>     Phi [<<Add>>,<<Sub>>]
     78 ##  CHECK-DAG:                      Return [<<Phi>>]
     79 
     80 ##  CHECK-START: int Smali.testFalseBranch(int, int) dead_code_elimination$after_inlining (after)
     81 ##  CHECK-DAG:     <<ArgX:i\d+>>    ParameterValue
     82 ##  CHECK-DAG:     <<ArgY:i\d+>>    ParameterValue
     83 ##  CHECK-DAG:     <<Sub:i\d+>>     Sub [<<ArgX>>,<<ArgY>>]
     84 ##  CHECK-DAG:                      Return [<<Sub>>]
     85 
     86 ##  CHECK-START: int Smali.testFalseBranch(int, int) dead_code_elimination$after_inlining (after)
     87 ##  CHECK-NOT:                      If
     88 ##  CHECK-NOT:                      Add
     89 ##  CHECK-NOT:                      Phi
     90 .method public static testFalseBranch(II)I
     91     # int z;
     92     # if (inlineFalse()) {
     93     #   z = x + y;
     94     # } else {
     95     #   z = x - y;
     96     #   // Prevent HSelect simplification by having a branch with multiple instructions.
     97     #   System.nanoTime();
     98     # }
     99     # return z;
    100 
    101     .registers 4
    102     .param p0, "x"    # I
    103     .param p1, "y"    # I
    104 
    105     invoke-static {}, LMain;->inlineFalse()Z
    106 
    107     move-result v1
    108 
    109     if-eqz v1, :cond_9
    110 
    111     add-int v0, p0, p1
    112 
    113     :goto_8
    114     return v0
    115 
    116     :cond_9
    117     sub-int v0, p0, p1
    118 
    119     invoke-static {}, Ljava/lang/System;->nanoTime()J
    120 
    121     goto :goto_8
    122 .end method
    123