| # Copyright (C) 2015 The Android Open Source Project |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| .class public LTestCmp; |
| |
| .super Ljava/lang/Object; |
| |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongConstants() constant_folding (before) |
| ## CHECK-DAG: <<Const13:j\d+>> LongConstant 13 |
| ## CHECK-DAG: <<Const7:j\d+>> LongConstant 7 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const13>>,<<Const7>>] |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongConstants() constant_folding (after) |
| ## CHECK-DAG: LongConstant 13 |
| ## CHECK-DAG: LongConstant 7 |
| ## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| ## CHECK-DAG: Return [<<Const1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongConstants() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLongConstants()I |
| .registers 5 |
| const-wide v1, 13 |
| const-wide v3, 7 |
| cmp-long v0, v1, v3 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstants() constant_folding (before) |
| ## CHECK-DAG: <<Const11:f\d+>> FloatConstant 11 |
| ## CHECK-DAG: <<Const22:f\d+>> FloatConstant 22 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const11>>,<<Const22>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstants() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 11 |
| ## CHECK-DAG: FloatConstant 22 |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstants() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtFloatConstants()I |
| .registers 3 |
| const v1, 11.f |
| const v2, 22.f |
| cmpg-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstants() constant_folding (before) |
| ## CHECK-DAG: <<Const33:f\d+>> FloatConstant 33 |
| ## CHECK-DAG: <<Const44:f\d+>> FloatConstant 44 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const33>>,<<Const44>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstants() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 33 |
| ## CHECK-DAG: FloatConstant 44 |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstants() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtFloatConstants()I |
| .registers 3 |
| const v1, 33.f |
| const v2, 44.f |
| cmpl-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstants() constant_folding (before) |
| ## CHECK-DAG: <<Const55:d\d+>> DoubleConstant 55 |
| ## CHECK-DAG: <<Const66:d\d+>> DoubleConstant 66 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const55>>,<<Const66>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstants() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 55 |
| ## CHECK-DAG: DoubleConstant 66 |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstants() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtDoubleConstants()I |
| .registers 5 |
| const-wide v1, 55. |
| const-wide v3, 66. |
| cmpg-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstants() constant_folding (before) |
| ## CHECK-DAG: <<Const77:d\d+>> DoubleConstant 77 |
| ## CHECK-DAG: <<Const88:d\d+>> DoubleConstant 88 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const77>>,<<Const88>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstants() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 77 |
| ## CHECK-DAG: DoubleConstant 88 |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstants() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtDoubleConstants()I |
| .registers 5 |
| const-wide v1, 77. |
| const-wide v3, 88. |
| cmpl-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongSameConstant() constant_folding (before) |
| ## CHECK-DAG: <<Const100:j\d+>> LongConstant 100 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const100>>,<<Const100>>] |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongSameConstant() constant_folding (after) |
| ## CHECK-DAG: LongConstant 100 |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLongSameConstant() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLongSameConstant()I |
| .registers 5 |
| const-wide v1, 100 |
| const-wide v3, 100 |
| cmp-long v0, v1, v3 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatSameConstant() constant_folding (before) |
| ## CHECK-DAG: <<Const200:f\d+>> FloatConstant 200 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const200>>,<<Const200>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatSameConstant() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 200 |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatSameConstant() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtFloatSameConstant()I |
| .registers 3 |
| const v1, 200.f |
| const v2, 200.f |
| cmpg-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatSameConstant() constant_folding (before) |
| ## CHECK-DAG: <<Const300:f\d+>> FloatConstant 300 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const300>>,<<Const300>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatSameConstant() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 300 |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatSameConstant() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtFloatSameConstant()I |
| .registers 3 |
| const v1, 300.f |
| const v2, 300.f |
| cmpl-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleSameConstant() constant_folding (before) |
| ## CHECK-DAG: <<Const400:d\d+>> DoubleConstant 400 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const400>>,<<Const400>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleSameConstant() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 400 |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleSameConstant() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtDoubleSameConstant()I |
| .registers 5 |
| const-wide v1, 400. |
| const-wide v3, 400. |
| cmpg-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleSameConstant() constant_folding (before) |
| ## CHECK-DAG: <<Const500:d\d+>> DoubleConstant 500 |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const500>>,<<Const500>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleSameConstant() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 500 |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleSameConstant() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtDoubleSameConstant()I |
| .registers 5 |
| const-wide v1, 500. |
| const-wide v3, 500. |
| cmpl-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstantWithNaN() constant_folding (before) |
| ## CHECK-DAG: <<Const44:f\d+>> FloatConstant 44 |
| ## CHECK-DAG: <<ConstNan:f\d+>> FloatConstant nan |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const44>>,<<ConstNan>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstantWithNaN() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 44 |
| ## CHECK-DAG: FloatConstant nan |
| ## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| ## CHECK-DAG: Return [<<Const1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtFloatConstantWithNaN() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtFloatConstantWithNaN()I |
| .registers 3 |
| const v1, 44.f |
| const v2, NaNf |
| cmpg-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstantWithNaN() constant_folding (before) |
| ## CHECK-DAG: <<Const44:f\d+>> FloatConstant 44 |
| ## CHECK-DAG: <<ConstNan:f\d+>> FloatConstant nan |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const44>>,<<ConstNan>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstantWithNaN() constant_folding (after) |
| ## CHECK-DAG: FloatConstant 44 |
| ## CHECK-DAG: FloatConstant nan |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtFloatConstantWithNaN() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtFloatConstantWithNaN()I |
| .registers 3 |
| const v1, 44.f |
| const v2, NaNf |
| cmpl-float v0, v1, v2 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstantWithNaN() constant_folding (before) |
| ## CHECK-DAG: <<Const45:d\d+>> DoubleConstant 45 |
| ## CHECK-DAG: <<ConstNan:d\d+>> DoubleConstant nan |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const45>>,<<ConstNan>>] bias:gt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstantWithNaN() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 45 |
| ## CHECK-DAG: DoubleConstant nan |
| ## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| ## CHECK-DAG: Return [<<Const1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpGtDoubleConstantWithNaN() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpGtDoubleConstantWithNaN()I |
| .registers 5 |
| const-wide v1, 45. |
| const-wide v3, NaN |
| cmpg-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstantWithNaN() constant_folding (before) |
| ## CHECK-DAG: <<Const46:d\d+>> DoubleConstant 46 |
| ## CHECK-DAG: <<ConstNan:d\d+>> DoubleConstant nan |
| ## CHECK-DAG: <<Cmp:i\d+>> Compare [<<Const46>>,<<ConstNan>>] bias:lt |
| ## CHECK-DAG: Return [<<Cmp>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstantWithNaN() constant_folding (after) |
| ## CHECK-DAG: DoubleConstant 46 |
| ## CHECK-DAG: DoubleConstant nan |
| ## CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstM1>>] |
| |
| ## CHECK-START: int TestCmp.$opt$CmpLtDoubleConstantWithNaN() constant_folding (after) |
| ## CHECK-NOT: Compare |
| |
| .method public static $opt$CmpLtDoubleConstantWithNaN()I |
| .registers 5 |
| const-wide v1, 46. |
| const-wide v3, NaN |
| cmpl-double v0, v1, v3 |
| return v0 |
| .end method |
| |
| |
| ## CHECK-START: int TestCmp.IntAddition2() constant_folding (before) |
| ## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| ## CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| ## CHECK-DAG: <<Const5:i\d+>> IntConstant 5 |
| ## CHECK-DAG: <<Const6:i\d+>> IntConstant 6 |
| ## CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>] |
| ## CHECK-DAG: <<Add2:i\d+>> Add [<<Const5>>,<<Const6>>] |
| ## CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Add2>>] |
| ## CHECK-DAG: Return [<<Add3>>] |
| |
| ## CHECK-START: int TestCmp.IntAddition2() constant_folding (after) |
| ## CHECK-DAG: <<Const14:i\d+>> IntConstant 14 |
| ## CHECK-DAG: Return [<<Const14>>] |
| |
| ## CHECK-START: int TestCmp.IntAddition2() constant_folding (after) |
| ## CHECK-NOT: Add |
| .method public static IntAddition2()I |
| # A more direct translation from Java. |
| |
| # int a, b, c; |
| .registers 3 |
| |
| # a = 1; |
| const/4 v0, 1 |
| # b = 2; |
| const/4 v1, 2 |
| |
| # a += b; |
| add-int/2addr v0, v1 |
| |
| # b = 5; |
| const/4 v1, 5 |
| # c = 6; |
| const/4 v2, 6 |
| |
| # b += c; |
| add-int/2addr v1, v2 |
| # c = a + b; |
| add-int v2, v0, v1 |
| |
| # return c; |
| return v2 |
| .end method |
| |
| |
| ## CHECK-START: int TestCmp.IntAddition2AddAndMove() constant_folding (before) |
| ## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| ## CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| ## CHECK-DAG: <<Const5:i\d+>> IntConstant 5 |
| ## CHECK-DAG: <<Const6:i\d+>> IntConstant 6 |
| ## CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>] |
| ## CHECK-DAG: <<Add2:i\d+>> Add [<<Const5>>,<<Const6>>] |
| ## CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Add2>>] |
| ## CHECK-DAG: Return [<<Add3>>] |
| |
| ## CHECK-START: int TestCmp.IntAddition2AddAndMove() constant_folding (after) |
| ## CHECK-DAG: <<Const14:i\d+>> IntConstant 14 |
| ## CHECK-DAG: Return [<<Const14>>] |
| |
| ## CHECK-START: int TestCmp.IntAddition2AddAndMove() constant_folding (after) |
| ## CHECK-NOT: Add |
| |
| # D8 uses 3 registers for += when local variable info is presented. |
| .method public static IntAddition2AddAndMove()I |
| .registers 4 |
| |
| # a = 1; |
| const/4 v0, 1 |
| # b = 2; |
| const/4 v1, 2 |
| |
| # a += b; |
| add-int v2, v0, v1 |
| move v0, v2 |
| |
| # b = 5; |
| const/4 v2, 5 |
| move v1, v2 |
| |
| # c = 6; |
| const/4 v2, 6 |
| |
| # b += c; |
| add-int v3, v1, v2 |
| move v1, v3 |
| |
| # c = a + b; |
| add-int v3, v0, v1 |
| move v2, v3 |
| |
| # return c; |
| return v2 |
| .end method |
| |
| |
| ## CHECK-START: int TestCmp.JumpsAndConditionals(boolean) constant_folding (before) |
| ## CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| ## CHECK-DAG: <<Const5:i\d+>> IntConstant 5 |
| ## CHECK-DAG: <<Add:i\d+>> Add [<<Const5>>,<<Const2>>] |
| ## CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<Const2>>] |
| ## CHECK-DAG: <<Phi:i\d+>> Phi [<<Add>>,<<Sub>>] |
| ## CHECK-DAG: Return [<<Phi>>] |
| |
| ## CHECK-START: int TestCmp.JumpsAndConditionals(boolean) constant_folding (after) |
| ## CHECK-DAG: <<Const3:i\d+>> IntConstant 3 |
| ## CHECK-DAG: <<Const7:i\d+>> IntConstant 7 |
| ## CHECK-DAG: <<Phi:i\d+>> Phi [<<Const7>>,<<Const3>>] |
| ## CHECK-DAG: Return [<<Phi>>] |
| |
| ## CHECK-START: int TestCmp.JumpsAndConditionals(boolean) constant_folding (after) |
| ## CHECK-NOT: Add |
| ## CHECK-NOT: Sub |
| .method public static JumpsAndConditionals(Z)I |
| # int a, b, c; |
| # a = 5; |
| # b = 2; |
| # if (cond) |
| # c = a + b; |
| # else |
| # c = a - b; |
| # return c; |
| .registers 4 |
| |
| const/4 v0, 5 |
| const/4 v1, 2 |
| |
| if-eqz p0, :cond_7 |
| add-int v2, v0, v1 |
| |
| :goto_6 |
| return v2 |
| |
| :cond_7 |
| sub-int v2, v0, v1 |
| goto :goto_6 |
| .end method |
| |
| ## CHECK-START: int TestCmp.And0(int) constant_folding (before) |
| ## CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const0>>] |
| ## CHECK-DAG: Return [<<And>>] |
| |
| ## CHECK-START: int TestCmp.And0(int) constant_folding (after) |
| ## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| ## CHECK-DAG: Return [<<Const0>>] |
| |
| ## CHECK-START: int TestCmp.And0(int) constant_folding (after) |
| ## CHECK-NOT: And |
| .method public static And0(I)I |
| # return arg & 0; |
| .registers 2 |
| |
| and-int/lit8 v0, p0, 0x0 |
| |
| return v0 |
| .end method |
| |
| ## CHECK-START: int TestCmp.OrAllOnes(int) constant_folding (before) |
| ## CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| ## CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| ## CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<ConstF>>] |
| ## CHECK-DAG: Return [<<Or>>] |
| |
| ## CHECK-START: int TestCmp.OrAllOnes(int) constant_folding (after) |
| ## CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| ## CHECK-DAG: Return [<<ConstF>>] |
| |
| ## CHECK-START: int TestCmp.OrAllOnes(int) constant_folding (after) |
| ## CHECK-NOT: Or |
| .method public static OrAllOnes(I)I |
| # return arg | -1; |
| .registers 2 |
| |
| or-int/lit8 v0, p0, -0x1 |
| |
| return v0 |
| .end method |