1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License.
4b1994897Sopenharmony_ci# You may obtain a copy of the License at
5b1994897Sopenharmony_ci#
6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
7b1994897Sopenharmony_ci#
8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and
12b1994897Sopenharmony_ci# limitations under the License.
13b1994897Sopenharmony_ci
14b1994897Sopenharmony_ci#
15b1994897Sopenharmony_ci# Tests on If/IfImm with CC_TST_EQ/CC_TST_NE condition code.
16b1994897Sopenharmony_ci#
17b1994897Sopenharmony_ci
18b1994897Sopenharmony_ci.function i32 ret0() {
19b1994897Sopenharmony_ci    ldai 0
20b1994897Sopenharmony_ci    return
21b1994897Sopenharmony_ci}
22b1994897Sopenharmony_ci
23b1994897Sopenharmony_ci.function i32 ret1() {
24b1994897Sopenharmony_ci    ldai 1
25b1994897Sopenharmony_ci    return
26b1994897Sopenharmony_ci}
27b1994897Sopenharmony_ci
28b1994897Sopenharmony_ci.function i32 testVarsEqZeroI32(i32 a0, i32 a1) {
29b1994897Sopenharmony_ci    lda a0
30b1994897Sopenharmony_ci    and2 a1
31b1994897Sopenharmony_ci    jeqz ret_true
32b1994897Sopenharmony_ci    call.short ret0
33b1994897Sopenharmony_ci    return
34b1994897Sopenharmony_ciret_true:
35b1994897Sopenharmony_ci    call.short ret1
36b1994897Sopenharmony_ci    return
37b1994897Sopenharmony_ci}
38b1994897Sopenharmony_ci
39b1994897Sopenharmony_ci.function i32 testVarsNeZeroI32(i32 a0, i32 a1) {
40b1994897Sopenharmony_ci    lda a0
41b1994897Sopenharmony_ci    and2 a1
42b1994897Sopenharmony_ci    jnez ret_true
43b1994897Sopenharmony_ci    call.short ret0
44b1994897Sopenharmony_ci    return
45b1994897Sopenharmony_ciret_true:
46b1994897Sopenharmony_ci    call.short ret1
47b1994897Sopenharmony_ci    return
48b1994897Sopenharmony_ci}
49b1994897Sopenharmony_ci
50b1994897Sopenharmony_ci.function i32 testVarSmallImmEqZeroI32(i32 a0) {
51b1994897Sopenharmony_ci    ldai 0x5
52b1994897Sopenharmony_ci    and2 a0
53b1994897Sopenharmony_ci    jeqz ret_true
54b1994897Sopenharmony_ci    call.short ret0
55b1994897Sopenharmony_ci    return
56b1994897Sopenharmony_ciret_true:
57b1994897Sopenharmony_ci    call.short ret1
58b1994897Sopenharmony_ci    return
59b1994897Sopenharmony_ci}
60b1994897Sopenharmony_ci
61b1994897Sopenharmony_ci.function i32 testVarSmallImmNeZeroI32(i32 a0) {
62b1994897Sopenharmony_ci    ldai 0x5
63b1994897Sopenharmony_ci    and2 a0
64b1994897Sopenharmony_ci    jnez ret_true
65b1994897Sopenharmony_ci    call.short ret0
66b1994897Sopenharmony_ci    return
67b1994897Sopenharmony_ciret_true:
68b1994897Sopenharmony_ci    call.short ret1
69b1994897Sopenharmony_ci    return
70b1994897Sopenharmony_ci}
71b1994897Sopenharmony_ci
72b1994897Sopenharmony_ci.function i32 testVarLargeImmEqZeroI32(i32 a0) {
73b1994897Sopenharmony_ci    ldai 0xffb1ab1a
74b1994897Sopenharmony_ci    and2 a0
75b1994897Sopenharmony_ci    jeqz ret_true
76b1994897Sopenharmony_ci    call.short ret0
77b1994897Sopenharmony_ci    return
78b1994897Sopenharmony_ciret_true:
79b1994897Sopenharmony_ci    call.short ret1
80b1994897Sopenharmony_ci    return
81b1994897Sopenharmony_ci}
82b1994897Sopenharmony_ci
83b1994897Sopenharmony_ci.function i32 testVarLargeImmNeZeroI32(i32 a0) {
84b1994897Sopenharmony_ci    ldai 0xffb1ab1a
85b1994897Sopenharmony_ci    and2 a0
86b1994897Sopenharmony_ci    jnez ret_true
87b1994897Sopenharmony_ci    call.short ret0
88b1994897Sopenharmony_ci    return
89b1994897Sopenharmony_ciret_true:
90b1994897Sopenharmony_ci    call.short ret1
91b1994897Sopenharmony_ci    return
92b1994897Sopenharmony_ci}
93b1994897Sopenharmony_ci
94b1994897Sopenharmony_ci.function i32 testVarsEqZeroI64(i64 a0, i64 a1) {
95b1994897Sopenharmony_ci    lda.64 a0
96b1994897Sopenharmony_ci    and2.64 a1
97b1994897Sopenharmony_ci    movi.64 v0, 0
98b1994897Sopenharmony_ci    cmp.64 v0
99b1994897Sopenharmony_ci    jeqz ret_true
100b1994897Sopenharmony_ci    call.short ret0
101b1994897Sopenharmony_ci    return
102b1994897Sopenharmony_ciret_true:
103b1994897Sopenharmony_ci    call.short ret1
104b1994897Sopenharmony_ci    return
105b1994897Sopenharmony_ci}
106b1994897Sopenharmony_ci
107b1994897Sopenharmony_ci.function i32 testVarsNeZeroI64(i64 a0, i64 a1) {
108b1994897Sopenharmony_ci    lda.64 a0
109b1994897Sopenharmony_ci    and2.64 a1
110b1994897Sopenharmony_ci    movi.64 v0, 0
111b1994897Sopenharmony_ci    cmp.64 v0
112b1994897Sopenharmony_ci    jnez ret_true
113b1994897Sopenharmony_ci    call.short ret0
114b1994897Sopenharmony_ci    return
115b1994897Sopenharmony_ciret_true:
116b1994897Sopenharmony_ci    call.short ret1
117b1994897Sopenharmony_ci    return
118b1994897Sopenharmony_ci}
119b1994897Sopenharmony_ci
120b1994897Sopenharmony_ci.function i32 testVarSmallImmEqZeroI64(i64 a0) {
121b1994897Sopenharmony_ci    ldai.64 0x5
122b1994897Sopenharmony_ci    and2.64 a0
123b1994897Sopenharmony_ci    movi.64 v0, 0
124b1994897Sopenharmony_ci    cmp.64 v0
125b1994897Sopenharmony_ci    jeqz ret_true
126b1994897Sopenharmony_ci    call.short ret0
127b1994897Sopenharmony_ci    return
128b1994897Sopenharmony_ciret_true:
129b1994897Sopenharmony_ci    call.short ret1
130b1994897Sopenharmony_ci    return
131b1994897Sopenharmony_ci}
132b1994897Sopenharmony_ci
133b1994897Sopenharmony_ci.function i32 testVarSmallImmNeZeroI64(i64 a0) {
134b1994897Sopenharmony_ci    ldai.64 0x5
135b1994897Sopenharmony_ci    and2.64 a0
136b1994897Sopenharmony_ci    movi.64 v0, 0
137b1994897Sopenharmony_ci    cmp.64 v0
138b1994897Sopenharmony_ci    jnez ret_true
139b1994897Sopenharmony_ci    call.short ret0
140b1994897Sopenharmony_ci    return
141b1994897Sopenharmony_ciret_true:
142b1994897Sopenharmony_ci    call.short ret1
143b1994897Sopenharmony_ci    return
144b1994897Sopenharmony_ci}
145b1994897Sopenharmony_ci
146b1994897Sopenharmony_ci.function i32 testVarLargeImmEqZeroI64(i64 a0) {
147b1994897Sopenharmony_ci    ldai.64 0xffffb1ab1ab1ab1a
148b1994897Sopenharmony_ci    and2.64 a0
149b1994897Sopenharmony_ci    movi.64 v0, 0
150b1994897Sopenharmony_ci    cmp.64 v0
151b1994897Sopenharmony_ci    jeqz ret_true
152b1994897Sopenharmony_ci    call.short ret0
153b1994897Sopenharmony_ci    return
154b1994897Sopenharmony_ciret_true:
155b1994897Sopenharmony_ci    call.short ret1
156b1994897Sopenharmony_ci    return
157b1994897Sopenharmony_ci}
158b1994897Sopenharmony_ci
159b1994897Sopenharmony_ci.function i32 testVarLargeImmNeZeroI64(i64 a0) {
160b1994897Sopenharmony_ci    ldai.64 0xffffb1ab1ab1ab1a
161b1994897Sopenharmony_ci    and2.64 a0
162b1994897Sopenharmony_ci    movi.64 v0, 0
163b1994897Sopenharmony_ci    cmp.64 v0
164b1994897Sopenharmony_ci    jnez ret_true
165b1994897Sopenharmony_ci    call.short ret0
166b1994897Sopenharmony_ci    return
167b1994897Sopenharmony_ciret_true:
168b1994897Sopenharmony_ci    call.short ret1
169b1994897Sopenharmony_ci    return
170b1994897Sopenharmony_ci}
171b1994897Sopenharmony_ci
172b1994897Sopenharmony_ci.function i32 main() {
173b1994897Sopenharmony_ci    movi v0, 0x01010101
174b1994897Sopenharmony_ci    movi v1, 0x10101010
175b1994897Sopenharmony_ci    movi v2, 0xffffffff
176b1994897Sopenharmony_ci    movi v3, 0x0
177b1994897Sopenharmony_ci
178b1994897Sopenharmony_ci    call.short testVarsEqZeroI32, v0, v1
179b1994897Sopenharmony_ci    jeqz error_0
180b1994897Sopenharmony_ci    call.short testVarsEqZeroI32, v0, v0
181b1994897Sopenharmony_ci    jnez error_1
182b1994897Sopenharmony_ci    call.short testVarsNeZeroI32, v0, v1
183b1994897Sopenharmony_ci    jnez error_2
184b1994897Sopenharmony_ci    call.short testVarsNeZeroI32, v0, v0
185b1994897Sopenharmony_ci    jeqz error_3
186b1994897Sopenharmony_ci    call.short testVarSmallImmEqZeroI32, v3
187b1994897Sopenharmony_ci    jeqz error_4
188b1994897Sopenharmony_ci    call.short testVarSmallImmEqZeroI32, v2
189b1994897Sopenharmony_ci    jnez error_5
190b1994897Sopenharmony_ci    call.short testVarSmallImmNeZeroI32, v3
191b1994897Sopenharmony_ci    jnez error_6
192b1994897Sopenharmony_ci    call.short testVarSmallImmNeZeroI32, v2
193b1994897Sopenharmony_ci    jeqz error_7
194b1994897Sopenharmony_ci    call.short testVarLargeImmEqZeroI32, v3
195b1994897Sopenharmony_ci    jeqz error_8
196b1994897Sopenharmony_ci    call.short testVarLargeImmEqZeroI32, v2
197b1994897Sopenharmony_ci    jnez error_9
198b1994897Sopenharmony_ci    call.short testVarLargeImmNeZeroI32, v3
199b1994897Sopenharmony_ci    jnez error_10
200b1994897Sopenharmony_ci    call.short testVarLargeImmNeZeroI32, v2
201b1994897Sopenharmony_ci    jeqz error_11
202b1994897Sopenharmony_ci
203b1994897Sopenharmony_ci    movi.64 v0, 0x0101010101010101
204b1994897Sopenharmony_ci    movi.64 v1, 0x1010101010101010
205b1994897Sopenharmony_ci    movi.64 v2, 0xffffffffffffffff
206b1994897Sopenharmony_ci    movi.64 v3, 0x0
207b1994897Sopenharmony_ci
208b1994897Sopenharmony_ci    call.short testVarsEqZeroI64, v0, v1
209b1994897Sopenharmony_ci    jeqz error_12
210b1994897Sopenharmony_ci    call.short testVarsEqZeroI64, v0, v0
211b1994897Sopenharmony_ci    jnez error_13
212b1994897Sopenharmony_ci    call.short testVarsNeZeroI64, v0, v1
213b1994897Sopenharmony_ci    jnez error_14
214b1994897Sopenharmony_ci    call.short testVarsNeZeroI64, v0, v0
215b1994897Sopenharmony_ci    jeqz error_15
216b1994897Sopenharmony_ci    call.short testVarSmallImmEqZeroI64, v3
217b1994897Sopenharmony_ci    jeqz error_16
218b1994897Sopenharmony_ci    call.short testVarSmallImmEqZeroI64, v2
219b1994897Sopenharmony_ci    jnez error_17
220b1994897Sopenharmony_ci    call.short testVarSmallImmNeZeroI64, v3
221b1994897Sopenharmony_ci    jnez error_18
222b1994897Sopenharmony_ci    call.short testVarSmallImmNeZeroI64, v2
223b1994897Sopenharmony_ci    jeqz error_19
224b1994897Sopenharmony_ci    call.short testVarLargeImmEqZeroI64, v3
225b1994897Sopenharmony_ci    jeqz error_20
226b1994897Sopenharmony_ci    call.short testVarLargeImmEqZeroI64, v2
227b1994897Sopenharmony_ci    jnez error_21
228b1994897Sopenharmony_ci    call.short testVarLargeImmNeZeroI64, v3
229b1994897Sopenharmony_ci    jnez error_22
230b1994897Sopenharmony_ci    call.short testVarLargeImmNeZeroI64, v2
231b1994897Sopenharmony_ci    jeqz error_23
232b1994897Sopenharmony_ci
233b1994897Sopenharmony_ci    ldai 0
234b1994897Sopenharmony_ci    return
235b1994897Sopenharmony_cierror_0:
236b1994897Sopenharmony_ci    ldai 1
237b1994897Sopenharmony_ci    return
238b1994897Sopenharmony_cierror_1:
239b1994897Sopenharmony_ci    ldai 2
240b1994897Sopenharmony_ci    return
241b1994897Sopenharmony_cierror_2:
242b1994897Sopenharmony_ci    ldai 3
243b1994897Sopenharmony_ci    return
244b1994897Sopenharmony_cierror_3:
245b1994897Sopenharmony_ci    ldai 4
246b1994897Sopenharmony_ci    return
247b1994897Sopenharmony_cierror_4:
248b1994897Sopenharmony_ci    ldai 5
249b1994897Sopenharmony_ci    return
250b1994897Sopenharmony_cierror_5:
251b1994897Sopenharmony_ci    ldai 6
252b1994897Sopenharmony_ci    return
253b1994897Sopenharmony_cierror_6:
254b1994897Sopenharmony_ci    ldai 7
255b1994897Sopenharmony_ci    return
256b1994897Sopenharmony_cierror_7:
257b1994897Sopenharmony_ci    ldai 8
258b1994897Sopenharmony_ci    return
259b1994897Sopenharmony_cierror_8:
260b1994897Sopenharmony_ci    ldai 9
261b1994897Sopenharmony_ci    return
262b1994897Sopenharmony_cierror_9:
263b1994897Sopenharmony_ci    ldai 10
264b1994897Sopenharmony_ci    return
265b1994897Sopenharmony_cierror_10:
266b1994897Sopenharmony_ci    ldai 11
267b1994897Sopenharmony_ci    return
268b1994897Sopenharmony_cierror_11:
269b1994897Sopenharmony_ci    ldai 12
270b1994897Sopenharmony_ci    return
271b1994897Sopenharmony_cierror_12:
272b1994897Sopenharmony_ci    ldai 13
273b1994897Sopenharmony_ci    return
274b1994897Sopenharmony_cierror_13:
275b1994897Sopenharmony_ci    ldai 14
276b1994897Sopenharmony_ci    return
277b1994897Sopenharmony_cierror_14:
278b1994897Sopenharmony_ci    ldai 15
279b1994897Sopenharmony_ci    return
280b1994897Sopenharmony_cierror_15:
281b1994897Sopenharmony_ci    ldai 16
282b1994897Sopenharmony_ci    return
283b1994897Sopenharmony_cierror_16:
284b1994897Sopenharmony_ci    ldai 17
285b1994897Sopenharmony_ci    return
286b1994897Sopenharmony_cierror_17:
287b1994897Sopenharmony_ci    ldai 18
288b1994897Sopenharmony_ci    return
289b1994897Sopenharmony_cierror_18:
290b1994897Sopenharmony_ci    ldai 19
291b1994897Sopenharmony_ci    return
292b1994897Sopenharmony_cierror_19:
293b1994897Sopenharmony_ci    ldai 20
294b1994897Sopenharmony_ci    return
295b1994897Sopenharmony_cierror_20:
296b1994897Sopenharmony_ci    ldai 21
297b1994897Sopenharmony_ci    return
298b1994897Sopenharmony_cierror_21:
299b1994897Sopenharmony_ci    ldai 22
300b1994897Sopenharmony_ci    return
301b1994897Sopenharmony_cierror_22:
302b1994897Sopenharmony_ci    ldai 23
303b1994897Sopenharmony_ci    return
304b1994897Sopenharmony_cierror_23:
305b1994897Sopenharmony_ci    ldai 24
306b1994897Sopenharmony_ci    return
307b1994897Sopenharmony_ci}