# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # 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. # This test check, that "CSE(VN)" - change users for "LenArray" and after "cleanup" delete this. # Part of optimization: LSE -> GVN -> Peepholes -> BranchElimination -> Cleanup -> ChecksElimination #! CHECKER Check that CSE is applied for inst in JIT #! RUN force_jit: true, options: "", entry: "_GLOBAL::main" #! EVENT /Compilation,_GLOBAL::main,.*COMPILED/ #! METHOD "_GLOBAL::main" #! PASS_AFTER "LSE" #! INST "LenArray" #! INST_NEXT "LenArray" #! PASS_AFTER "ChecksElimination" #! INST_NOT "LenArray" #! CHECKER Check that CSE is applied for inst in AOT #! SKIP_IF @architecture == "arm32" #! RUN_PAOC options: "" #! METHOD "_GLOBAL::main" #! PASS_AFTER "LSE" #! INST "LenArray" #! INST_NEXT "LenArray" #! PASS_AFTER "ChecksElimination" #! INST_NOT "LenArray" #! RUN options: "", entry: "_GLOBAL::main" #! EVENT "AotEntrypointFound,_GLOBAL::main" .record Asm{ i32[] asm1 } .function void Asm.Construct(Asm a0) { movi v0, 2 newarr v1, v0, i32[] lda.obj v1 stobj.obj a0, Asm.asm1 return.void } .function u1 main() { initobj.short Asm.Construct sta.obj v0 ldobj.obj v0, Asm.asm1 sta.obj v1 ldai 0 movi v2, 0 starr v1, v2 ldobj.obj v0, Asm.asm1 sta.obj v1 ldai 1 movi v2, 1 starr v1, v2 ldai 0 return }