# 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. #! CHECKER Check if LenArray is not less than zero is eliminated #! RUN force_jit: true, options: "--compiler-inlining=false", entry: "_GLOBAL::main1" #! METHOD "_GLOBAL::check_lt" #! PASS_AFTER "IrBuilder" #! INST "LenArray" #! INST_NEXT "IfImm" #! PASS_AFTER "Codegen" #! INST_NOT "LenArray" .function i32 check_lt(i32[] a0) { movi v0, 0 lenarr a0 jltz success ldai 0 return success: ldai 1 return } .function u1 main1() { movi v1, 3 newarr v0, v1, i32[] call check_lt, v0 return } #! CHECKER Check if LenArray is greater than zero is not eliminated #! RUN force_jit: true, options: "--compiler-inlining=false", entry: "_GLOBAL::main2" #! METHOD "_GLOBAL::check_le" #! PASS_AFTER "Codegen" #! INST "LenArray" #! INST_NEXT "IfImm" .function i32 check_le(i32[] a0) { movi v0, 0 lenarr a0 jlez success ldai 0 return success: ldai 1 return } .function u1 main2() { movi v1, 3 newarr v0, v1, i32[] call check_le, v0 jnez fail movi v2, 0 newarr v3, v2, i32[] call check_le, v3 jeqz fail ldai 0 return fail: ldai 1 return }