• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16# class DeoptimizeCompare {
17#     public static int main() {
18#         int[] array = new int[10];
19#         return sum(array, 10);
20#     }
21#     public static int sum(int[] arr, int size) {
22#         int s = 0;
23#         for (int i = 0; i < size; ++i) {
24#             s += arr[i];
25#         }
26#         return s;
27#     }
28# }
29
30#! CHECKER      DeoptimizeCompare
31#! RUN_PAOC     options: "--compiler-inlining false"
32#! METHOD       "sum"
33#! PASS_AFTER   "ChecksElimination"
34#! INST         "DeoptimizeIf"
35#! PASS_AFTER   "Lowering"
36#! INST         "DeoptimizeIf"
37#! INST         "DeoptimizeCompare"
38
39.function i32 sum(i32[] a0, i32 a1) <> {
40        movi v0, 0x0
41        mov v3, v0
42        movi v0, 0x0
43        mov v4, v0
44        jump_label_1: mov v0, v4
45        mov v1, a1
46        lda v0
47        jge v1, jump_label_0
48        mov v0, v3
49        mov.obj v1, a0
50        mov v2, v4
51        lda v2
52        ldarr v1
53        sta v1
54        add v1, v0
55        sta v0
56        mov v3, v0
57        inci v4, 0x1
58        jmp jump_label_1
59        jump_label_0: mov v0, v3
60        lda v0
61        return
62}
63