1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64I
4 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbt -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64ZBT
7 define signext i32 @cmix_i32(i32 signext %a, i32 signext %b, i32 signext %c) nounwind {
8 ; RV64I-LABEL: cmix_i32:
10 ; RV64I-NEXT: and a0, a1, a0
11 ; RV64I-NEXT: not a1, a1
12 ; RV64I-NEXT: and a1, a1, a2
13 ; RV64I-NEXT: or a0, a1, a0
16 ; RV64ZBT-LABEL: cmix_i32:
18 ; RV64ZBT-NEXT: cmix a0, a1, a0, a2
22 %and1 = and i32 %neg, %c
23 %or = or i32 %and1, %and
27 define signext i32 @cmix_i32_2(i32 signext %a, i32 signext %b, i32 signext %c) nounwind {
28 ; RV64I-LABEL: cmix_i32_2:
30 ; RV64I-NEXT: xor a0, a0, a2
31 ; RV64I-NEXT: and a0, a0, a1
32 ; RV64I-NEXT: xor a0, a0, a2
35 ; RV64ZBT-LABEL: cmix_i32_2:
37 ; RV64ZBT-NEXT: cmix a0, a1, a0, a2
40 %and = and i32 %xor, %b
41 %xor1 = xor i32 %and, %c
45 define i64 @cmix_i64(i64 %a, i64 %b, i64 %c) nounwind {
46 ; RV64I-LABEL: cmix_i64:
48 ; RV64I-NEXT: and a0, a1, a0
49 ; RV64I-NEXT: not a1, a1
50 ; RV64I-NEXT: and a1, a1, a2
51 ; RV64I-NEXT: or a0, a1, a0
54 ; RV64ZBT-LABEL: cmix_i64:
56 ; RV64ZBT-NEXT: cmix a0, a1, a0, a2
60 %and1 = and i64 %neg, %c
61 %or = or i64 %and1, %and
65 define i64 @cmix_i64_2(i64 %a, i64 %b, i64 %c) nounwind {
66 ; RV64I-LABEL: cmix_i64_2:
68 ; RV64I-NEXT: xor a0, a1, a2
69 ; RV64I-NEXT: and a0, a0, a1
70 ; RV64I-NEXT: xor a0, a0, a2
73 ; RV64ZBT-LABEL: cmix_i64_2:
75 ; RV64ZBT-NEXT: cmix a0, a1, a1, a2
78 %and = and i64 %xor, %b
79 %xor1 = xor i64 %and, %c
83 define signext i32 @cmov_i32(i32 signext %a, i32 signext %b, i32 signext %c) nounwind {
84 ; RV64I-LABEL: cmov_i32:
86 ; RV64I-NEXT: beqz a1, .LBB4_2
87 ; RV64I-NEXT: # %bb.1:
88 ; RV64I-NEXT: mv a2, a0
89 ; RV64I-NEXT: .LBB4_2:
90 ; RV64I-NEXT: mv a0, a2
93 ; RV64ZBT-LABEL: cmov_i32:
95 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
97 %tobool.not = icmp eq i32 %b, 0
98 %cond = select i1 %tobool.not, i32 %c, i32 %a
102 define signext i32 @cmov_sle_i32(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d) nounwind {
103 ; RV64I-LABEL: cmov_sle_i32:
105 ; RV64I-NEXT: bge a2, a1, .LBB5_2
106 ; RV64I-NEXT: # %bb.1:
107 ; RV64I-NEXT: mv a0, a3
108 ; RV64I-NEXT: .LBB5_2:
111 ; RV64ZBT-LABEL: cmov_sle_i32:
113 ; RV64ZBT-NEXT: slt a1, a2, a1
114 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
116 %tobool = icmp sle i32 %b, %c
117 %cond = select i1 %tobool, i32 %a, i32 %d
121 define signext i32 @cmov_sge_i32(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d) nounwind {
122 ; RV64I-LABEL: cmov_sge_i32:
124 ; RV64I-NEXT: bge a1, a2, .LBB6_2
125 ; RV64I-NEXT: # %bb.1:
126 ; RV64I-NEXT: mv a0, a3
127 ; RV64I-NEXT: .LBB6_2:
130 ; RV64ZBT-LABEL: cmov_sge_i32:
132 ; RV64ZBT-NEXT: slt a1, a1, a2
133 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
135 %tobool = icmp sge i32 %b, %c
136 %cond = select i1 %tobool, i32 %a, i32 %d
140 define signext i32 @cmov_ule_i32(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d) nounwind {
141 ; RV64I-LABEL: cmov_ule_i32:
143 ; RV64I-NEXT: bgeu a2, a1, .LBB7_2
144 ; RV64I-NEXT: # %bb.1:
145 ; RV64I-NEXT: mv a0, a3
146 ; RV64I-NEXT: .LBB7_2:
149 ; RV64ZBT-LABEL: cmov_ule_i32:
151 ; RV64ZBT-NEXT: sltu a1, a2, a1
152 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
154 %tobool = icmp ule i32 %b, %c
155 %cond = select i1 %tobool, i32 %a, i32 %d
159 define signext i32 @cmov_uge_i32(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d) nounwind {
160 ; RV64I-LABEL: cmov_uge_i32:
162 ; RV64I-NEXT: bgeu a1, a2, .LBB8_2
163 ; RV64I-NEXT: # %bb.1:
164 ; RV64I-NEXT: mv a0, a3
165 ; RV64I-NEXT: .LBB8_2:
168 ; RV64ZBT-LABEL: cmov_uge_i32:
170 ; RV64ZBT-NEXT: sltu a1, a1, a2
171 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
173 %tobool = icmp uge i32 %b, %c
174 %cond = select i1 %tobool, i32 %a, i32 %d
178 define i64 @cmov_i64(i64 %a, i64 %b, i64 %c) nounwind {
179 ; RV64I-LABEL: cmov_i64:
181 ; RV64I-NEXT: beqz a1, .LBB9_2
182 ; RV64I-NEXT: # %bb.1:
183 ; RV64I-NEXT: mv a2, a0
184 ; RV64I-NEXT: .LBB9_2:
185 ; RV64I-NEXT: mv a0, a2
188 ; RV64ZBT-LABEL: cmov_i64:
190 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
192 %tobool.not = icmp eq i64 %b, 0
193 %cond = select i1 %tobool.not, i64 %c, i64 %a
197 define i64 @cmov_eq_i64_constant_2048(i64 %a, i64 %b, i64 %c) nounwind {
198 ; RV64I-LABEL: cmov_eq_i64_constant_2048:
200 ; RV64I-NEXT: lui a3, 1
201 ; RV64I-NEXT: addiw a3, a3, -2048
202 ; RV64I-NEXT: beq a1, a3, .LBB10_2
203 ; RV64I-NEXT: # %bb.1:
204 ; RV64I-NEXT: mv a0, a2
205 ; RV64I-NEXT: .LBB10_2:
208 ; RV64ZBT-LABEL: cmov_eq_i64_constant_2048:
210 ; RV64ZBT-NEXT: addi a1, a1, -2048
211 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
213 %tobool.not = icmp eq i64 %b, 2048
214 %cond = select i1 %tobool.not, i64 %a, i64 %c
218 define i64 @cmov_eq_i64_constant_neg_2047(i64 %a, i64 %b, i64 %c) nounwind {
219 ; RV64I-LABEL: cmov_eq_i64_constant_neg_2047:
221 ; RV64I-NEXT: li a3, -2047
222 ; RV64I-NEXT: beq a1, a3, .LBB11_2
223 ; RV64I-NEXT: # %bb.1:
224 ; RV64I-NEXT: mv a0, a2
225 ; RV64I-NEXT: .LBB11_2:
228 ; RV64ZBT-LABEL: cmov_eq_i64_constant_neg_2047:
230 ; RV64ZBT-NEXT: addi a1, a1, 2047
231 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
233 %tobool.not = icmp eq i64 %b, -2047
234 %cond = select i1 %tobool.not, i64 %a, i64 %c
238 define i64 @cmov_ne_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
239 ; RV64I-LABEL: cmov_ne_i64:
241 ; RV64I-NEXT: bne a1, a2, .LBB12_2
242 ; RV64I-NEXT: # %bb.1:
243 ; RV64I-NEXT: mv a0, a3
244 ; RV64I-NEXT: .LBB12_2:
247 ; RV64ZBT-LABEL: cmov_ne_i64:
249 ; RV64ZBT-NEXT: xor a1, a1, a2
250 ; RV64ZBT-NEXT: cmov a0, a1, a0, a3
252 %tobool.not = icmp ne i64 %b, %c
253 %cond = select i1 %tobool.not, i64 %a, i64 %d
257 define i64 @cmov_ne_i64_constant_zero(i64 %a, i64 %b, i64 %c) nounwind {
258 ; RV64I-LABEL: cmov_ne_i64_constant_zero:
260 ; RV64I-NEXT: bnez a1, .LBB13_2
261 ; RV64I-NEXT: # %bb.1:
262 ; RV64I-NEXT: mv a0, a2
263 ; RV64I-NEXT: .LBB13_2:
266 ; RV64ZBT-LABEL: cmov_ne_i64_constant_zero:
268 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
270 %tobool.not = icmp ne i64 %b, 0
271 %cond = select i1 %tobool.not, i64 %a, i64 %c
275 define i64 @cmov_ne_i64_constant_2048(i64 %a, i64 %b, i64 %c) nounwind {
276 ; RV64I-LABEL: cmov_ne_i64_constant_2048:
278 ; RV64I-NEXT: lui a3, 1
279 ; RV64I-NEXT: addiw a3, a3, -2048
280 ; RV64I-NEXT: bne a1, a3, .LBB14_2
281 ; RV64I-NEXT: # %bb.1:
282 ; RV64I-NEXT: mv a0, a2
283 ; RV64I-NEXT: .LBB14_2:
286 ; RV64ZBT-LABEL: cmov_ne_i64_constant_2048:
288 ; RV64ZBT-NEXT: addi a1, a1, -2048
289 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
291 %tobool.not = icmp ne i64 %b, 2048
292 %cond = select i1 %tobool.not, i64 %a, i64 %c
296 define i64 @cmov_ne_i64_constant_neg_2047(i64 %a, i64 %b, i64 %c) nounwind {
297 ; RV64I-LABEL: cmov_ne_i64_constant_neg_2047:
299 ; RV64I-NEXT: li a3, -2047
300 ; RV64I-NEXT: bne a1, a3, .LBB15_2
301 ; RV64I-NEXT: # %bb.1:
302 ; RV64I-NEXT: mv a0, a2
303 ; RV64I-NEXT: .LBB15_2:
306 ; RV64ZBT-LABEL: cmov_ne_i64_constant_neg_2047:
308 ; RV64ZBT-NEXT: addi a1, a1, 2047
309 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
311 %tobool.not = icmp ne i64 %b, -2047
312 %cond = select i1 %tobool.not, i64 %a, i64 %c
316 define i64 @cmov_sle_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
317 ; RV64I-LABEL: cmov_sle_i64:
319 ; RV64I-NEXT: bge a2, a1, .LBB16_2
320 ; RV64I-NEXT: # %bb.1:
321 ; RV64I-NEXT: mv a0, a3
322 ; RV64I-NEXT: .LBB16_2:
325 ; RV64ZBT-LABEL: cmov_sle_i64:
327 ; RV64ZBT-NEXT: slt a1, a2, a1
328 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
330 %tobool = icmp sle i64 %b, %c
331 %cond = select i1 %tobool, i64 %a, i64 %d
335 define i64 @cmov_sle_i64_constant_2046(i64 %a, i64 %b, i64 %c) nounwind {
336 ; RV64I-LABEL: cmov_sle_i64_constant_2046:
338 ; RV64I-NEXT: li a3, 2047
339 ; RV64I-NEXT: blt a1, a3, .LBB17_2
340 ; RV64I-NEXT: # %bb.1:
341 ; RV64I-NEXT: mv a0, a2
342 ; RV64I-NEXT: .LBB17_2:
345 ; RV64ZBT-LABEL: cmov_sle_i64_constant_2046:
347 ; RV64ZBT-NEXT: slti a1, a1, 2047
348 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
350 %tobool = icmp sle i64 %b, 2046
351 %cond = select i1 %tobool, i64 %a, i64 %c
355 define i64 @cmov_sle_i64_constant_neg_2049(i64 %a, i64 %b, i64 %c) nounwind {
356 ; RV64I-LABEL: cmov_sle_i64_constant_neg_2049:
358 ; RV64I-NEXT: li a3, -2048
359 ; RV64I-NEXT: blt a1, a3, .LBB18_2
360 ; RV64I-NEXT: # %bb.1:
361 ; RV64I-NEXT: mv a0, a2
362 ; RV64I-NEXT: .LBB18_2:
365 ; RV64ZBT-LABEL: cmov_sle_i64_constant_neg_2049:
367 ; RV64ZBT-NEXT: slti a1, a1, -2048
368 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
370 %tobool = icmp sle i64 %b, -2049
371 %cond = select i1 %tobool, i64 %a, i64 %c
375 define i64 @cmov_sgt_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
376 ; RV64I-LABEL: cmov_sgt_i64:
378 ; RV64I-NEXT: blt a2, a1, .LBB19_2
379 ; RV64I-NEXT: # %bb.1:
380 ; RV64I-NEXT: mv a0, a3
381 ; RV64I-NEXT: .LBB19_2:
384 ; RV64ZBT-LABEL: cmov_sgt_i64:
386 ; RV64ZBT-NEXT: slt a1, a2, a1
387 ; RV64ZBT-NEXT: cmov a0, a1, a0, a3
389 %tobool = icmp sgt i64 %b, %c
390 %cond = select i1 %tobool, i64 %a, i64 %d
394 define i64 @cmov_sgt_i64_constant_2046(i64 %a, i64 %b, i64 %c) nounwind {
395 ; RV64I-LABEL: cmov_sgt_i64_constant_2046:
397 ; RV64I-NEXT: li a3, 2046
398 ; RV64I-NEXT: blt a3, a1, .LBB20_2
399 ; RV64I-NEXT: # %bb.1:
400 ; RV64I-NEXT: mv a0, a2
401 ; RV64I-NEXT: .LBB20_2:
404 ; RV64ZBT-LABEL: cmov_sgt_i64_constant_2046:
406 ; RV64ZBT-NEXT: slti a1, a1, 2047
407 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
409 %tobool = icmp sgt i64 %b, 2046
410 %cond = select i1 %tobool, i64 %a, i64 %c
414 define i64 @cmov_sgt_i64_constant_neg_2049(i64 %a, i64 %b, i64 %c) nounwind {
415 ; RV64I-LABEL: cmov_sgt_i64_constant_neg_2049:
417 ; RV64I-NEXT: lui a3, 1048575
418 ; RV64I-NEXT: addiw a3, a3, 2047
419 ; RV64I-NEXT: blt a3, a1, .LBB21_2
420 ; RV64I-NEXT: # %bb.1:
421 ; RV64I-NEXT: mv a0, a2
422 ; RV64I-NEXT: .LBB21_2:
425 ; RV64ZBT-LABEL: cmov_sgt_i64_constant_neg_2049:
427 ; RV64ZBT-NEXT: slti a1, a1, -2048
428 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
430 %tobool = icmp sgt i64 %b, -2049
431 %cond = select i1 %tobool, i64 %a, i64 %c
435 define i64 @cmov_sge_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
436 ; RV64I-LABEL: cmov_sge_i64:
438 ; RV64I-NEXT: bge a1, a2, .LBB22_2
439 ; RV64I-NEXT: # %bb.1:
440 ; RV64I-NEXT: mv a0, a3
441 ; RV64I-NEXT: .LBB22_2:
444 ; RV64ZBT-LABEL: cmov_sge_i64:
446 ; RV64ZBT-NEXT: slt a1, a1, a2
447 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
449 %tobool = icmp sge i64 %b, %c
450 %cond = select i1 %tobool, i64 %a, i64 %d
454 define i64 @cmov_sge_i64_constant_2047(i64 %a, i64 %b, i64 %c) nounwind {
455 ; RV64I-LABEL: cmov_sge_i64_constant_2047:
457 ; RV64I-NEXT: li a3, 2046
458 ; RV64I-NEXT: blt a3, a1, .LBB23_2
459 ; RV64I-NEXT: # %bb.1:
460 ; RV64I-NEXT: mv a0, a2
461 ; RV64I-NEXT: .LBB23_2:
464 ; RV64ZBT-LABEL: cmov_sge_i64_constant_2047:
466 ; RV64ZBT-NEXT: slti a1, a1, 2047
467 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
469 %tobool = icmp sge i64 %b, 2047
470 %cond = select i1 %tobool, i64 %a, i64 %c
474 define i64 @cmov_sge_i64_constant_neg_2048(i64 %a, i64 %b, i64 %c) nounwind {
475 ; RV64I-LABEL: cmov_sge_i64_constant_neg_2048:
477 ; RV64I-NEXT: lui a3, 1048575
478 ; RV64I-NEXT: addiw a3, a3, 2047
479 ; RV64I-NEXT: blt a3, a1, .LBB24_2
480 ; RV64I-NEXT: # %bb.1:
481 ; RV64I-NEXT: mv a0, a2
482 ; RV64I-NEXT: .LBB24_2:
485 ; RV64ZBT-LABEL: cmov_sge_i64_constant_neg_2048:
487 ; RV64ZBT-NEXT: slti a1, a1, -2048
488 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
490 %tobool = icmp sge i64 %b, -2048
491 %cond = select i1 %tobool, i64 %a, i64 %c
495 define i64 @cmov_ule_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
496 ; RV64I-LABEL: cmov_ule_i64:
498 ; RV64I-NEXT: bgeu a2, a1, .LBB25_2
499 ; RV64I-NEXT: # %bb.1:
500 ; RV64I-NEXT: mv a0, a3
501 ; RV64I-NEXT: .LBB25_2:
504 ; RV64ZBT-LABEL: cmov_ule_i64:
506 ; RV64ZBT-NEXT: sltu a1, a2, a1
507 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
509 %tobool = icmp ule i64 %b, %c
510 %cond = select i1 %tobool, i64 %a, i64 %d
514 define i64 @cmov_ule_i64_constant_2047(i64 %a, i64 %b, i64 %c) nounwind {
515 ; RV64I-LABEL: cmov_ule_i64_constant_2047:
517 ; RV64I-NEXT: srli a1, a1, 11
518 ; RV64I-NEXT: beqz a1, .LBB26_2
519 ; RV64I-NEXT: # %bb.1:
520 ; RV64I-NEXT: mv a0, a2
521 ; RV64I-NEXT: .LBB26_2:
524 ; RV64ZBT-LABEL: cmov_ule_i64_constant_2047:
526 ; RV64ZBT-NEXT: srli a1, a1, 11
527 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
529 %tobool = icmp ule i64 %b, 2047
530 %cond = select i1 %tobool, i64 %a, i64 %c
534 define i64 @cmov_ule_i64_constant_neg_2049(i64 %a, i64 %b, i64 %c) nounwind {
535 ; RV64I-LABEL: cmov_ule_i64_constant_neg_2049:
537 ; RV64I-NEXT: li a3, -2048
538 ; RV64I-NEXT: bltu a1, a3, .LBB27_2
539 ; RV64I-NEXT: # %bb.1:
540 ; RV64I-NEXT: mv a0, a2
541 ; RV64I-NEXT: .LBB27_2:
544 ; RV64ZBT-LABEL: cmov_ule_i64_constant_neg_2049:
546 ; RV64ZBT-NEXT: sltiu a1, a1, -2048
547 ; RV64ZBT-NEXT: cmov a0, a1, a0, a2
549 %tobool = icmp ule i64 %b, 18446744073709549567
550 %cond = select i1 %tobool, i64 %a, i64 %c
554 define i64 @cmov_ugt_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
555 ; RV64I-LABEL: cmov_ugt_i64:
557 ; RV64I-NEXT: bltu a2, a1, .LBB28_2
558 ; RV64I-NEXT: # %bb.1:
559 ; RV64I-NEXT: mv a0, a3
560 ; RV64I-NEXT: .LBB28_2:
563 ; RV64ZBT-LABEL: cmov_ugt_i64:
565 ; RV64ZBT-NEXT: sltu a1, a2, a1
566 ; RV64ZBT-NEXT: cmov a0, a1, a0, a3
568 %tobool = icmp ugt i64 %b, %c
569 %cond = select i1 %tobool, i64 %a, i64 %d
573 define i64 @cmov_ugt_i64_constant_2046(i64 %a, i64 %b, i64 %c) nounwind {
574 ; RV64I-LABEL: cmov_ugt_i64_constant_2046:
576 ; RV64I-NEXT: li a3, 2046
577 ; RV64I-NEXT: bltu a3, a1, .LBB29_2
578 ; RV64I-NEXT: # %bb.1:
579 ; RV64I-NEXT: mv a0, a2
580 ; RV64I-NEXT: .LBB29_2:
583 ; RV64ZBT-LABEL: cmov_ugt_i64_constant_2046:
585 ; RV64ZBT-NEXT: sltiu a1, a1, 2047
586 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
588 %tobool = icmp ugt i64 %b, 2046
589 %cond = select i1 %tobool, i64 %a, i64 %c
593 define i64 @cmov_ugt_i64_constant_neg_2049(i64 %a, i64 %b, i64 %c) nounwind {
594 ; RV64I-LABEL: cmov_ugt_i64_constant_neg_2049:
596 ; RV64I-NEXT: lui a3, 1048575
597 ; RV64I-NEXT: addiw a3, a3, 2047
598 ; RV64I-NEXT: bltu a3, a1, .LBB30_2
599 ; RV64I-NEXT: # %bb.1:
600 ; RV64I-NEXT: mv a0, a2
601 ; RV64I-NEXT: .LBB30_2:
604 ; RV64ZBT-LABEL: cmov_ugt_i64_constant_neg_2049:
606 ; RV64ZBT-NEXT: sltiu a1, a1, -2048
607 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
609 %tobool = icmp ugt i64 %b, 18446744073709549567
610 %cond = select i1 %tobool, i64 %a, i64 %c
614 define i64 @cmov_uge_i64(i64 %a, i64 %b, i64 %c, i64 %d) nounwind {
615 ; RV64I-LABEL: cmov_uge_i64:
617 ; RV64I-NEXT: bgeu a1, a2, .LBB31_2
618 ; RV64I-NEXT: # %bb.1:
619 ; RV64I-NEXT: mv a0, a3
620 ; RV64I-NEXT: .LBB31_2:
623 ; RV64ZBT-LABEL: cmov_uge_i64:
625 ; RV64ZBT-NEXT: sltu a1, a1, a2
626 ; RV64ZBT-NEXT: cmov a0, a1, a3, a0
628 %tobool = icmp uge i64 %b, %c
629 %cond = select i1 %tobool, i64 %a, i64 %d
633 define i64 @cmov_uge_i64_constant_2047(i64 %a, i64 %b, i64 %c) nounwind {
634 ; RV64I-LABEL: cmov_uge_i64_constant_2047:
636 ; RV64I-NEXT: li a3, 2046
637 ; RV64I-NEXT: bltu a3, a1, .LBB32_2
638 ; RV64I-NEXT: # %bb.1:
639 ; RV64I-NEXT: mv a0, a2
640 ; RV64I-NEXT: .LBB32_2:
643 ; RV64ZBT-LABEL: cmov_uge_i64_constant_2047:
645 ; RV64ZBT-NEXT: sltiu a1, a1, 2047
646 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
648 %tobool = icmp uge i64 %b, 2047
649 %cond = select i1 %tobool, i64 %a, i64 %c
653 define i64 @cmov_uge_i64_constant_neg_2048(i64 %a, i64 %b, i64 %c) nounwind {
654 ; RV64I-LABEL: cmov_uge_i64_constant_neg_2048:
656 ; RV64I-NEXT: lui a3, 1048575
657 ; RV64I-NEXT: addiw a3, a3, 2047
658 ; RV64I-NEXT: bltu a3, a1, .LBB33_2
659 ; RV64I-NEXT: # %bb.1:
660 ; RV64I-NEXT: mv a0, a2
661 ; RV64I-NEXT: .LBB33_2:
664 ; RV64ZBT-LABEL: cmov_uge_i64_constant_neg_2048:
666 ; RV64ZBT-NEXT: sltiu a1, a1, -2048
667 ; RV64ZBT-NEXT: cmov a0, a1, a2, a0
669 %tobool = icmp uge i64 %b, 18446744073709549568
670 %cond = select i1 %tobool, i64 %a, i64 %c
674 declare i32 @llvm.fshl.i32(i32, i32, i32)
676 define signext i32 @fshl_i32(i32 signext %a, i32 signext %b, i32 signext %c) nounwind {
677 ; RV64I-LABEL: fshl_i32:
679 ; RV64I-NEXT: slli a0, a0, 32
680 ; RV64I-NEXT: slli a1, a1, 32
681 ; RV64I-NEXT: srli a1, a1, 32
682 ; RV64I-NEXT: or a0, a0, a1
683 ; RV64I-NEXT: andi a1, a2, 31
684 ; RV64I-NEXT: sll a0, a0, a1
685 ; RV64I-NEXT: srai a0, a0, 32
688 ; RV64ZBT-LABEL: fshl_i32:
690 ; RV64ZBT-NEXT: andi a2, a2, 31
691 ; RV64ZBT-NEXT: fslw a0, a0, a1, a2
693 %1 = tail call i32 @llvm.fshl.i32(i32 %a, i32 %b, i32 %c)
697 ; Similar to fshl_i32 but result is not sign extended.
698 define void @fshl_i32_nosext(i32 signext %a, i32 signext %b, i32 signext %c, i32* %x) nounwind {
699 ; RV64I-LABEL: fshl_i32_nosext:
701 ; RV64I-NEXT: slli a0, a0, 32
702 ; RV64I-NEXT: slli a1, a1, 32
703 ; RV64I-NEXT: srli a1, a1, 32
704 ; RV64I-NEXT: or a0, a0, a1
705 ; RV64I-NEXT: andi a1, a2, 31
706 ; RV64I-NEXT: sll a0, a0, a1
707 ; RV64I-NEXT: srli a0, a0, 32
708 ; RV64I-NEXT: sw a0, 0(a3)
711 ; RV64ZBT-LABEL: fshl_i32_nosext:
713 ; RV64ZBT-NEXT: andi a2, a2, 31
714 ; RV64ZBT-NEXT: fslw a0, a0, a1, a2
715 ; RV64ZBT-NEXT: sw a0, 0(a3)
717 %1 = tail call i32 @llvm.fshl.i32(i32 %a, i32 %b, i32 %c)
718 store i32 %1, i32* %x
722 declare i64 @llvm.fshl.i64(i64, i64, i64)
724 define i64 @fshl_i64(i64 %a, i64 %b, i64 %c) nounwind {
725 ; RV64I-LABEL: fshl_i64:
727 ; RV64I-NEXT: sll a0, a0, a2
728 ; RV64I-NEXT: not a2, a2
729 ; RV64I-NEXT: srli a1, a1, 1
730 ; RV64I-NEXT: srl a1, a1, a2
731 ; RV64I-NEXT: or a0, a0, a1
734 ; RV64ZBT-LABEL: fshl_i64:
736 ; RV64ZBT-NEXT: andi a2, a2, 63
737 ; RV64ZBT-NEXT: fsl a0, a0, a1, a2
739 %1 = tail call i64 @llvm.fshl.i64(i64 %a, i64 %b, i64 %c)
743 declare i32 @llvm.fshr.i32(i32, i32, i32)
745 define signext i32 @fshr_i32(i32 signext %a, i32 signext %b, i32 signext %c) nounwind {
746 ; RV64I-LABEL: fshr_i32:
748 ; RV64I-NEXT: slli a0, a0, 32
749 ; RV64I-NEXT: slli a1, a1, 32
750 ; RV64I-NEXT: srli a1, a1, 32
751 ; RV64I-NEXT: or a0, a0, a1
752 ; RV64I-NEXT: andi a1, a2, 31
753 ; RV64I-NEXT: srl a0, a0, a1
754 ; RV64I-NEXT: sext.w a0, a0
757 ; RV64ZBT-LABEL: fshr_i32:
759 ; RV64ZBT-NEXT: andi a2, a2, 31
760 ; RV64ZBT-NEXT: fsrw a0, a1, a0, a2
762 %1 = tail call i32 @llvm.fshr.i32(i32 %a, i32 %b, i32 %c)
766 ; Similar to fshr_i32 but result is not sign extended.
767 define void @fshr_i32_nosext(i32 signext %a, i32 signext %b, i32 signext %c, i32* %x) nounwind {
768 ; RV64I-LABEL: fshr_i32_nosext:
770 ; RV64I-NEXT: slli a0, a0, 32
771 ; RV64I-NEXT: slli a1, a1, 32
772 ; RV64I-NEXT: srli a1, a1, 32
773 ; RV64I-NEXT: or a0, a0, a1
774 ; RV64I-NEXT: andi a1, a2, 31
775 ; RV64I-NEXT: srl a0, a0, a1
776 ; RV64I-NEXT: sw a0, 0(a3)
779 ; RV64ZBT-LABEL: fshr_i32_nosext:
781 ; RV64ZBT-NEXT: andi a2, a2, 31
782 ; RV64ZBT-NEXT: fsrw a0, a1, a0, a2
783 ; RV64ZBT-NEXT: sw a0, 0(a3)
785 %1 = tail call i32 @llvm.fshr.i32(i32 %a, i32 %b, i32 %c)
786 store i32 %1, i32* %x
790 declare i64 @llvm.fshr.i64(i64, i64, i64)
792 define i64 @fshr_i64(i64 %a, i64 %b, i64 %c) nounwind {
793 ; RV64I-LABEL: fshr_i64:
795 ; RV64I-NEXT: srl a1, a1, a2
796 ; RV64I-NEXT: not a2, a2
797 ; RV64I-NEXT: slli a0, a0, 1
798 ; RV64I-NEXT: sll a0, a0, a2
799 ; RV64I-NEXT: or a0, a0, a1
802 ; RV64ZBT-LABEL: fshr_i64:
804 ; RV64ZBT-NEXT: andi a2, a2, 63
805 ; RV64ZBT-NEXT: fsr a0, a1, a0, a2
807 %1 = tail call i64 @llvm.fshr.i64(i64 %a, i64 %b, i64 %c)
811 define signext i32 @fshri_i32(i32 signext %a, i32 signext %b) nounwind {
812 ; RV64I-LABEL: fshri_i32:
814 ; RV64I-NEXT: srliw a1, a1, 5
815 ; RV64I-NEXT: slliw a0, a0, 27
816 ; RV64I-NEXT: or a0, a0, a1
819 ; RV64ZBT-LABEL: fshri_i32:
821 ; RV64ZBT-NEXT: fsriw a0, a1, a0, 5
823 %1 = tail call i32 @llvm.fshr.i32(i32 %a, i32 %b, i32 5)
827 ; Similar to fshr_i32 but result is not sign extended.
828 define void @fshri_i32_nosext(i32 signext %a, i32 signext %b, i32* %x) nounwind {
829 ; RV64I-LABEL: fshri_i32_nosext:
831 ; RV64I-NEXT: srliw a1, a1, 5
832 ; RV64I-NEXT: slli a0, a0, 27
833 ; RV64I-NEXT: or a0, a0, a1
834 ; RV64I-NEXT: sw a0, 0(a2)
837 ; RV64ZBT-LABEL: fshri_i32_nosext:
839 ; RV64ZBT-NEXT: fsriw a0, a1, a0, 5
840 ; RV64ZBT-NEXT: sw a0, 0(a2)
842 %1 = tail call i32 @llvm.fshr.i32(i32 %a, i32 %b, i32 5)
843 store i32 %1, i32* %x
847 define i64 @fshri_i64(i64 %a, i64 %b) nounwind {
848 ; RV64I-LABEL: fshri_i64:
850 ; RV64I-NEXT: srli a1, a1, 5
851 ; RV64I-NEXT: slli a0, a0, 59
852 ; RV64I-NEXT: or a0, a0, a1
855 ; RV64ZBT-LABEL: fshri_i64:
857 ; RV64ZBT-NEXT: fsri a0, a1, a0, 5
859 %1 = tail call i64 @llvm.fshr.i64(i64 %a, i64 %b, i64 5)
863 define signext i32 @fshli_i32(i32 signext %a, i32 signext %b) nounwind {
864 ; RV64I-LABEL: fshli_i32:
866 ; RV64I-NEXT: srliw a1, a1, 27
867 ; RV64I-NEXT: slliw a0, a0, 5
868 ; RV64I-NEXT: or a0, a0, a1
871 ; RV64ZBT-LABEL: fshli_i32:
873 ; RV64ZBT-NEXT: fsriw a0, a1, a0, 27
875 %1 = tail call i32 @llvm.fshl.i32(i32 %a, i32 %b, i32 5)
879 ; Similar to fshl_i32 but result is not sign extended.
880 define void @fshli_i32_nosext(i32 signext %a, i32 signext %b, i32* %x) nounwind {
881 ; RV64I-LABEL: fshli_i32_nosext:
883 ; RV64I-NEXT: srliw a1, a1, 27
884 ; RV64I-NEXT: slli a0, a0, 5
885 ; RV64I-NEXT: or a0, a0, a1
886 ; RV64I-NEXT: sw a0, 0(a2)
889 ; RV64ZBT-LABEL: fshli_i32_nosext:
891 ; RV64ZBT-NEXT: fsriw a0, a1, a0, 27
892 ; RV64ZBT-NEXT: sw a0, 0(a2)
894 %1 = tail call i32 @llvm.fshl.i32(i32 %a, i32 %b, i32 5)
895 store i32 %1, i32* %x
899 define i64 @fshli_i64(i64 %a, i64 %b) nounwind {
900 ; RV64I-LABEL: fshli_i64:
902 ; RV64I-NEXT: srli a1, a1, 59
903 ; RV64I-NEXT: slli a0, a0, 5
904 ; RV64I-NEXT: or a0, a0, a1
907 ; RV64ZBT-LABEL: fshli_i64:
909 ; RV64ZBT-NEXT: fsri a0, a1, a0, 59
911 %1 = tail call i64 @llvm.fshl.i64(i64 %a, i64 %b, i64 5)