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 'lshr' LLVM IR: https://llvm.org/docs/LangRef.html#lshr-instruction
7 define i1 @lshr_i1(i1 %x, i1 %y) {
12 ; LA64-LABEL: lshr_i1:
15 %lshr = lshr i1 %x, %y
19 define i8 @lshr_i8(i8 %x, i8 %y) {
20 ; LA32-LABEL: lshr_i8:
22 ; LA32-NEXT: andi $a0, $a0, 255
23 ; LA32-NEXT: srl.w $a0, $a0, $a1
26 ; LA64-LABEL: lshr_i8:
28 ; LA64-NEXT: andi $a0, $a0, 255
29 ; LA64-NEXT: srl.d $a0, $a0, $a1
31 %lshr = lshr i8 %x, %y
35 define i16 @lshr_i16(i16 %x, i16 %y) {
36 ; LA32-LABEL: lshr_i16:
38 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
39 ; LA32-NEXT: srl.w $a0, $a0, $a1
42 ; LA64-LABEL: lshr_i16:
44 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
45 ; LA64-NEXT: srl.d $a0, $a0, $a1
47 %lshr = lshr i16 %x, %y
51 define i32 @lshr_i32(i32 %x, i32 %y) {
52 ; LA32-LABEL: lshr_i32:
54 ; LA32-NEXT: srl.w $a0, $a0, $a1
57 ; LA64-LABEL: lshr_i32:
59 ; LA64-NEXT: srl.w $a0, $a0, $a1
61 %lshr = lshr i32 %x, %y
65 define i64 @lshr_i64(i64 %x, i64 %y) {
66 ; LA32-LABEL: lshr_i64:
68 ; LA32-NEXT: srl.w $a0, $a0, $a2
69 ; LA32-NEXT: xori $a3, $a2, 31
70 ; LA32-NEXT: slli.w $a4, $a1, 1
71 ; LA32-NEXT: sll.w $a3, $a4, $a3
72 ; LA32-NEXT: or $a0, $a0, $a3
73 ; LA32-NEXT: addi.w $a3, $a2, -32
74 ; LA32-NEXT: slti $a4, $a3, 0
75 ; LA32-NEXT: maskeqz $a0, $a0, $a4
76 ; LA32-NEXT: srl.w $a5, $a1, $a3
77 ; LA32-NEXT: masknez $a4, $a5, $a4
78 ; LA32-NEXT: or $a0, $a0, $a4
79 ; LA32-NEXT: srl.w $a1, $a1, $a2
80 ; LA32-NEXT: srai.w $a2, $a3, 31
81 ; LA32-NEXT: and $a1, $a2, $a1
84 ; LA64-LABEL: lshr_i64:
86 ; LA64-NEXT: srl.d $a0, $a0, $a1
88 %lshr = lshr i64 %x, %y
92 define i1 @lshr_i1_3(i1 %x) {
93 ; LA32-LABEL: lshr_i1_3:
97 ; LA64-LABEL: lshr_i1_3:
100 %lshr = lshr i1 %x, 3
104 define i8 @lshr_i8_3(i8 %x) {
105 ; LA32-LABEL: lshr_i8_3:
107 ; LA32-NEXT: bstrpick.w $a0, $a0, 7, 3
110 ; LA64-LABEL: lshr_i8_3:
112 ; LA64-NEXT: bstrpick.d $a0, $a0, 7, 3
114 %lshr = lshr i8 %x, 3
118 define i16 @lshr_i16_3(i16 %x) {
119 ; LA32-LABEL: lshr_i16_3:
121 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 3
124 ; LA64-LABEL: lshr_i16_3:
126 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 3
128 %lshr = lshr i16 %x, 3
132 define i32 @lshr_i32_3(i32 %x) {
133 ; LA32-LABEL: lshr_i32_3:
135 ; LA32-NEXT: srli.w $a0, $a0, 3
138 ; LA64-LABEL: lshr_i32_3:
140 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 3
142 %lshr = lshr i32 %x, 3
146 define i64 @lshr_i64_3(i64 %x) {
147 ; LA32-LABEL: lshr_i64_3:
149 ; LA32-NEXT: slli.w $a2, $a1, 29
150 ; LA32-NEXT: srli.w $a0, $a0, 3
151 ; LA32-NEXT: or $a0, $a0, $a2
152 ; LA32-NEXT: srli.w $a1, $a1, 3
155 ; LA64-LABEL: lshr_i64_3:
157 ; LA64-NEXT: srli.d $a0, $a0, 3
159 %lshr = lshr i64 %x, 3