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 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.function i32 ifconv__noinline__(i32 a0, i32 a1, i32 a2) 100{ 101 ldai 10 102 jgt a0, lable_10 103 movi v1, 5 104 movi v2, 2 105 movi v3, 6 106 mulv v1, a1 107 shlv v2, a0 108 addv v3, a2 109 jmp exit 110lable_10: 111 movi v1, 4 112 movi v2, 3 113 movi v3, 5 114 mulv v1, a2 115 shlv v2, a1 116 subv v3, a0 117 jmp exit 118exit: 119 addv v1, v2 120 add v1, v3 121 return 122} 123 124.function i32 main1 () <> { 125 movi v4, 256 126 127 movi v5, 0 #loop_counter 128loop: 129 lda v5 130 movi v0, 0 131 movi v1, 10 132 movi v2, 5 133 movi v3, 3097 134 call ifconv__noinline__, v0, v1, v2 135 jne v3, error 136 movi v0, 11 137 movi v3, 4168 138 call ifconv__noinline__, v0, v0, v0 139 jne v3, error 140 inci v5, 1 141 lda v5 142 jne v4, loop 143 144 ldai 0 145 return 146error: 147 lda v3 148 return 149}