1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; Exercise the 'shl' LLVM IR: https://llvm.org/docs/LangRef.html#shl-instruction
7 define i1 @shl_i1(i1 %x, i1 %y) {
19 define i8 @shl_i8(i8 %x, i8 %y) {
22 ; LA32-NEXT: sll.w $a0, $a0, $a1
27 ; LA64-NEXT: sll.d $a0, $a0, $a1
33 define i16 @shl_i16(i16 %x, i16 %y) {
34 ; LA32-LABEL: shl_i16:
36 ; LA32-NEXT: sll.w $a0, $a0, $a1
39 ; LA64-LABEL: shl_i16:
41 ; LA64-NEXT: sll.d $a0, $a0, $a1
47 define i32 @shl_i32(i32 %x, i32 %y) {
48 ; LA32-LABEL: shl_i32:
50 ; LA32-NEXT: sll.w $a0, $a0, $a1
53 ; LA64-LABEL: shl_i32:
55 ; LA64-NEXT: sll.w $a0, $a0, $a1
61 define i64 @shl_i64(i64 %x, i64 %y) {
62 ; LA32-LABEL: shl_i64:
64 ; LA32-NEXT: sll.w $a1, $a1, $a2
65 ; LA32-NEXT: xori $a3, $a2, 31
66 ; LA32-NEXT: srli.w $a4, $a0, 1
67 ; LA32-NEXT: srl.w $a3, $a4, $a3
68 ; LA32-NEXT: or $a1, $a1, $a3
69 ; LA32-NEXT: addi.w $a3, $a2, -32
70 ; LA32-NEXT: slti $a4, $a3, 0
71 ; LA32-NEXT: maskeqz $a1, $a1, $a4
72 ; LA32-NEXT: sll.w $a5, $a0, $a3
73 ; LA32-NEXT: masknez $a4, $a5, $a4
74 ; LA32-NEXT: or $a1, $a1, $a4
75 ; LA32-NEXT: sll.w $a0, $a0, $a2
76 ; LA32-NEXT: srai.w $a2, $a3, 31
77 ; LA32-NEXT: and $a0, $a2, $a0
80 ; LA64-LABEL: shl_i64:
82 ; LA64-NEXT: sll.d $a0, $a0, $a1
88 define i1 @shl_i1_3(i1 %x) {
89 ; LA32-LABEL: shl_i1_3:
93 ; LA64-LABEL: shl_i1_3:
100 define i8 @shl_i8_3(i8 %x) {
101 ; LA32-LABEL: shl_i8_3:
103 ; LA32-NEXT: slli.w $a0, $a0, 3
106 ; LA64-LABEL: shl_i8_3:
108 ; LA64-NEXT: slli.d $a0, $a0, 3
114 define i16 @shl_i16_3(i16 %x) {
115 ; LA32-LABEL: shl_i16_3:
117 ; LA32-NEXT: slli.w $a0, $a0, 3
120 ; LA64-LABEL: shl_i16_3:
122 ; LA64-NEXT: slli.d $a0, $a0, 3
128 define i32 @shl_i32_3(i32 %x) {
129 ; LA32-LABEL: shl_i32_3:
131 ; LA32-NEXT: slli.w $a0, $a0, 3
134 ; LA64-LABEL: shl_i32_3:
136 ; LA64-NEXT: slli.d $a0, $a0, 3
142 define i64 @shl_i64_3(i64 %x) {
143 ; LA32-LABEL: shl_i64_3:
145 ; LA32-NEXT: srli.w $a2, $a0, 29
146 ; LA32-NEXT: slli.w $a1, $a1, 3
147 ; LA32-NEXT: or $a1, $a1, $a2
148 ; LA32-NEXT: slli.w $a0, $a0, 3
151 ; LA64-LABEL: shl_i64_3:
153 ; LA64-NEXT: slli.d $a0, $a0, 3