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 LStoreLoad; 16 17.super Ljava/lang/Object; 18 19## CHECK-START: int StoreLoad.test(int) load_store_elimination (before) 20## CHECK-DAG: <<Arg:i\d+>> ParameterValue 21## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField 22## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField2 23## CHECK-DAG: <<Val:b\d+>> StaticFieldGet [{{l\d+}}] field_name:StoreLoad.byteField 24## CHECK-DAG: <<Val2:b\d+>> StaticFieldGet [{{l\d+}}] field_name:StoreLoad.byteField2 25## CHECK-DAG: <<Val3:i\d+>> Add [<<Val>>,<<Val2>>] 26## CHECK-DAG: Return [<<Val3>>] 27 28## CHECK-START: int StoreLoad.test(int) load_store_elimination (after) 29## CHECK-NOT: StaticFieldGet 30 31## CHECK-START: int StoreLoad.test(int) load_store_elimination (after) 32## CHECK-DAG: <<Arg:i\d+>> ParameterValue 33## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField 34## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField2 35## CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Arg>>] 36## CHECK-DAG: <<Val3:i\d+>> Add [<<Conv>>,<<Conv>>] 37## CHECK-DAG: Return [<<Val3>>] 38.method public static test(I)I 39 .registers 2 40 sput-byte v1, LStoreLoad;->byteField:B 41 sput-byte v1, LStoreLoad;->byteField2:B 42 sget-byte v0, LStoreLoad;->byteField:B 43 sget-byte v1, LStoreLoad;->byteField2:B 44 add-int/2addr v0, v1 45 return v0 46.end method 47 48## CHECK-START: int StoreLoad.test2(int) load_store_elimination (before) 49## CHECK-DAG: <<Arg:i\d+>> ParameterValue 50## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField 51## CHECK-DAG: Return [<<Arg>>] 52 53## CHECK-START: int StoreLoad.test2(int) load_store_elimination (after) 54## CHECK-NOT: TypeConversion 55.method public static test2(I)I 56 .registers 1 57 sput-byte v0, LStoreLoad;->byteField:B 58 return v0 59.end method 60 61## CHECK-START: int StoreLoad.test3(int) load_store_elimination (before) 62## CHECK-DAG: StaticFieldSet 63## CHECK-DAG: StaticFieldSet 64## CHECK-DAG: StaticFieldGet 65## CHECK-DAG: StaticFieldSet 66## CHECK-DAG: StaticFieldGet 67 68## CHECK-START: int StoreLoad.test3(int) load_store_elimination (after) 69## CHECK-DAG: StaticFieldSet 70## CHECK-DAG: StaticFieldSet 71## CHECK-DAG: TypeConversion 72## CHECK-DAG: StaticFieldSet 73## CHECK-DAG: StaticFieldGet 74 75## CHECK-START: int StoreLoad.test3(int) load_store_elimination (after) 76## CHECK: TypeConversion 77## CHECK-NOT: TypeConversion 78.method public static test3(I)I 79 .registers 3 80 const/4 v0, 0 81 sput p0, LStoreLoad;->intField:I 82 and-int/lit8 v1, p0, 1 83 if-eqz v1, :skip 84 85 sput-byte p0, LStoreLoad;->byteField:B 86 sget-byte v1, LStoreLoad;->byteField:B 87 sput v1, LStoreLoad;->intField:I 88 # Test that this TypeConversion is moved and used for the 89 # sget-byte above instead of creating a new one. 90 int-to-byte v0, p0 91 92 :skip 93 sget v1, LStoreLoad;->intField:I 94 add-int v0, v1, v0 95 return v0 96.end method 97 98.field public static intField:I 99.field public static byteField:B 100.field public static byteField2:B 101