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#! CHECKER Check if LenArray is not less than zero is eliminated 15#! RUN force_jit: true, options: "--compiler-inlining=false", entry: "_GLOBAL::main1" 16#! METHOD "_GLOBAL::check_lt" 17#! PASS_AFTER "IrBuilder" 18#! INST "LenArray" 19#! INST_NEXT "IfImm" 20#! PASS_AFTER "Codegen" 21#! INST_NOT "LenArray" 22 23.function i32 check_lt(i32[] a0) { 24 movi v0, 0 25 lenarr a0 26 jltz success 27 ldai 0 28 return 29success: 30 ldai 1 31 return 32} 33 34.function u1 main1() { 35 movi v1, 3 36 newarr v0, v1, i32[] 37 call check_lt, v0 38 return 39} 40 41#! CHECKER Check if LenArray is greater than zero is not eliminated 42#! RUN force_jit: true, options: "--compiler-inlining=false", entry: "_GLOBAL::main2" 43#! METHOD "_GLOBAL::check_le" 44#! PASS_AFTER "Codegen" 45#! INST "LenArray" 46#! INST_NEXT "IfImm" 47 48.function i32 check_le(i32[] a0) { 49 movi v0, 0 50 lenarr a0 51 jlez success 52 ldai 0 53 return 54success: 55 ldai 1 56 return 57} 58 59.function u1 main2() { 60 movi v1, 3 61 newarr v0, v1, i32[] 62 call check_le, v0 63 jnez fail 64 movi v2, 0 65 newarr v3, v2, i32[] 66 call check_le, v3 67 jeqz fail 68 ldai 0 69 return 70fail: 71 ldai 1 72 return 73} 74