Skip to content

Commit bc829b5

Browse files
committed
[LoongArch][test] Pre-commit for fix codegen for ISD::ROTR. NFC
1 parent 0420d2f commit bc829b5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

llvm/test/CodeGen/LoongArch/rotl-rotr.ll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,41 @@ define i64 @rotr_64_mask_or_128_or_64(i64 %x, i64 %y) nounwind {
504504
ret i64 %f
505505
}
506506

507+
define signext i32 @rotr_64_trunc_32(i64 %x, i64 %y) nounwind {
508+
; LA32-LABEL: rotr_64_trunc_32:
509+
; LA32: # %bb.0:
510+
; LA32-NEXT: srl.w $a3, $a0, $a2
511+
; LA32-NEXT: xori $a4, $a2, 31
512+
; LA32-NEXT: slli.w $a5, $a1, 1
513+
; LA32-NEXT: sll.w $a4, $a5, $a4
514+
; LA32-NEXT: or $a3, $a3, $a4
515+
; LA32-NEXT: addi.w $a4, $a2, -32
516+
; LA32-NEXT: slti $a5, $a4, 0
517+
; LA32-NEXT: maskeqz $a3, $a3, $a5
518+
; LA32-NEXT: srl.w $a1, $a1, $a4
519+
; LA32-NEXT: masknez $a1, $a1, $a5
520+
; LA32-NEXT: or $a1, $a3, $a1
521+
; LA32-NEXT: sub.w $a3, $zero, $a2
522+
; LA32-NEXT: sll.w $a0, $a0, $a3
523+
; LA32-NEXT: ori $a3, $zero, 32
524+
; LA32-NEXT: sub.w $a2, $a3, $a2
525+
; LA32-NEXT: srai.w $a2, $a2, 31
526+
; LA32-NEXT: and $a0, $a2, $a0
527+
; LA32-NEXT: or $a0, $a1, $a0
528+
; LA32-NEXT: ret
529+
;
530+
; LA64-LABEL: rotr_64_trunc_32:
531+
; LA64: # %bb.0:
532+
; LA64-NEXT: rotr.w $a0, $a0, $a1
533+
; LA64-NEXT: ret
534+
%z = sub i64 64, %y
535+
%b = lshr i64 %x, %y
536+
%c = shl i64 %x, %z
537+
%d = or i64 %b, %c
538+
%e = trunc i64 %d to i32
539+
ret i32 %e
540+
}
541+
507542
define signext i32 @rotri_i32(i32 signext %a) nounwind {
508543
; LA32-LABEL: rotri_i32:
509544
; LA32: # %bb.0:

0 commit comments

Comments
 (0)