1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,CHECK32,RV32IM %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,CHECK64,RV64IM %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+m,+xventanacondops -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,CHECK64,RV64IMXVTCONDOPS %s
5 ; RUN: llc -mtriple=riscv32 -mattr=+m,+experimental-zicond -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,CHECK32,CHECKZICOND,RV32IMZICOND %s
6 ; RUN: llc -mtriple=riscv64 -mattr=+m,+experimental-zicond -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,CHECK64,CHECKZICOND,RV64IMZICOND %s
8 define i16 @select_xor_1(i16 %A, i8 %cond) {
9 ; CHECK32-LABEL: select_xor_1:
10 ; CHECK32: # %bb.0: # %entry
11 ; CHECK32-NEXT: slli a1, a1, 31
12 ; CHECK32-NEXT: srai a1, a1, 31
13 ; CHECK32-NEXT: andi a1, a1, 43
14 ; CHECK32-NEXT: xor a0, a0, a1
17 ; CHECK64-LABEL: select_xor_1:
18 ; CHECK64: # %bb.0: # %entry
19 ; CHECK64-NEXT: slli a1, a1, 63
20 ; CHECK64-NEXT: srai a1, a1, 63
21 ; CHECK64-NEXT: andi a1, a1, 43
22 ; CHECK64-NEXT: xor a0, a0, a1
25 %and = and i8 %cond, 1
26 %cmp10 = icmp eq i8 %and, 0
28 %1 = select i1 %cmp10, i16 %A, i16 %0
32 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
33 ; icmp eq (and %cond, 1), 0
34 define i16 @select_xor_1b(i16 %A, i8 %cond) {
35 ; RV32IM-LABEL: select_xor_1b:
36 ; RV32IM: # %bb.0: # %entry
37 ; RV32IM-NEXT: slli a1, a1, 31
38 ; RV32IM-NEXT: srai a1, a1, 31
39 ; RV32IM-NEXT: andi a1, a1, 43
40 ; RV32IM-NEXT: xor a0, a0, a1
43 ; RV64IM-LABEL: select_xor_1b:
44 ; RV64IM: # %bb.0: # %entry
45 ; RV64IM-NEXT: slli a1, a1, 63
46 ; RV64IM-NEXT: srai a1, a1, 63
47 ; RV64IM-NEXT: andi a1, a1, 43
48 ; RV64IM-NEXT: xor a0, a0, a1
51 ; RV64IMXVTCONDOPS-LABEL: select_xor_1b:
52 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
53 ; RV64IMXVTCONDOPS-NEXT: andi a1, a1, 1
54 ; RV64IMXVTCONDOPS-NEXT: li a2, 43
55 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a2, a1
56 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
57 ; RV64IMXVTCONDOPS-NEXT: ret
59 ; CHECKZICOND-LABEL: select_xor_1b:
60 ; CHECKZICOND: # %bb.0: # %entry
61 ; CHECKZICOND-NEXT: andi a1, a1, 1
62 ; CHECKZICOND-NEXT: li a2, 43
63 ; CHECKZICOND-NEXT: czero.eqz a1, a2, a1
64 ; CHECKZICOND-NEXT: xor a0, a0, a1
65 ; CHECKZICOND-NEXT: ret
67 %and = and i8 %cond, 1
68 %cmp10 = icmp ne i8 %and, 1
70 %1 = select i1 %cmp10, i16 %A, i16 %0
74 define i32 @select_xor_2(i32 %A, i32 %B, i8 %cond) {
75 ; CHECK32-LABEL: select_xor_2:
76 ; CHECK32: # %bb.0: # %entry
77 ; CHECK32-NEXT: slli a2, a2, 31
78 ; CHECK32-NEXT: srai a2, a2, 31
79 ; CHECK32-NEXT: and a1, a2, a1
80 ; CHECK32-NEXT: xor a0, a0, a1
83 ; CHECK64-LABEL: select_xor_2:
84 ; CHECK64: # %bb.0: # %entry
85 ; CHECK64-NEXT: slli a2, a2, 63
86 ; CHECK64-NEXT: srai a2, a2, 63
87 ; CHECK64-NEXT: and a1, a2, a1
88 ; CHECK64-NEXT: xor a0, a0, a1
91 %and = and i8 %cond, 1
92 %cmp10 = icmp eq i8 %and, 0
94 %1 = select i1 %cmp10, i32 %A, i32 %0
98 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
99 ; icmp eq (and %cond, 1), 0
100 define i32 @select_xor_2b(i32 %A, i32 %B, i8 %cond) {
101 ; RV32IM-LABEL: select_xor_2b:
102 ; RV32IM: # %bb.0: # %entry
103 ; RV32IM-NEXT: slli a2, a2, 31
104 ; RV32IM-NEXT: srai a2, a2, 31
105 ; RV32IM-NEXT: and a1, a2, a1
106 ; RV32IM-NEXT: xor a0, a0, a1
109 ; RV64IM-LABEL: select_xor_2b:
110 ; RV64IM: # %bb.0: # %entry
111 ; RV64IM-NEXT: slli a2, a2, 63
112 ; RV64IM-NEXT: srai a2, a2, 63
113 ; RV64IM-NEXT: and a1, a2, a1
114 ; RV64IM-NEXT: xor a0, a0, a1
117 ; RV64IMXVTCONDOPS-LABEL: select_xor_2b:
118 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
119 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
120 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a1, a2
121 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
122 ; RV64IMXVTCONDOPS-NEXT: ret
124 ; CHECKZICOND-LABEL: select_xor_2b:
125 ; CHECKZICOND: # %bb.0: # %entry
126 ; CHECKZICOND-NEXT: andi a2, a2, 1
127 ; CHECKZICOND-NEXT: czero.eqz a1, a1, a2
128 ; CHECKZICOND-NEXT: xor a0, a0, a1
129 ; CHECKZICOND-NEXT: ret
131 %and = and i8 %cond, 1
132 %cmp10 = icmp ne i8 %and, 1
134 %1 = select i1 %cmp10, i32 %A, i32 %0
138 define i16 @select_xor_3(i16 %A, i8 %cond) {
139 ; RV32IM-LABEL: select_xor_3:
140 ; RV32IM: # %bb.0: # %entry
141 ; RV32IM-NEXT: andi a1, a1, 1
142 ; RV32IM-NEXT: addi a1, a1, -1
143 ; RV32IM-NEXT: andi a1, a1, 43
144 ; RV32IM-NEXT: xor a0, a0, a1
147 ; RV64IM-LABEL: select_xor_3:
148 ; RV64IM: # %bb.0: # %entry
149 ; RV64IM-NEXT: andi a1, a1, 1
150 ; RV64IM-NEXT: addi a1, a1, -1
151 ; RV64IM-NEXT: andi a1, a1, 43
152 ; RV64IM-NEXT: xor a0, a0, a1
155 ; RV64IMXVTCONDOPS-LABEL: select_xor_3:
156 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
157 ; RV64IMXVTCONDOPS-NEXT: andi a1, a1, 1
158 ; RV64IMXVTCONDOPS-NEXT: li a2, 43
159 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a2, a1
160 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
161 ; RV64IMXVTCONDOPS-NEXT: ret
163 ; CHECKZICOND-LABEL: select_xor_3:
164 ; CHECKZICOND: # %bb.0: # %entry
165 ; CHECKZICOND-NEXT: andi a1, a1, 1
166 ; CHECKZICOND-NEXT: li a2, 43
167 ; CHECKZICOND-NEXT: czero.nez a1, a2, a1
168 ; CHECKZICOND-NEXT: xor a0, a0, a1
169 ; CHECKZICOND-NEXT: ret
171 %and = and i8 %cond, 1
172 %cmp10 = icmp eq i8 %and, 0
174 %1 = select i1 %cmp10, i16 %0, i16 %A
178 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
179 ; icmp eq (and %cond, 1), 0
180 define i16 @select_xor_3b(i16 %A, i8 %cond) {
181 ; RV32IM-LABEL: select_xor_3b:
182 ; RV32IM: # %bb.0: # %entry
183 ; RV32IM-NEXT: andi a1, a1, 1
184 ; RV32IM-NEXT: addi a1, a1, -1
185 ; RV32IM-NEXT: andi a1, a1, 43
186 ; RV32IM-NEXT: xor a0, a0, a1
189 ; RV64IM-LABEL: select_xor_3b:
190 ; RV64IM: # %bb.0: # %entry
191 ; RV64IM-NEXT: andi a1, a1, 1
192 ; RV64IM-NEXT: addi a1, a1, -1
193 ; RV64IM-NEXT: andi a1, a1, 43
194 ; RV64IM-NEXT: xor a0, a0, a1
197 ; RV64IMXVTCONDOPS-LABEL: select_xor_3b:
198 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
199 ; RV64IMXVTCONDOPS-NEXT: andi a1, a1, 1
200 ; RV64IMXVTCONDOPS-NEXT: li a2, 43
201 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a2, a1
202 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
203 ; RV64IMXVTCONDOPS-NEXT: ret
205 ; CHECKZICOND-LABEL: select_xor_3b:
206 ; CHECKZICOND: # %bb.0: # %entry
207 ; CHECKZICOND-NEXT: andi a1, a1, 1
208 ; CHECKZICOND-NEXT: li a2, 43
209 ; CHECKZICOND-NEXT: czero.nez a1, a2, a1
210 ; CHECKZICOND-NEXT: xor a0, a0, a1
211 ; CHECKZICOND-NEXT: ret
213 %and = and i8 %cond, 1
214 %cmp10 = icmp ne i8 %and, 1
216 %1 = select i1 %cmp10, i16 %0, i16 %A
220 define i32 @select_xor_4(i32 %A, i32 %B, i8 %cond) {
221 ; RV32IM-LABEL: select_xor_4:
222 ; RV32IM: # %bb.0: # %entry
223 ; RV32IM-NEXT: andi a2, a2, 1
224 ; RV32IM-NEXT: addi a2, a2, -1
225 ; RV32IM-NEXT: and a1, a2, a1
226 ; RV32IM-NEXT: xor a0, a0, a1
229 ; RV64IM-LABEL: select_xor_4:
230 ; RV64IM: # %bb.0: # %entry
231 ; RV64IM-NEXT: andi a2, a2, 1
232 ; RV64IM-NEXT: addi a2, a2, -1
233 ; RV64IM-NEXT: and a1, a2, a1
234 ; RV64IM-NEXT: xor a0, a0, a1
237 ; RV64IMXVTCONDOPS-LABEL: select_xor_4:
238 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
239 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
240 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
241 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
242 ; RV64IMXVTCONDOPS-NEXT: ret
244 ; CHECKZICOND-LABEL: select_xor_4:
245 ; CHECKZICOND: # %bb.0: # %entry
246 ; CHECKZICOND-NEXT: andi a2, a2, 1
247 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
248 ; CHECKZICOND-NEXT: xor a0, a0, a1
249 ; CHECKZICOND-NEXT: ret
251 %and = and i8 %cond, 1
252 %cmp10 = icmp eq i8 %and, 0
254 %1 = select i1 %cmp10, i32 %0, i32 %A
258 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
259 ; icmp eq (and %cond, 1), 0
260 define i32 @select_xor_4b(i32 %A, i32 %B, i8 %cond) {
261 ; RV32IM-LABEL: select_xor_4b:
262 ; RV32IM: # %bb.0: # %entry
263 ; RV32IM-NEXT: andi a2, a2, 1
264 ; RV32IM-NEXT: addi a2, a2, -1
265 ; RV32IM-NEXT: and a1, a2, a1
266 ; RV32IM-NEXT: xor a0, a0, a1
269 ; RV64IM-LABEL: select_xor_4b:
270 ; RV64IM: # %bb.0: # %entry
271 ; RV64IM-NEXT: andi a2, a2, 1
272 ; RV64IM-NEXT: addi a2, a2, -1
273 ; RV64IM-NEXT: and a1, a2, a1
274 ; RV64IM-NEXT: xor a0, a0, a1
277 ; RV64IMXVTCONDOPS-LABEL: select_xor_4b:
278 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
279 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
280 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
281 ; RV64IMXVTCONDOPS-NEXT: xor a0, a0, a1
282 ; RV64IMXVTCONDOPS-NEXT: ret
284 ; CHECKZICOND-LABEL: select_xor_4b:
285 ; CHECKZICOND: # %bb.0: # %entry
286 ; CHECKZICOND-NEXT: andi a2, a2, 1
287 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
288 ; CHECKZICOND-NEXT: xor a0, a0, a1
289 ; CHECKZICOND-NEXT: ret
291 %and = and i8 %cond, 1
292 %cmp10 = icmp ne i8 %and, 1
294 %1 = select i1 %cmp10, i32 %0, i32 %A
298 define i32 @select_or(i32 %A, i32 %B, i8 %cond) {
299 ; CHECK32-LABEL: select_or:
300 ; CHECK32: # %bb.0: # %entry
301 ; CHECK32-NEXT: slli a2, a2, 31
302 ; CHECK32-NEXT: srai a2, a2, 31
303 ; CHECK32-NEXT: and a1, a2, a1
304 ; CHECK32-NEXT: or a0, a0, a1
307 ; CHECK64-LABEL: select_or:
308 ; CHECK64: # %bb.0: # %entry
309 ; CHECK64-NEXT: slli a2, a2, 63
310 ; CHECK64-NEXT: srai a2, a2, 63
311 ; CHECK64-NEXT: and a1, a2, a1
312 ; CHECK64-NEXT: or a0, a0, a1
315 %and = and i8 %cond, 1
316 %cmp10 = icmp eq i8 %and, 0
318 %1 = select i1 %cmp10, i32 %A, i32 %0
322 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
323 ; icmp eq (and %cond, 1), 0
324 define i32 @select_or_b(i32 %A, i32 %B, i8 %cond) {
325 ; RV32IM-LABEL: select_or_b:
326 ; RV32IM: # %bb.0: # %entry
327 ; RV32IM-NEXT: slli a2, a2, 31
328 ; RV32IM-NEXT: srai a2, a2, 31
329 ; RV32IM-NEXT: and a1, a2, a1
330 ; RV32IM-NEXT: or a0, a0, a1
333 ; RV64IM-LABEL: select_or_b:
334 ; RV64IM: # %bb.0: # %entry
335 ; RV64IM-NEXT: slli a2, a2, 63
336 ; RV64IM-NEXT: srai a2, a2, 63
337 ; RV64IM-NEXT: and a1, a2, a1
338 ; RV64IM-NEXT: or a0, a0, a1
341 ; RV64IMXVTCONDOPS-LABEL: select_or_b:
342 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
343 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
344 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a1, a2
345 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
346 ; RV64IMXVTCONDOPS-NEXT: ret
348 ; CHECKZICOND-LABEL: select_or_b:
349 ; CHECKZICOND: # %bb.0: # %entry
350 ; CHECKZICOND-NEXT: andi a2, a2, 1
351 ; CHECKZICOND-NEXT: czero.eqz a1, a1, a2
352 ; CHECKZICOND-NEXT: or a0, a0, a1
353 ; CHECKZICOND-NEXT: ret
355 %and = and i8 %cond, 1
356 %cmp10 = icmp ne i8 %and, 1
358 %1 = select i1 %cmp10, i32 %A, i32 %0
362 define i32 @select_or_1(i32 %A, i32 %B, i32 %cond) {
363 ; CHECK32-LABEL: select_or_1:
364 ; CHECK32: # %bb.0: # %entry
365 ; CHECK32-NEXT: slli a2, a2, 31
366 ; CHECK32-NEXT: srai a2, a2, 31
367 ; CHECK32-NEXT: and a1, a2, a1
368 ; CHECK32-NEXT: or a0, a0, a1
371 ; CHECK64-LABEL: select_or_1:
372 ; CHECK64: # %bb.0: # %entry
373 ; CHECK64-NEXT: slli a2, a2, 63
374 ; CHECK64-NEXT: srai a2, a2, 63
375 ; CHECK64-NEXT: and a1, a2, a1
376 ; CHECK64-NEXT: or a0, a0, a1
379 %and = and i32 %cond, 1
380 %cmp10 = icmp eq i32 %and, 0
382 %1 = select i1 %cmp10, i32 %A, i32 %0
386 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
387 ; icmp eq (and %cond, 1), 0
388 define i32 @select_or_1b(i32 %A, i32 %B, i32 %cond) {
389 ; RV32IM-LABEL: select_or_1b:
390 ; RV32IM: # %bb.0: # %entry
391 ; RV32IM-NEXT: slli a2, a2, 31
392 ; RV32IM-NEXT: srai a2, a2, 31
393 ; RV32IM-NEXT: and a1, a2, a1
394 ; RV32IM-NEXT: or a0, a0, a1
397 ; RV64IM-LABEL: select_or_1b:
398 ; RV64IM: # %bb.0: # %entry
399 ; RV64IM-NEXT: slli a2, a2, 63
400 ; RV64IM-NEXT: srai a2, a2, 63
401 ; RV64IM-NEXT: and a1, a2, a1
402 ; RV64IM-NEXT: or a0, a0, a1
405 ; RV64IMXVTCONDOPS-LABEL: select_or_1b:
406 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
407 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
408 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a1, a2
409 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
410 ; RV64IMXVTCONDOPS-NEXT: ret
412 ; CHECKZICOND-LABEL: select_or_1b:
413 ; CHECKZICOND: # %bb.0: # %entry
414 ; CHECKZICOND-NEXT: andi a2, a2, 1
415 ; CHECKZICOND-NEXT: czero.eqz a1, a1, a2
416 ; CHECKZICOND-NEXT: or a0, a0, a1
417 ; CHECKZICOND-NEXT: ret
419 %and = and i32 %cond, 1
420 %cmp10 = icmp ne i32 %and, 1
422 %1 = select i1 %cmp10, i32 %A, i32 %0
426 define i32 @select_or_2(i32 %A, i32 %B, i8 %cond) {
427 ; RV32IM-LABEL: select_or_2:
428 ; RV32IM: # %bb.0: # %entry
429 ; RV32IM-NEXT: andi a2, a2, 1
430 ; RV32IM-NEXT: addi a2, a2, -1
431 ; RV32IM-NEXT: and a1, a2, a1
432 ; RV32IM-NEXT: or a0, a0, a1
435 ; RV64IM-LABEL: select_or_2:
436 ; RV64IM: # %bb.0: # %entry
437 ; RV64IM-NEXT: andi a2, a2, 1
438 ; RV64IM-NEXT: addi a2, a2, -1
439 ; RV64IM-NEXT: and a1, a2, a1
440 ; RV64IM-NEXT: or a0, a0, a1
443 ; RV64IMXVTCONDOPS-LABEL: select_or_2:
444 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
445 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
446 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
447 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
448 ; RV64IMXVTCONDOPS-NEXT: ret
450 ; CHECKZICOND-LABEL: select_or_2:
451 ; CHECKZICOND: # %bb.0: # %entry
452 ; CHECKZICOND-NEXT: andi a2, a2, 1
453 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
454 ; CHECKZICOND-NEXT: or a0, a0, a1
455 ; CHECKZICOND-NEXT: ret
457 %and = and i8 %cond, 1
458 %cmp10 = icmp eq i8 %and, 0
460 %1 = select i1 %cmp10, i32 %0, i32 %A
464 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
465 ; icmp eq (and %cond, 1), 0
466 define i32 @select_or_2b(i32 %A, i32 %B, i8 %cond) {
467 ; RV32IM-LABEL: select_or_2b:
468 ; RV32IM: # %bb.0: # %entry
469 ; RV32IM-NEXT: andi a2, a2, 1
470 ; RV32IM-NEXT: addi a2, a2, -1
471 ; RV32IM-NEXT: and a1, a2, a1
472 ; RV32IM-NEXT: or a0, a0, a1
475 ; RV64IM-LABEL: select_or_2b:
476 ; RV64IM: # %bb.0: # %entry
477 ; RV64IM-NEXT: andi a2, a2, 1
478 ; RV64IM-NEXT: addi a2, a2, -1
479 ; RV64IM-NEXT: and a1, a2, a1
480 ; RV64IM-NEXT: or a0, a0, a1
483 ; RV64IMXVTCONDOPS-LABEL: select_or_2b:
484 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
485 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
486 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
487 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
488 ; RV64IMXVTCONDOPS-NEXT: ret
490 ; CHECKZICOND-LABEL: select_or_2b:
491 ; CHECKZICOND: # %bb.0: # %entry
492 ; CHECKZICOND-NEXT: andi a2, a2, 1
493 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
494 ; CHECKZICOND-NEXT: or a0, a0, a1
495 ; CHECKZICOND-NEXT: ret
497 %and = and i8 %cond, 1
498 %cmp10 = icmp ne i8 %and, 1
500 %1 = select i1 %cmp10, i32 %0, i32 %A
504 define i32 @select_or_3(i32 %A, i32 %B, i32 %cond) {
505 ; RV32IM-LABEL: select_or_3:
506 ; RV32IM: # %bb.0: # %entry
507 ; RV32IM-NEXT: andi a2, a2, 1
508 ; RV32IM-NEXT: addi a2, a2, -1
509 ; RV32IM-NEXT: and a1, a2, a1
510 ; RV32IM-NEXT: or a0, a0, a1
513 ; RV64IM-LABEL: select_or_3:
514 ; RV64IM: # %bb.0: # %entry
515 ; RV64IM-NEXT: andi a2, a2, 1
516 ; RV64IM-NEXT: addi a2, a2, -1
517 ; RV64IM-NEXT: and a1, a2, a1
518 ; RV64IM-NEXT: or a0, a0, a1
521 ; RV64IMXVTCONDOPS-LABEL: select_or_3:
522 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
523 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
524 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
525 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
526 ; RV64IMXVTCONDOPS-NEXT: ret
528 ; CHECKZICOND-LABEL: select_or_3:
529 ; CHECKZICOND: # %bb.0: # %entry
530 ; CHECKZICOND-NEXT: andi a2, a2, 1
531 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
532 ; CHECKZICOND-NEXT: or a0, a0, a1
533 ; CHECKZICOND-NEXT: ret
535 %and = and i32 %cond, 1
536 %cmp10 = icmp eq i32 %and, 0
538 %1 = select i1 %cmp10, i32 %0, i32 %A
542 ; Equivalent to above, but with icmp ne (and %cond, 1), 1 instead of
543 ; icmp eq (and %cond, 1), 0
544 define i32 @select_or_3b(i32 %A, i32 %B, i32 %cond) {
545 ; RV32IM-LABEL: select_or_3b:
546 ; RV32IM: # %bb.0: # %entry
547 ; RV32IM-NEXT: andi a2, a2, 1
548 ; RV32IM-NEXT: addi a2, a2, -1
549 ; RV32IM-NEXT: and a1, a2, a1
550 ; RV32IM-NEXT: or a0, a0, a1
553 ; RV64IM-LABEL: select_or_3b:
554 ; RV64IM: # %bb.0: # %entry
555 ; RV64IM-NEXT: andi a2, a2, 1
556 ; RV64IM-NEXT: addi a2, a2, -1
557 ; RV64IM-NEXT: and a1, a2, a1
558 ; RV64IM-NEXT: or a0, a0, a1
561 ; RV64IMXVTCONDOPS-LABEL: select_or_3b:
562 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
563 ; RV64IMXVTCONDOPS-NEXT: andi a2, a2, 1
564 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a1, a1, a2
565 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a1
566 ; RV64IMXVTCONDOPS-NEXT: ret
568 ; CHECKZICOND-LABEL: select_or_3b:
569 ; CHECKZICOND: # %bb.0: # %entry
570 ; CHECKZICOND-NEXT: andi a2, a2, 1
571 ; CHECKZICOND-NEXT: czero.nez a1, a1, a2
572 ; CHECKZICOND-NEXT: or a0, a0, a1
573 ; CHECKZICOND-NEXT: ret
575 %and = and i32 %cond, 1
576 %cmp10 = icmp ne i32 %and, 1
578 %1 = select i1 %cmp10, i32 %0, i32 %A
582 define i32 @select_add_1(i1 zeroext %cond, i32 %a, i32 %b) {
583 ; RV32IM-LABEL: select_add_1:
584 ; RV32IM: # %bb.0: # %entry
585 ; RV32IM-NEXT: neg a0, a0
586 ; RV32IM-NEXT: and a0, a0, a1
587 ; RV32IM-NEXT: add a0, a2, a0
590 ; RV64IM-LABEL: select_add_1:
591 ; RV64IM: # %bb.0: # %entry
592 ; RV64IM-NEXT: negw a0, a0
593 ; RV64IM-NEXT: and a0, a0, a1
594 ; RV64IM-NEXT: addw a0, a2, a0
597 ; RV64IMXVTCONDOPS-LABEL: select_add_1:
598 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
599 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
600 ; RV64IMXVTCONDOPS-NEXT: addw a0, a2, a0
601 ; RV64IMXVTCONDOPS-NEXT: ret
603 ; RV32IMZICOND-LABEL: select_add_1:
604 ; RV32IMZICOND: # %bb.0: # %entry
605 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
606 ; RV32IMZICOND-NEXT: add a0, a2, a0
607 ; RV32IMZICOND-NEXT: ret
609 ; RV64IMZICOND-LABEL: select_add_1:
610 ; RV64IMZICOND: # %bb.0: # %entry
611 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
612 ; RV64IMZICOND-NEXT: addw a0, a2, a0
613 ; RV64IMZICOND-NEXT: ret
616 %res = select i1 %cond, i32 %c, i32 %b
620 define i32 @select_add_2(i1 zeroext %cond, i32 %a, i32 %b) {
621 ; RV32IM-LABEL: select_add_2:
622 ; RV32IM: # %bb.0: # %entry
623 ; RV32IM-NEXT: addi a0, a0, -1
624 ; RV32IM-NEXT: and a0, a0, a2
625 ; RV32IM-NEXT: add a0, a1, a0
628 ; RV64IM-LABEL: select_add_2:
629 ; RV64IM: # %bb.0: # %entry
630 ; RV64IM-NEXT: addi a0, a0, -1
631 ; RV64IM-NEXT: and a0, a0, a2
632 ; RV64IM-NEXT: addw a0, a1, a0
635 ; RV64IMXVTCONDOPS-LABEL: select_add_2:
636 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
637 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
638 ; RV64IMXVTCONDOPS-NEXT: addw a0, a1, a0
639 ; RV64IMXVTCONDOPS-NEXT: ret
641 ; RV32IMZICOND-LABEL: select_add_2:
642 ; RV32IMZICOND: # %bb.0: # %entry
643 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
644 ; RV32IMZICOND-NEXT: add a0, a1, a0
645 ; RV32IMZICOND-NEXT: ret
647 ; RV64IMZICOND-LABEL: select_add_2:
648 ; RV64IMZICOND: # %bb.0: # %entry
649 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
650 ; RV64IMZICOND-NEXT: addw a0, a1, a0
651 ; RV64IMZICOND-NEXT: ret
654 %res = select i1 %cond, i32 %a, i32 %c
658 define i32 @select_add_3(i1 zeroext %cond, i32 %a) {
659 ; RV32IM-LABEL: select_add_3:
660 ; RV32IM: # %bb.0: # %entry
661 ; RV32IM-NEXT: addi a0, a0, -1
662 ; RV32IM-NEXT: andi a0, a0, 42
663 ; RV32IM-NEXT: add a0, a1, a0
666 ; RV64IM-LABEL: select_add_3:
667 ; RV64IM: # %bb.0: # %entry
668 ; RV64IM-NEXT: addi a0, a0, -1
669 ; RV64IM-NEXT: andi a0, a0, 42
670 ; RV64IM-NEXT: addw a0, a1, a0
673 ; RV64IMXVTCONDOPS-LABEL: select_add_3:
674 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
675 ; RV64IMXVTCONDOPS-NEXT: li a2, 42
676 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
677 ; RV64IMXVTCONDOPS-NEXT: addw a0, a1, a0
678 ; RV64IMXVTCONDOPS-NEXT: ret
680 ; RV32IMZICOND-LABEL: select_add_3:
681 ; RV32IMZICOND: # %bb.0: # %entry
682 ; RV32IMZICOND-NEXT: li a2, 42
683 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
684 ; RV32IMZICOND-NEXT: add a0, a1, a0
685 ; RV32IMZICOND-NEXT: ret
687 ; RV64IMZICOND-LABEL: select_add_3:
688 ; RV64IMZICOND: # %bb.0: # %entry
689 ; RV64IMZICOND-NEXT: li a2, 42
690 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
691 ; RV64IMZICOND-NEXT: addw a0, a1, a0
692 ; RV64IMZICOND-NEXT: ret
695 %res = select i1 %cond, i32 %a, i32 %c
699 define i32 @select_sub_1(i1 zeroext %cond, i32 %a, i32 %b) {
700 ; RV32IM-LABEL: select_sub_1:
701 ; RV32IM: # %bb.0: # %entry
702 ; RV32IM-NEXT: beqz a0, .LBB19_2
703 ; RV32IM-NEXT: # %bb.1:
704 ; RV32IM-NEXT: sub a2, a1, a2
705 ; RV32IM-NEXT: .LBB19_2: # %entry
706 ; RV32IM-NEXT: mv a0, a2
709 ; RV64IM-LABEL: select_sub_1:
710 ; RV64IM: # %bb.0: # %entry
711 ; RV64IM-NEXT: beqz a0, .LBB19_2
712 ; RV64IM-NEXT: # %bb.1:
713 ; RV64IM-NEXT: subw a2, a1, a2
714 ; RV64IM-NEXT: .LBB19_2: # %entry
715 ; RV64IM-NEXT: mv a0, a2
718 ; RV64IMXVTCONDOPS-LABEL: select_sub_1:
719 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
720 ; RV64IMXVTCONDOPS-NEXT: subw a1, a1, a2
721 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a2, a2, a0
722 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
723 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a2
724 ; RV64IMXVTCONDOPS-NEXT: ret
726 ; RV32IMZICOND-LABEL: select_sub_1:
727 ; RV32IMZICOND: # %bb.0: # %entry
728 ; RV32IMZICOND-NEXT: sub a1, a1, a2
729 ; RV32IMZICOND-NEXT: czero.nez a2, a2, a0
730 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
731 ; RV32IMZICOND-NEXT: or a0, a0, a2
732 ; RV32IMZICOND-NEXT: ret
734 ; RV64IMZICOND-LABEL: select_sub_1:
735 ; RV64IMZICOND: # %bb.0: # %entry
736 ; RV64IMZICOND-NEXT: subw a1, a1, a2
737 ; RV64IMZICOND-NEXT: czero.nez a2, a2, a0
738 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
739 ; RV64IMZICOND-NEXT: or a0, a0, a2
740 ; RV64IMZICOND-NEXT: ret
743 %res = select i1 %cond, i32 %c, i32 %b
747 define i32 @select_sub_2(i1 zeroext %cond, i32 %a, i32 %b) {
748 ; RV32IM-LABEL: select_sub_2:
749 ; RV32IM: # %bb.0: # %entry
750 ; RV32IM-NEXT: addi a0, a0, -1
751 ; RV32IM-NEXT: and a0, a0, a2
752 ; RV32IM-NEXT: sub a0, a1, a0
755 ; RV64IM-LABEL: select_sub_2:
756 ; RV64IM: # %bb.0: # %entry
757 ; RV64IM-NEXT: addi a0, a0, -1
758 ; RV64IM-NEXT: and a0, a0, a2
759 ; RV64IM-NEXT: subw a0, a1, a0
762 ; RV64IMXVTCONDOPS-LABEL: select_sub_2:
763 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
764 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
765 ; RV64IMXVTCONDOPS-NEXT: subw a0, a1, a0
766 ; RV64IMXVTCONDOPS-NEXT: ret
768 ; RV32IMZICOND-LABEL: select_sub_2:
769 ; RV32IMZICOND: # %bb.0: # %entry
770 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
771 ; RV32IMZICOND-NEXT: sub a0, a1, a0
772 ; RV32IMZICOND-NEXT: ret
774 ; RV64IMZICOND-LABEL: select_sub_2:
775 ; RV64IMZICOND: # %bb.0: # %entry
776 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
777 ; RV64IMZICOND-NEXT: subw a0, a1, a0
778 ; RV64IMZICOND-NEXT: ret
781 %res = select i1 %cond, i32 %a, i32 %c
785 define i32 @select_sub_3(i1 zeroext %cond, i32 %a) {
786 ; RV32IM-LABEL: select_sub_3:
787 ; RV32IM: # %bb.0: # %entry
788 ; RV32IM-NEXT: addi a0, a0, -1
789 ; RV32IM-NEXT: andi a0, a0, 42
790 ; RV32IM-NEXT: sub a0, a1, a0
793 ; RV64IM-LABEL: select_sub_3:
794 ; RV64IM: # %bb.0: # %entry
795 ; RV64IM-NEXT: addi a0, a0, -1
796 ; RV64IM-NEXT: andi a0, a0, 42
797 ; RV64IM-NEXT: subw a0, a1, a0
800 ; RV64IMXVTCONDOPS-LABEL: select_sub_3:
801 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
802 ; RV64IMXVTCONDOPS-NEXT: li a2, 42
803 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
804 ; RV64IMXVTCONDOPS-NEXT: subw a0, a1, a0
805 ; RV64IMXVTCONDOPS-NEXT: ret
807 ; RV32IMZICOND-LABEL: select_sub_3:
808 ; RV32IMZICOND: # %bb.0: # %entry
809 ; RV32IMZICOND-NEXT: li a2, 42
810 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
811 ; RV32IMZICOND-NEXT: sub a0, a1, a0
812 ; RV32IMZICOND-NEXT: ret
814 ; RV64IMZICOND-LABEL: select_sub_3:
815 ; RV64IMZICOND: # %bb.0: # %entry
816 ; RV64IMZICOND-NEXT: li a2, 42
817 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
818 ; RV64IMZICOND-NEXT: subw a0, a1, a0
819 ; RV64IMZICOND-NEXT: ret
822 %res = select i1 %cond, i32 %a, i32 %c
826 define i32 @select_and_1(i1 zeroext %cond, i32 %a, i32 %b) {
827 ; RV32IM-LABEL: select_and_1:
828 ; RV32IM: # %bb.0: # %entry
829 ; RV32IM-NEXT: beqz a0, .LBB22_2
830 ; RV32IM-NEXT: # %bb.1:
831 ; RV32IM-NEXT: and a2, a1, a2
832 ; RV32IM-NEXT: .LBB22_2: # %entry
833 ; RV32IM-NEXT: mv a0, a2
836 ; RV64IM-LABEL: select_and_1:
837 ; RV64IM: # %bb.0: # %entry
838 ; RV64IM-NEXT: beqz a0, .LBB22_2
839 ; RV64IM-NEXT: # %bb.1:
840 ; RV64IM-NEXT: and a2, a1, a2
841 ; RV64IM-NEXT: .LBB22_2: # %entry
842 ; RV64IM-NEXT: mv a0, a2
845 ; RV64IMXVTCONDOPS-LABEL: select_and_1:
846 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
847 ; RV64IMXVTCONDOPS-NEXT: and a1, a1, a2
848 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
849 ; RV64IMXVTCONDOPS-NEXT: or a0, a1, a0
850 ; RV64IMXVTCONDOPS-NEXT: ret
852 ; CHECKZICOND-LABEL: select_and_1:
853 ; CHECKZICOND: # %bb.0: # %entry
854 ; CHECKZICOND-NEXT: and a1, a1, a2
855 ; CHECKZICOND-NEXT: czero.nez a0, a2, a0
856 ; CHECKZICOND-NEXT: or a0, a1, a0
857 ; CHECKZICOND-NEXT: ret
860 %res = select i1 %cond, i32 %c, i32 %b
864 define i32 @select_and_2(i1 zeroext %cond, i32 %a, i32 %b) {
865 ; RV32IM-LABEL: select_and_2:
866 ; RV32IM: # %bb.0: # %entry
867 ; RV32IM-NEXT: bnez a0, .LBB23_2
868 ; RV32IM-NEXT: # %bb.1: # %entry
869 ; RV32IM-NEXT: and a1, a1, a2
870 ; RV32IM-NEXT: .LBB23_2: # %entry
871 ; RV32IM-NEXT: mv a0, a1
874 ; RV64IM-LABEL: select_and_2:
875 ; RV64IM: # %bb.0: # %entry
876 ; RV64IM-NEXT: bnez a0, .LBB23_2
877 ; RV64IM-NEXT: # %bb.1: # %entry
878 ; RV64IM-NEXT: and a1, a1, a2
879 ; RV64IM-NEXT: .LBB23_2: # %entry
880 ; RV64IM-NEXT: mv a0, a1
883 ; RV64IMXVTCONDOPS-LABEL: select_and_2:
884 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
885 ; RV64IMXVTCONDOPS-NEXT: and a2, a1, a2
886 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
887 ; RV64IMXVTCONDOPS-NEXT: or a0, a2, a0
888 ; RV64IMXVTCONDOPS-NEXT: ret
890 ; CHECKZICOND-LABEL: select_and_2:
891 ; CHECKZICOND: # %bb.0: # %entry
892 ; CHECKZICOND-NEXT: and a2, a1, a2
893 ; CHECKZICOND-NEXT: czero.eqz a0, a1, a0
894 ; CHECKZICOND-NEXT: or a0, a2, a0
895 ; CHECKZICOND-NEXT: ret
898 %res = select i1 %cond, i32 %a, i32 %c
902 define i32 @select_and_3(i1 zeroext %cond, i32 %a) {
903 ; RV32IM-LABEL: select_and_3:
904 ; RV32IM: # %bb.0: # %entry
905 ; RV32IM-NEXT: bnez a0, .LBB24_2
906 ; RV32IM-NEXT: # %bb.1: # %entry
907 ; RV32IM-NEXT: andi a1, a1, 42
908 ; RV32IM-NEXT: .LBB24_2: # %entry
909 ; RV32IM-NEXT: mv a0, a1
912 ; RV64IM-LABEL: select_and_3:
913 ; RV64IM: # %bb.0: # %entry
914 ; RV64IM-NEXT: bnez a0, .LBB24_2
915 ; RV64IM-NEXT: # %bb.1: # %entry
916 ; RV64IM-NEXT: andi a1, a1, 42
917 ; RV64IM-NEXT: .LBB24_2: # %entry
918 ; RV64IM-NEXT: mv a0, a1
921 ; RV64IMXVTCONDOPS-LABEL: select_and_3:
922 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
923 ; RV64IMXVTCONDOPS-NEXT: andi a2, a1, 42
924 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
925 ; RV64IMXVTCONDOPS-NEXT: or a0, a2, a0
926 ; RV64IMXVTCONDOPS-NEXT: ret
928 ; CHECKZICOND-LABEL: select_and_3:
929 ; CHECKZICOND: # %bb.0: # %entry
930 ; CHECKZICOND-NEXT: andi a2, a1, 42
931 ; CHECKZICOND-NEXT: czero.eqz a0, a1, a0
932 ; CHECKZICOND-NEXT: or a0, a2, a0
933 ; CHECKZICOND-NEXT: ret
936 %res = select i1 %cond, i32 %a, i32 %c
940 define i32 @select_udiv_1(i1 zeroext %cond, i32 %a, i32 %b) {
941 ; RV32IM-LABEL: select_udiv_1:
942 ; RV32IM: # %bb.0: # %entry
943 ; RV32IM-NEXT: beqz a0, .LBB25_2
944 ; RV32IM-NEXT: # %bb.1:
945 ; RV32IM-NEXT: divu a2, a1, a2
946 ; RV32IM-NEXT: .LBB25_2: # %entry
947 ; RV32IM-NEXT: mv a0, a2
950 ; RV64IM-LABEL: select_udiv_1:
951 ; RV64IM: # %bb.0: # %entry
952 ; RV64IM-NEXT: beqz a0, .LBB25_2
953 ; RV64IM-NEXT: # %bb.1:
954 ; RV64IM-NEXT: divuw a2, a1, a2
955 ; RV64IM-NEXT: .LBB25_2: # %entry
956 ; RV64IM-NEXT: mv a0, a2
959 ; RV64IMXVTCONDOPS-LABEL: select_udiv_1:
960 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
961 ; RV64IMXVTCONDOPS-NEXT: divuw a1, a1, a2
962 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a2, a2, a0
963 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
964 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a2
965 ; RV64IMXVTCONDOPS-NEXT: ret
967 ; RV32IMZICOND-LABEL: select_udiv_1:
968 ; RV32IMZICOND: # %bb.0: # %entry
969 ; RV32IMZICOND-NEXT: divu a1, a1, a2
970 ; RV32IMZICOND-NEXT: czero.nez a2, a2, a0
971 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
972 ; RV32IMZICOND-NEXT: or a0, a0, a2
973 ; RV32IMZICOND-NEXT: ret
975 ; RV64IMZICOND-LABEL: select_udiv_1:
976 ; RV64IMZICOND: # %bb.0: # %entry
977 ; RV64IMZICOND-NEXT: divuw a1, a1, a2
978 ; RV64IMZICOND-NEXT: czero.nez a2, a2, a0
979 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
980 ; RV64IMZICOND-NEXT: or a0, a0, a2
981 ; RV64IMZICOND-NEXT: ret
984 %res = select i1 %cond, i32 %c, i32 %b
988 define i32 @select_udiv_2(i1 zeroext %cond, i32 %a, i32 %b) {
989 ; RV32IM-LABEL: select_udiv_2:
990 ; RV32IM: # %bb.0: # %entry
991 ; RV32IM-NEXT: bnez a0, .LBB26_2
992 ; RV32IM-NEXT: # %bb.1: # %entry
993 ; RV32IM-NEXT: divu a1, a1, a2
994 ; RV32IM-NEXT: .LBB26_2: # %entry
995 ; RV32IM-NEXT: mv a0, a1
998 ; RV64IM-LABEL: select_udiv_2:
999 ; RV64IM: # %bb.0: # %entry
1000 ; RV64IM-NEXT: bnez a0, .LBB26_2
1001 ; RV64IM-NEXT: # %bb.1: # %entry
1002 ; RV64IM-NEXT: divuw a1, a1, a2
1003 ; RV64IM-NEXT: .LBB26_2: # %entry
1004 ; RV64IM-NEXT: mv a0, a1
1007 ; RV64IMXVTCONDOPS-LABEL: select_udiv_2:
1008 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1009 ; RV64IMXVTCONDOPS-NEXT: divuw a2, a1, a2
1010 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a1, a0
1011 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
1012 ; RV64IMXVTCONDOPS-NEXT: or a0, a1, a0
1013 ; RV64IMXVTCONDOPS-NEXT: ret
1015 ; RV32IMZICOND-LABEL: select_udiv_2:
1016 ; RV32IMZICOND: # %bb.0: # %entry
1017 ; RV32IMZICOND-NEXT: divu a2, a1, a2
1018 ; RV32IMZICOND-NEXT: czero.eqz a1, a1, a0
1019 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
1020 ; RV32IMZICOND-NEXT: or a0, a1, a0
1021 ; RV32IMZICOND-NEXT: ret
1023 ; RV64IMZICOND-LABEL: select_udiv_2:
1024 ; RV64IMZICOND: # %bb.0: # %entry
1025 ; RV64IMZICOND-NEXT: divuw a2, a1, a2
1026 ; RV64IMZICOND-NEXT: czero.eqz a1, a1, a0
1027 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
1028 ; RV64IMZICOND-NEXT: or a0, a1, a0
1029 ; RV64IMZICOND-NEXT: ret
1031 %c = udiv i32 %a, %b
1032 %res = select i1 %cond, i32 %a, i32 %c
1036 define i32 @select_udiv_3(i1 zeroext %cond, i32 %a) {
1037 ; RV32IM-LABEL: select_udiv_3:
1038 ; RV32IM: # %bb.0: # %entry
1039 ; RV32IM-NEXT: bnez a0, .LBB27_2
1040 ; RV32IM-NEXT: # %bb.1: # %entry
1041 ; RV32IM-NEXT: srli a1, a1, 1
1042 ; RV32IM-NEXT: lui a0, 199729
1043 ; RV32IM-NEXT: addi a0, a0, -975
1044 ; RV32IM-NEXT: mulhu a1, a1, a0
1045 ; RV32IM-NEXT: srli a1, a1, 2
1046 ; RV32IM-NEXT: .LBB27_2: # %entry
1047 ; RV32IM-NEXT: mv a0, a1
1050 ; RV64IM-LABEL: select_udiv_3:
1051 ; RV64IM: # %bb.0: # %entry
1052 ; RV64IM-NEXT: bnez a0, .LBB27_2
1053 ; RV64IM-NEXT: # %bb.1: # %entry
1054 ; RV64IM-NEXT: srliw a0, a1, 1
1055 ; RV64IM-NEXT: lui a1, 199729
1056 ; RV64IM-NEXT: addiw a1, a1, -975
1057 ; RV64IM-NEXT: mul a1, a0, a1
1058 ; RV64IM-NEXT: srli a1, a1, 34
1059 ; RV64IM-NEXT: .LBB27_2: # %entry
1060 ; RV64IM-NEXT: mv a0, a1
1063 ; RV64IMXVTCONDOPS-LABEL: select_udiv_3:
1064 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1065 ; RV64IMXVTCONDOPS-NEXT: srliw a2, a1, 1
1066 ; RV64IMXVTCONDOPS-NEXT: lui a3, 199729
1067 ; RV64IMXVTCONDOPS-NEXT: addiw a3, a3, -975
1068 ; RV64IMXVTCONDOPS-NEXT: mul a2, a2, a3
1069 ; RV64IMXVTCONDOPS-NEXT: srli a2, a2, 34
1070 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a1, a1, a0
1071 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
1072 ; RV64IMXVTCONDOPS-NEXT: or a0, a1, a0
1073 ; RV64IMXVTCONDOPS-NEXT: ret
1075 ; RV32IMZICOND-LABEL: select_udiv_3:
1076 ; RV32IMZICOND: # %bb.0: # %entry
1077 ; RV32IMZICOND-NEXT: srli a2, a1, 1
1078 ; RV32IMZICOND-NEXT: lui a3, 199729
1079 ; RV32IMZICOND-NEXT: addi a3, a3, -975
1080 ; RV32IMZICOND-NEXT: mulhu a2, a2, a3
1081 ; RV32IMZICOND-NEXT: srli a2, a2, 2
1082 ; RV32IMZICOND-NEXT: czero.eqz a1, a1, a0
1083 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
1084 ; RV32IMZICOND-NEXT: or a0, a1, a0
1085 ; RV32IMZICOND-NEXT: ret
1087 ; RV64IMZICOND-LABEL: select_udiv_3:
1088 ; RV64IMZICOND: # %bb.0: # %entry
1089 ; RV64IMZICOND-NEXT: srliw a2, a1, 1
1090 ; RV64IMZICOND-NEXT: lui a3, 199729
1091 ; RV64IMZICOND-NEXT: addiw a3, a3, -975
1092 ; RV64IMZICOND-NEXT: mul a2, a2, a3
1093 ; RV64IMZICOND-NEXT: srli a2, a2, 34
1094 ; RV64IMZICOND-NEXT: czero.eqz a1, a1, a0
1095 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
1096 ; RV64IMZICOND-NEXT: or a0, a1, a0
1097 ; RV64IMZICOND-NEXT: ret
1099 %c = udiv i32 %a, 42
1100 %res = select i1 %cond, i32 %a, i32 %c
1104 define i32 @select_shl_1(i1 zeroext %cond, i32 %a, i32 %b) {
1105 ; RV32IM-LABEL: select_shl_1:
1106 ; RV32IM: # %bb.0: # %entry
1107 ; RV32IM-NEXT: beqz a0, .LBB28_2
1108 ; RV32IM-NEXT: # %bb.1:
1109 ; RV32IM-NEXT: sll a2, a1, a2
1110 ; RV32IM-NEXT: .LBB28_2: # %entry
1111 ; RV32IM-NEXT: mv a0, a2
1114 ; RV64IM-LABEL: select_shl_1:
1115 ; RV64IM: # %bb.0: # %entry
1116 ; RV64IM-NEXT: beqz a0, .LBB28_2
1117 ; RV64IM-NEXT: # %bb.1:
1118 ; RV64IM-NEXT: sllw a2, a1, a2
1119 ; RV64IM-NEXT: .LBB28_2: # %entry
1120 ; RV64IM-NEXT: mv a0, a2
1123 ; RV64IMXVTCONDOPS-LABEL: select_shl_1:
1124 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1125 ; RV64IMXVTCONDOPS-NEXT: sllw a1, a1, a2
1126 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a2, a2, a0
1127 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
1128 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a2
1129 ; RV64IMXVTCONDOPS-NEXT: ret
1131 ; RV32IMZICOND-LABEL: select_shl_1:
1132 ; RV32IMZICOND: # %bb.0: # %entry
1133 ; RV32IMZICOND-NEXT: sll a1, a1, a2
1134 ; RV32IMZICOND-NEXT: czero.nez a2, a2, a0
1135 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
1136 ; RV32IMZICOND-NEXT: or a0, a0, a2
1137 ; RV32IMZICOND-NEXT: ret
1139 ; RV64IMZICOND-LABEL: select_shl_1:
1140 ; RV64IMZICOND: # %bb.0: # %entry
1141 ; RV64IMZICOND-NEXT: sllw a1, a1, a2
1142 ; RV64IMZICOND-NEXT: czero.nez a2, a2, a0
1143 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
1144 ; RV64IMZICOND-NEXT: or a0, a0, a2
1145 ; RV64IMZICOND-NEXT: ret
1148 %res = select i1 %cond, i32 %c, i32 %b
1152 define i32 @select_shl_2(i1 zeroext %cond, i32 %a, i32 %b) {
1153 ; RV32IM-LABEL: select_shl_2:
1154 ; RV32IM: # %bb.0: # %entry
1155 ; RV32IM-NEXT: addi a0, a0, -1
1156 ; RV32IM-NEXT: and a0, a0, a2
1157 ; RV32IM-NEXT: sll a0, a1, a0
1160 ; RV64IM-LABEL: select_shl_2:
1161 ; RV64IM: # %bb.0: # %entry
1162 ; RV64IM-NEXT: addi a0, a0, -1
1163 ; RV64IM-NEXT: and a0, a0, a2
1164 ; RV64IM-NEXT: sllw a0, a1, a0
1167 ; RV64IMXVTCONDOPS-LABEL: select_shl_2:
1168 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1169 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
1170 ; RV64IMXVTCONDOPS-NEXT: sllw a0, a1, a0
1171 ; RV64IMXVTCONDOPS-NEXT: ret
1173 ; RV32IMZICOND-LABEL: select_shl_2:
1174 ; RV32IMZICOND: # %bb.0: # %entry
1175 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
1176 ; RV32IMZICOND-NEXT: sll a0, a1, a0
1177 ; RV32IMZICOND-NEXT: ret
1179 ; RV64IMZICOND-LABEL: select_shl_2:
1180 ; RV64IMZICOND: # %bb.0: # %entry
1181 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
1182 ; RV64IMZICOND-NEXT: sllw a0, a1, a0
1183 ; RV64IMZICOND-NEXT: ret
1186 %res = select i1 %cond, i32 %a, i32 %c
1190 define i32 @select_shl_3(i1 zeroext %cond, i32 %a) {
1191 ; CHECK-LABEL: select_shl_3:
1192 ; CHECK: # %bb.0: # %entry
1193 ; CHECK-NEXT: mv a0, a1
1197 %res = select i1 %cond, i32 %a, i32 %c
1201 define i32 @select_ashr_1(i1 zeroext %cond, i32 %a, i32 %b) {
1202 ; RV32IM-LABEL: select_ashr_1:
1203 ; RV32IM: # %bb.0: # %entry
1204 ; RV32IM-NEXT: beqz a0, .LBB31_2
1205 ; RV32IM-NEXT: # %bb.1:
1206 ; RV32IM-NEXT: sra a2, a1, a2
1207 ; RV32IM-NEXT: .LBB31_2: # %entry
1208 ; RV32IM-NEXT: mv a0, a2
1211 ; RV64IM-LABEL: select_ashr_1:
1212 ; RV64IM: # %bb.0: # %entry
1213 ; RV64IM-NEXT: beqz a0, .LBB31_2
1214 ; RV64IM-NEXT: # %bb.1:
1215 ; RV64IM-NEXT: sraw a2, a1, a2
1216 ; RV64IM-NEXT: .LBB31_2: # %entry
1217 ; RV64IM-NEXT: mv a0, a2
1220 ; RV64IMXVTCONDOPS-LABEL: select_ashr_1:
1221 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1222 ; RV64IMXVTCONDOPS-NEXT: sraw a1, a1, a2
1223 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a2, a2, a0
1224 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
1225 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a2
1226 ; RV64IMXVTCONDOPS-NEXT: ret
1228 ; RV32IMZICOND-LABEL: select_ashr_1:
1229 ; RV32IMZICOND: # %bb.0: # %entry
1230 ; RV32IMZICOND-NEXT: sra a1, a1, a2
1231 ; RV32IMZICOND-NEXT: czero.nez a2, a2, a0
1232 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
1233 ; RV32IMZICOND-NEXT: or a0, a0, a2
1234 ; RV32IMZICOND-NEXT: ret
1236 ; RV64IMZICOND-LABEL: select_ashr_1:
1237 ; RV64IMZICOND: # %bb.0: # %entry
1238 ; RV64IMZICOND-NEXT: sraw a1, a1, a2
1239 ; RV64IMZICOND-NEXT: czero.nez a2, a2, a0
1240 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
1241 ; RV64IMZICOND-NEXT: or a0, a0, a2
1242 ; RV64IMZICOND-NEXT: ret
1244 %c = ashr i32 %a, %b
1245 %res = select i1 %cond, i32 %c, i32 %b
1249 define i32 @select_ashr_2(i1 zeroext %cond, i32 %a, i32 %b) {
1250 ; RV32IM-LABEL: select_ashr_2:
1251 ; RV32IM: # %bb.0: # %entry
1252 ; RV32IM-NEXT: addi a0, a0, -1
1253 ; RV32IM-NEXT: and a0, a0, a2
1254 ; RV32IM-NEXT: sra a0, a1, a0
1257 ; RV64IM-LABEL: select_ashr_2:
1258 ; RV64IM: # %bb.0: # %entry
1259 ; RV64IM-NEXT: addi a0, a0, -1
1260 ; RV64IM-NEXT: and a0, a0, a2
1261 ; RV64IM-NEXT: sraw a0, a1, a0
1264 ; RV64IMXVTCONDOPS-LABEL: select_ashr_2:
1265 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1266 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
1267 ; RV64IMXVTCONDOPS-NEXT: sraw a0, a1, a0
1268 ; RV64IMXVTCONDOPS-NEXT: ret
1270 ; RV32IMZICOND-LABEL: select_ashr_2:
1271 ; RV32IMZICOND: # %bb.0: # %entry
1272 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
1273 ; RV32IMZICOND-NEXT: sra a0, a1, a0
1274 ; RV32IMZICOND-NEXT: ret
1276 ; RV64IMZICOND-LABEL: select_ashr_2:
1277 ; RV64IMZICOND: # %bb.0: # %entry
1278 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
1279 ; RV64IMZICOND-NEXT: sraw a0, a1, a0
1280 ; RV64IMZICOND-NEXT: ret
1282 %c = ashr i32 %a, %b
1283 %res = select i1 %cond, i32 %a, i32 %c
1287 define i32 @select_ashr_3(i1 zeroext %cond, i32 %a) {
1288 ; CHECK-LABEL: select_ashr_3:
1289 ; CHECK: # %bb.0: # %entry
1290 ; CHECK-NEXT: mv a0, a1
1293 %c = ashr i32 %a, 42
1294 %res = select i1 %cond, i32 %a, i32 %c
1298 define i32 @select_lshr_1(i1 zeroext %cond, i32 %a, i32 %b) {
1299 ; RV32IM-LABEL: select_lshr_1:
1300 ; RV32IM: # %bb.0: # %entry
1301 ; RV32IM-NEXT: beqz a0, .LBB34_2
1302 ; RV32IM-NEXT: # %bb.1:
1303 ; RV32IM-NEXT: srl a2, a1, a2
1304 ; RV32IM-NEXT: .LBB34_2: # %entry
1305 ; RV32IM-NEXT: mv a0, a2
1308 ; RV64IM-LABEL: select_lshr_1:
1309 ; RV64IM: # %bb.0: # %entry
1310 ; RV64IM-NEXT: beqz a0, .LBB34_2
1311 ; RV64IM-NEXT: # %bb.1:
1312 ; RV64IM-NEXT: srlw a2, a1, a2
1313 ; RV64IM-NEXT: .LBB34_2: # %entry
1314 ; RV64IM-NEXT: mv a0, a2
1317 ; RV64IMXVTCONDOPS-LABEL: select_lshr_1:
1318 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1319 ; RV64IMXVTCONDOPS-NEXT: srlw a1, a1, a2
1320 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a2, a2, a0
1321 ; RV64IMXVTCONDOPS-NEXT: vt.maskc a0, a1, a0
1322 ; RV64IMXVTCONDOPS-NEXT: or a0, a0, a2
1323 ; RV64IMXVTCONDOPS-NEXT: ret
1325 ; RV32IMZICOND-LABEL: select_lshr_1:
1326 ; RV32IMZICOND: # %bb.0: # %entry
1327 ; RV32IMZICOND-NEXT: srl a1, a1, a2
1328 ; RV32IMZICOND-NEXT: czero.nez a2, a2, a0
1329 ; RV32IMZICOND-NEXT: czero.eqz a0, a1, a0
1330 ; RV32IMZICOND-NEXT: or a0, a0, a2
1331 ; RV32IMZICOND-NEXT: ret
1333 ; RV64IMZICOND-LABEL: select_lshr_1:
1334 ; RV64IMZICOND: # %bb.0: # %entry
1335 ; RV64IMZICOND-NEXT: srlw a1, a1, a2
1336 ; RV64IMZICOND-NEXT: czero.nez a2, a2, a0
1337 ; RV64IMZICOND-NEXT: czero.eqz a0, a1, a0
1338 ; RV64IMZICOND-NEXT: or a0, a0, a2
1339 ; RV64IMZICOND-NEXT: ret
1341 %c = lshr i32 %a, %b
1342 %res = select i1 %cond, i32 %c, i32 %b
1346 define i32 @select_lshr_2(i1 zeroext %cond, i32 %a, i32 %b) {
1347 ; RV32IM-LABEL: select_lshr_2:
1348 ; RV32IM: # %bb.0: # %entry
1349 ; RV32IM-NEXT: addi a0, a0, -1
1350 ; RV32IM-NEXT: and a0, a0, a2
1351 ; RV32IM-NEXT: srl a0, a1, a0
1354 ; RV64IM-LABEL: select_lshr_2:
1355 ; RV64IM: # %bb.0: # %entry
1356 ; RV64IM-NEXT: addi a0, a0, -1
1357 ; RV64IM-NEXT: and a0, a0, a2
1358 ; RV64IM-NEXT: srlw a0, a1, a0
1361 ; RV64IMXVTCONDOPS-LABEL: select_lshr_2:
1362 ; RV64IMXVTCONDOPS: # %bb.0: # %entry
1363 ; RV64IMXVTCONDOPS-NEXT: vt.maskcn a0, a2, a0
1364 ; RV64IMXVTCONDOPS-NEXT: srlw a0, a1, a0
1365 ; RV64IMXVTCONDOPS-NEXT: ret
1367 ; RV32IMZICOND-LABEL: select_lshr_2:
1368 ; RV32IMZICOND: # %bb.0: # %entry
1369 ; RV32IMZICOND-NEXT: czero.nez a0, a2, a0
1370 ; RV32IMZICOND-NEXT: srl a0, a1, a0
1371 ; RV32IMZICOND-NEXT: ret
1373 ; RV64IMZICOND-LABEL: select_lshr_2:
1374 ; RV64IMZICOND: # %bb.0: # %entry
1375 ; RV64IMZICOND-NEXT: czero.nez a0, a2, a0
1376 ; RV64IMZICOND-NEXT: srlw a0, a1, a0
1377 ; RV64IMZICOND-NEXT: ret
1379 %c = lshr i32 %a, %b
1380 %res = select i1 %cond, i32 %a, i32 %c
1384 define i32 @select_lshr_3(i1 zeroext %cond, i32 %a) {
1385 ; CHECK-LABEL: select_lshr_3:
1386 ; CHECK: # %bb.0: # %entry
1387 ; CHECK-NEXT: mv a0, a1
1390 %c = lshr i32 %a, 42
1391 %res = select i1 %cond, i32 %a, i32 %c