1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -verify-machineinstrs -csky-no-aliases -mattr=+2e3 < %s -mtriple=csky | FileCheck %s
4 define i32 @select_by_icmp_ugt(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
5 ; CHECK-LABEL: select_by_icmp_ugt:
7 ; CHECK-NEXT: cmphs16 a1, a0
8 ; CHECK-NEXT: decf32 a3, a2, 10
9 ; CHECK-NEXT: mov16 a0, a3
11 %t4 = icmp ugt i32 %t0, %t1
13 %t6 = select i1 %t4, i32 %t5, i32 %t3
17 define i32 @select_by_icmp_sgt(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
18 ; CHECK-LABEL: select_by_icmp_sgt:
20 ; CHECK-NEXT: cmplt16 a1, a0
21 ; CHECK-NEXT: dect32 a3, a2, 10
22 ; CHECK-NEXT: mov16 a0, a3
24 %t4 = icmp sgt i32 %t0, %t1
26 %t6 = select i1 %t4, i32 %t5, i32 %t3
30 define i32 @select_by_icmp_uge(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
31 ; CHECK-LABEL: select_by_icmp_uge:
33 ; CHECK-NEXT: cmphs16 a0, a1
34 ; CHECK-NEXT: dect32 a3, a2, 10
35 ; CHECK-NEXT: mov16 a0, a3
37 %t4 = icmp uge i32 %t0, %t1
39 %t6 = select i1 %t4, i32 %t5, i32 %t3
43 define i32 @select_by_icmp_sge(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
44 ; CHECK-LABEL: select_by_icmp_sge:
46 ; CHECK-NEXT: cmplt16 a0, a1
47 ; CHECK-NEXT: decf32 a3, a2, 10
48 ; CHECK-NEXT: mov16 a0, a3
50 %t4 = icmp sge i32 %t0, %t1
52 %t6 = select i1 %t4, i32 %t5, i32 %t3
56 define i32 @select_by_icmp_ult(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
57 ; CHECK-LABEL: select_by_icmp_ult:
59 ; CHECK-NEXT: cmphs16 a0, a1
60 ; CHECK-NEXT: decf32 a3, a2, 10
61 ; CHECK-NEXT: mov16 a0, a3
63 %t4 = icmp ult i32 %t0, %t1
65 %t6 = select i1 %t4, i32 %t5, i32 %t3
69 define i32 @select_by_icmp_slt(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
70 ; CHECK-LABEL: select_by_icmp_slt:
72 ; CHECK-NEXT: cmplt16 a0, a1
73 ; CHECK-NEXT: dect32 a3, a2, 10
74 ; CHECK-NEXT: mov16 a0, a3
76 %t4 = icmp slt i32 %t0, %t1
78 %t6 = select i1 %t4, i32 %t5, i32 %t3
82 define i32 @select_by_icmp_ule(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
83 ; CHECK-LABEL: select_by_icmp_ule:
85 ; CHECK-NEXT: cmphs16 a1, a0
86 ; CHECK-NEXT: dect32 a3, a2, 10
87 ; CHECK-NEXT: mov16 a0, a3
89 %t4 = icmp ule i32 %t0, %t1
91 %t6 = select i1 %t4, i32 %t5, i32 %t3
95 define i32 @select_by_icmp_sle(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
96 ; CHECK-LABEL: select_by_icmp_sle:
98 ; CHECK-NEXT: cmplt16 a1, a0
99 ; CHECK-NEXT: decf32 a3, a2, 10
100 ; CHECK-NEXT: mov16 a0, a3
102 %t4 = icmp sle i32 %t0, %t1
103 %t5 = sub i32 %t2, 10
104 %t6 = select i1 %t4, i32 %t5, i32 %t3
108 define i32 @select_by_icmp_ne(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
109 ; CHECK-LABEL: select_by_icmp_ne:
111 ; CHECK-NEXT: cmpne16 a0, a1
112 ; CHECK-NEXT: dect32 a3, a2, 10
113 ; CHECK-NEXT: mov16 a0, a3
115 %t4 = icmp ne i32 %t0, %t1
116 %t5 = sub i32 %t2, 10
117 %t6 = select i1 %t4, i32 %t5, i32 %t3
121 define i32 @select_by_icmp_eq(i32 %t0, i32 %t1, i32 %t2, i32 %t3) {
122 ; CHECK-LABEL: select_by_icmp_eq:
124 ; CHECK-NEXT: cmpne16 a0, a1
125 ; CHECK-NEXT: decf32 a3, a2, 10
126 ; CHECK-NEXT: mov16 a0, a3
128 %t4 = icmp eq i32 %t0, %t1
129 %t5 = sub i32 %t2, 10
130 %t6 = select i1 %t4, i32 %t5, i32 %t3
134 define i32 @select_by_icmp_ugt_imm(i32 %t0, i32 %t2, i32 %t3) {
135 ; CHECK-LABEL: select_by_icmp_ugt_imm:
137 ; CHECK-NEXT: movi16 a3, 128
138 ; CHECK-NEXT: cmphs16 a3, a0
139 ; CHECK-NEXT: decf32 a2, a1, 10
140 ; CHECK-NEXT: mov16 a0, a2
142 %t4 = icmp ugt i32 %t0, 128
143 %t5 = sub i32 %t2, 10
144 %t6 = select i1 %t4, i32 %t5, i32 %t3
148 define i32 @select_by_icmp_sgt_imm(i32 %t0, i32 %t2, i32 %t3) {
149 ; CHECK-LABEL: select_by_icmp_sgt_imm:
151 ; CHECK-NEXT: movi16 a3, 128
152 ; CHECK-NEXT: cmplt16 a3, a0
153 ; CHECK-NEXT: dect32 a2, a1, 10
154 ; CHECK-NEXT: mov16 a0, a2
156 %t4 = icmp sgt i32 %t0, 128
157 %t5 = sub i32 %t2, 10
158 %t6 = select i1 %t4, i32 %t5, i32 %t3
162 define i32 @select_by_icmp_uge_imm(i32 %t0, i32 %t2, i32 %t3) {
163 ; CHECK-LABEL: select_by_icmp_uge_imm:
165 ; CHECK-NEXT: movi16 a3, 127
166 ; CHECK-NEXT: cmphs16 a3, a0
167 ; CHECK-NEXT: decf32 a2, a1, 10
168 ; CHECK-NEXT: mov16 a0, a2
170 %t4 = icmp uge i32 %t0, 128
171 %t5 = sub i32 %t2, 10
172 %t6 = select i1 %t4, i32 %t5, i32 %t3
176 define i32 @select_by_icmp_sge_imm(i32 %t0, i32 %t2, i32 %t3) {
177 ; CHECK-LABEL: select_by_icmp_sge_imm:
179 ; CHECK-NEXT: movi16 a3, 127
180 ; CHECK-NEXT: cmplt16 a3, a0
181 ; CHECK-NEXT: dect32 a2, a1, 10
182 ; CHECK-NEXT: mov16 a0, a2
184 %t4 = icmp sge i32 %t0, 128
185 %t5 = sub i32 %t2, 10
186 %t6 = select i1 %t4, i32 %t5, i32 %t3
190 define i32 @select_by_icmp_ult_imm(i32 %t0, i32 %t2, i32 %t3) {
191 ; CHECK-LABEL: select_by_icmp_ult_imm:
193 ; CHECK-NEXT: cmphsi32 a0, 128
194 ; CHECK-NEXT: decf32 a2, a1, 10
195 ; CHECK-NEXT: mov16 a0, a2
197 %t4 = icmp ult i32 %t0, 128
198 %t5 = sub i32 %t2, 10
199 %t6 = select i1 %t4, i32 %t5, i32 %t3
203 define i32 @select_by_icmp_slt_imm(i32 %t0, i32 %t2, i32 %t3) {
204 ; CHECK-LABEL: select_by_icmp_slt_imm:
206 ; CHECK-NEXT: cmplti32 a0, 128
207 ; CHECK-NEXT: dect32 a2, a1, 10
208 ; CHECK-NEXT: mov16 a0, a2
210 %t4 = icmp slt i32 %t0, 128
211 %t5 = sub i32 %t2, 10
212 %t6 = select i1 %t4, i32 %t5, i32 %t3
216 define i32 @select_by_icmp_ule_imm(i32 %t0, i32 %t2, i32 %t3) {
217 ; CHECK-LABEL: select_by_icmp_ule_imm:
219 ; CHECK-NEXT: cmphsi32 a0, 129
220 ; CHECK-NEXT: decf32 a2, a1, 10
221 ; CHECK-NEXT: mov16 a0, a2
223 %t4 = icmp ule i32 %t0, 128
224 %t5 = sub i32 %t2, 10
225 %t6 = select i1 %t4, i32 %t5, i32 %t3
229 define i32 @select_by_icmp_sle_imm(i32 %t0, i32 %t2, i32 %t3) {
230 ; CHECK-LABEL: select_by_icmp_sle_imm:
232 ; CHECK-NEXT: cmplti32 a0, 129
233 ; CHECK-NEXT: dect32 a2, a1, 10
234 ; CHECK-NEXT: mov16 a0, a2
236 %t4 = icmp sle i32 %t0, 128
237 %t5 = sub i32 %t2, 10
238 %t6 = select i1 %t4, i32 %t5, i32 %t3
242 define i32 @select_by_icmp_ne_imm(i32 %t0, i32 %t2, i32 %t3) {
243 ; CHECK-LABEL: select_by_icmp_ne_imm:
245 ; CHECK-NEXT: cmpnei32 a0, 128
246 ; CHECK-NEXT: dect32 a2, a1, 10
247 ; CHECK-NEXT: mov16 a0, a2
249 %t4 = icmp ne i32 %t0, 128
250 %t5 = sub i32 %t2, 10
251 %t6 = select i1 %t4, i32 %t5, i32 %t3
255 define i32 @select_by_icmp_eq_imm(i32 %t0, i32 %t2, i32 %t3) {
256 ; CHECK-LABEL: select_by_icmp_eq_imm:
258 ; CHECK-NEXT: cmpnei32 a0, 128
259 ; CHECK-NEXT: decf32 a2, a1, 10
260 ; CHECK-NEXT: mov16 a0, a2
262 %t4 = icmp eq i32 %t0, 128
263 %t5 = sub i32 %t2, 10
264 %t6 = select i1 %t4, i32 %t5, i32 %t3
268 define i32 @select_by_call_t(i32 %t0, i32 %t1, i32 %t2) {
269 ; CHECK-LABEL: select_by_call_t:
271 ; CHECK-NEXT: subi16 sp, sp, 12
272 ; CHECK-NEXT: .cfi_def_cfa_offset 12
273 ; CHECK-NEXT: st16.w l1, (sp, 8) # 4-byte Folded Spill
274 ; CHECK-NEXT: st16.w l0, (sp, 4) # 4-byte Folded Spill
275 ; CHECK-NEXT: st32.w lr, (sp, 0) # 4-byte Folded Spill
276 ; CHECK-NEXT: .cfi_offset l1, -4
277 ; CHECK-NEXT: .cfi_offset l0, -8
278 ; CHECK-NEXT: .cfi_offset lr, -12
279 ; CHECK-NEXT: .cfi_def_cfa_offset 12
280 ; CHECK-NEXT: mov16 l0, a2
281 ; CHECK-NEXT: mov16 l1, a1
282 ; CHECK-NEXT: jsri32 [.LCPI20_0]
283 ; CHECK-NEXT: btsti16 a0, 0
284 ; CHECK-NEXT: dect32 l0, l1, 10
285 ; CHECK-NEXT: mov16 a0, l0
286 ; CHECK-NEXT: ld32.w lr, (sp, 0) # 4-byte Folded Reload
287 ; CHECK-NEXT: ld16.w l0, (sp, 4) # 4-byte Folded Reload
288 ; CHECK-NEXT: ld16.w l1, (sp, 8) # 4-byte Folded Reload
289 ; CHECK-NEXT: addi16 sp, sp, 12
291 ; CHECK-NEXT: .p2align 1
292 ; CHECK-NEXT: # %bb.1:
293 ; CHECK-NEXT: .p2align 2, 0x0
294 ; CHECK-NEXT: .LCPI20_0:
295 ; CHECK-NEXT: .long check_val
296 %t3 = tail call i1 @check_val(i32 %t0)
297 %t4 = sub i32 %t1, 10
298 %t5 = select i1 %t3, i32 %t4, i32 %t2
302 define i32 @select_by_call_f(i32 %t0, i32 %t1, i32 %t2) {
303 ; CHECK-LABEL: select_by_call_f:
305 ; CHECK-NEXT: subi16 sp, sp, 12
306 ; CHECK-NEXT: .cfi_def_cfa_offset 12
307 ; CHECK-NEXT: st16.w l1, (sp, 8) # 4-byte Folded Spill
308 ; CHECK-NEXT: st16.w l0, (sp, 4) # 4-byte Folded Spill
309 ; CHECK-NEXT: st32.w lr, (sp, 0) # 4-byte Folded Spill
310 ; CHECK-NEXT: .cfi_offset l1, -4
311 ; CHECK-NEXT: .cfi_offset l0, -8
312 ; CHECK-NEXT: .cfi_offset lr, -12
313 ; CHECK-NEXT: .cfi_def_cfa_offset 12
314 ; CHECK-NEXT: mov16 l0, a2
315 ; CHECK-NEXT: mov16 l1, a1
316 ; CHECK-NEXT: jsri32 [.LCPI21_0]
317 ; CHECK-NEXT: btsti16 a0, 0
318 ; CHECK-NEXT: decf32 l0, l1, 10
319 ; CHECK-NEXT: mov16 a0, l0
320 ; CHECK-NEXT: ld32.w lr, (sp, 0) # 4-byte Folded Reload
321 ; CHECK-NEXT: ld16.w l0, (sp, 4) # 4-byte Folded Reload
322 ; CHECK-NEXT: ld16.w l1, (sp, 8) # 4-byte Folded Reload
323 ; CHECK-NEXT: addi16 sp, sp, 12
325 ; CHECK-NEXT: .p2align 1
326 ; CHECK-NEXT: # %bb.1:
327 ; CHECK-NEXT: .p2align 2, 0x0
328 ; CHECK-NEXT: .LCPI21_0:
329 ; CHECK-NEXT: .long check_val
330 %t3 = tail call i1 @check_val(i32 %t0)
331 %t4 = sub i32 %t1, 10
332 %t5 = select i1 %t3, i32 %t2, i32 %t4
336 declare i1 @check_val(i32)