1# Copyright (c) 2021-2025 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 IfConversion in JIT 15#! RUN force_jit: true, options: "", entry: "_GLOBAL::main" 16#! EVENT /Compilation,_GLOBAL::main,.*COMPILED/ 17#! METHOD "_GLOBAL::main" 18#! PASS_AFTER "MemoryCoalescing" 19#! INST_NOT "SelectImm GT i32" 20#! @mem_coalescing_count = BLOCK_COUNT() 21#! PASS_AFTER "IfConversion" 22#! TRUE @mem_coalescing_count > BLOCK_COUNT() 23#! INST "SelectImm GT i32" 24# Construction before is necessary for compare the quantity of base blocks after pass "MemoryCoalescing" and after "IfConversion", 25# without variable, you can write only such code. 26# Equivalent code with variable: 27# temp = BLOCK_COUNT() 28# PASS_AFTER("IfConversion") 29# TRUE(temp > BLOCK_COUNT()) 30 31#! CHECKER Check IfConversion in AOT 32#! SKIP_IF @architecture == "arm32" 33#! RUN_PAOC options: "" 34#! METHOD "_GLOBAL::main" 35#! PASS_AFTER "MemoryCoalescing" 36#! INST_NOT "SelectImm GT i32" 37#! @mem_coalescing_count = BLOCK_COUNT() 38#! PASS_AFTER "IfConversion" 39#! TRUE @mem_coalescing_count > BLOCK_COUNT() 40#! INST "SelectImm GT i32" 41#! RUN options: "", entry: "_GLOBAL::main" 42#! EVENT "AotEntrypointFound,_GLOBAL::main" 43# Construction after is necessary for compare the quantity of base blocks after pass "MemoryCoalescing" and after "IfConversion", 44# without variable, you can write only such code. 45# Equivalent code with variable: 46# temp = BLOCK_COUNT() 47# PASS_AFTER("IfConversion") 48# TRUE(temp > BLOCK_COUNT()) 49 50.function i32 main () <> { 51 movi v0, 0 52 movi v1, 10 53 movi v2, 5 54loop: 55 lda v1 56 jgt v2, inci 57 inci v0, -1 58 jmp done 59inci: 60 inci v0, 1 61done: 62 inci v1, -1 63 lda v1 64 jgtz loop 65 lda v0 66 return 67} 68 69#! CHECKER Check do not increase limit IfConversion in force JIT 70#! RUN force_jit: true, options: "", entry: "_GLOBAL::main1" 71#! EVENT /Compilation,_GLOBAL::ifconv__noinline__,.*COMPILED/ 72#! METHOD "_GLOBAL::ifconv__noinline__" 73#! PASS_AFTER "MemoryCoalescing" 74#! INST_NOT "SelectImm LT i32" 75#! PASS_AFTER "IfConversion" 76#! INST_NOT "SelectImm LT i32" 77 78#! CHECKER Check increase limit IfConversion in JIT 79#! RUN options: "--compiler-hotness-threshold=10 --compiler-profiling-threshold=2 --no-async-jit=true", entry: "_GLOBAL::main1" 80#! EVENT /Compilation,_GLOBAL::ifconv__noinline__,.*COMPILED/ 81#! METHOD "_GLOBAL::ifconv__noinline__" 82#! PASS_AFTER "MemoryCoalescing" 83#! INST_NOT "SelectImm LT i32" 84#! PASS_AFTER "IfConversion" 85#! INST_COUNT "SelectImm LT i32", 3 86 87#! CHECKER Check do not increase limit IfConversion in AOT 88#! SKIP_IF @architecture == "arm32" 89#! RUN_PAOC options: "" 90#! EVENT /Compilation,_GLOBAL::ifconv__noinline__,.*COMPILED/ 91#! METHOD "_GLOBAL::ifconv__noinline__" 92#! PASS_AFTER "MemoryCoalescing" 93#! INST_NOT "SelectImm LT i32" 94#! PASS_AFTER "IfConversion" 95#! INST_NOT "SelectImm LT i32" 96#! RUN options: "", entry: "_GLOBAL::main1" 97#! EVENT "AotEntrypointFound,_GLOBAL::ifconv__noinline__" 98 99#! CHECKER Check hotness and increase limit IfConversion in PGO AOT 100#! SKIP_IF @architecture == "arm32" 101#! RUN_PGO_PROF entry: "_GLOBAL::main1" 102#! RUN_PGO_PAOC options: "" 103#! EVENT /Compilation,_GLOBAL::ifconv__noinline__,.*COMPILED/ 104#! METHOD "_GLOBAL::main" 105#! PASS_AFTER "IfConversion" 106#! INST "hotness=0" 107#! INST_NOT /hotness=[1-9]/ 108#! METHOD "_GLOBAL::ifconv__noinline__" 109#! PASS_AFTER "MemoryCoalescing" 110#! INST_NOT "SelectImm LT i32" 111#! PASS_AFTER "IfConversion" 112#! INST /hotness=[1-9]/ 113#! INST_COUNT "SelectImm LT i32", 3 114#! RUN entry: "_GLOBAL::main1" 115#! EVENT "AotEntrypointFound,_GLOBAL::ifconv__noinline__" 116 117.function i32 ifconv__noinline__(i32 a0, i32 a1, i32 a2) 118{ 119 ldai 10 120 jgt a0, lable_10 121 movi v1, 5 122 movi v2, 2 123 movi v3, 6 124 mulv v1, a1 125 shlv v2, a0 126 addv v3, a2 127 jmp exit 128lable_10: 129 movi v1, 4 130 movi v2, 3 131 movi v3, 5 132 mulv v1, a2 133 shlv v2, a1 134 subv v3, a0 135 jmp exit 136exit: 137 addv v1, v2 138 add v1, v3 139 return 140} 141 142.function i32 main1 () <> { 143 movi v4, 256 144 145 movi v5, 0 #loop_counter 146loop: 147 lda v5 148 movi v0, 0 149 movi v1, 10 150 movi v2, 5 151 movi v3, 3097 152 call ifconv__noinline__, v0, v1, v2 153 jne v3, error 154 movi v0, 11 155 movi v3, 4168 156 call ifconv__noinline__, v0, v0, v0 157 jne v3, error 158 inci v5, 1 159 lda v5 160 jne v4, loop 161 162 ldai 0 163 return 164error: 165 lda v3 166 return 167}