1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14# This test check, that "CSE(VN)" - change users for "LenArray" and after "cleanup" delete this. 15# Part of optimization: LSE -> GVN -> Peepholes -> BranchElimination -> Cleanup -> ChecksElimination 16 17#! CHECKER Check that CSE is applied for inst in JIT 18#! RUN force_jit: true, options: "", entry: "_GLOBAL::main" 19#! EVENT /Compilation,_GLOBAL::main,.*COMPILED/ 20#! METHOD "_GLOBAL::main" 21#! PASS_AFTER "LSE" 22#! INST "LenArray" 23#! INST_NEXT "LenArray" 24#! PASS_AFTER "ChecksElimination" 25#! INST_NOT "LenArray" 26 27#! CHECKER Check that CSE is applied for inst in AOT 28#! SKIP_IF @architecture == "arm32" 29#! RUN_PAOC options: "" 30#! METHOD "_GLOBAL::main" 31#! PASS_AFTER "LSE" 32#! INST "LenArray" 33#! INST_NEXT "LenArray" 34#! PASS_AFTER "ChecksElimination" 35#! INST_NOT "LenArray" 36#! RUN options: "", entry: "_GLOBAL::main" 37#! EVENT "AotEntrypointFound,_GLOBAL::main" 38 39.record Asm{ 40 i32[] asm1 41} 42 43.function void Asm.Construct(Asm a0) <ctor> { 44 movi v0, 2 45 newarr v1, v0, i32[] 46 lda.obj v1 47 stobj.obj a0, Asm.asm1 48 return.void 49} 50 51.function u1 main() { 52 initobj.short Asm.Construct 53 sta.obj v0 54 55 ldobj.obj v0, Asm.asm1 56 sta.obj v1 57 ldai 0 58 movi v2, 0 59 starr v1, v2 60 61 ldobj.obj v0, Asm.asm1 62 sta.obj v1 63 ldai 1 64 movi v2, 1 65 starr v1, v2 66 67 ldai 0 68 return 69} 70