1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefix=LA32
4 ; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s --check-prefix=LA64
7 ;; a=00112233 b=44556677
9 define i32 @pick_i32_1(i32 %a, i32 %b) {
10 ; LA32-LABEL: pick_i32_1:
12 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 1
15 ; LA64-LABEL: pick_i32_1:
17 ; LA64-NEXT: slli.d $a0, $a0, 8
18 ; LA64-NEXT: bstrpick.d $a1, $a1, 31, 24
19 ; LA64-NEXT: or $a0, $a1, $a0
27 ;; a=00112233 b=44556677
29 define signext i32 @pick_i32_1_sext(i32 %a, i32 %b) {
30 ; LA32-LABEL: pick_i32_1_sext:
32 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 1
35 ; LA64-LABEL: pick_i32_1_sext:
37 ; LA64-NEXT: bytepick.w $a0, $a1, $a0, 1
45 ;; a=00112233 b=44556677
47 define i32 @pick_i32_2(i32 %a, i32 %b) {
48 ; LA32-LABEL: pick_i32_2:
50 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 2
53 ; LA64-LABEL: pick_i32_2:
55 ; LA64-NEXT: slli.d $a0, $a0, 16
56 ; LA64-NEXT: bstrpick.d $a1, $a1, 31, 16
57 ; LA64-NEXT: or $a0, $a1, $a0
65 ;; a=00112233 b=44556677
67 define signext i32 @pick_i32_2_sext(i32 %a, i32 %b) {
68 ; LA32-LABEL: pick_i32_2_sext:
70 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 2
73 ; LA64-LABEL: pick_i32_2_sext:
75 ; LA64-NEXT: bytepick.w $a0, $a1, $a0, 2
83 ;; a=00112233 b=44556677
85 define i32 @pick_i32_3(i32 %a, i32 %b) {
86 ; LA32-LABEL: pick_i32_3:
88 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 3
91 ; LA64-LABEL: pick_i32_3:
93 ; LA64-NEXT: slli.d $a0, $a0, 24
94 ; LA64-NEXT: bstrpick.d $a1, $a1, 31, 8
95 ; LA64-NEXT: or $a0, $a1, $a0
103 ;; a=00112233 b=44556677
105 define signext i32 @pick_i32_3_sext(i32 %a, i32 %b) {
106 ; LA32-LABEL: pick_i32_3_sext:
108 ; LA32-NEXT: bytepick.w $a0, $a1, $a0, 3
111 ; LA64-LABEL: pick_i32_3_sext:
113 ; LA64-NEXT: bytepick.w $a0, $a1, $a0, 3
121 ;; a=0011223344556677 b=8899aabbccddeeff
122 ;; expected 1122334455667788
123 define i64 @pick_i64_1(i64 %a, i64 %b) {
124 ; LA32-LABEL: pick_i64_1:
126 ; LA32-NEXT: bytepick.w $a2, $a3, $a0, 1
127 ; LA32-NEXT: bytepick.w $a1, $a0, $a1, 1
128 ; LA32-NEXT: move $a0, $a2
131 ; LA64-LABEL: pick_i64_1:
133 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 1
141 ;; a=0011223344556677 b=8899aabbccddeeff
142 ;; expected 2233445566778899
143 define i64 @pick_i64_2(i64 %a, i64 %b) {
144 ; LA32-LABEL: pick_i64_2:
146 ; LA32-NEXT: bytepick.w $a2, $a3, $a0, 2
147 ; LA32-NEXT: bytepick.w $a1, $a0, $a1, 2
148 ; LA32-NEXT: move $a0, $a2
151 ; LA64-LABEL: pick_i64_2:
153 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 2
161 ;; a=0011223344556677 b=8899aabbccddeeff
162 ;; expected 33445566778899aa
163 define i64 @pick_i64_3(i64 %a, i64 %b) {
164 ; LA32-LABEL: pick_i64_3:
166 ; LA32-NEXT: bytepick.w $a2, $a3, $a0, 3
167 ; LA32-NEXT: bytepick.w $a1, $a0, $a1, 3
168 ; LA32-NEXT: move $a0, $a2
171 ; LA64-LABEL: pick_i64_3:
173 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 3
181 ;; a=0011223344556677 b=8899aabbccddeeff
182 ;; expected 445566778899aabb
183 define i64 @pick_i64_4(i64 %a, i64 %b) {
184 ; LA32-LABEL: pick_i64_4:
186 ; LA32-NEXT: move $a1, $a0
187 ; LA32-NEXT: move $a0, $a3
190 ; LA64-LABEL: pick_i64_4:
192 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 4
200 ;; a=0011223344556677 b=8899aabbccddeeff
201 ;; expected 5566778899aabbcc
202 define i64 @pick_i64_5(i64 %a, i64 %b) {
203 ; LA32-LABEL: pick_i64_5:
205 ; LA32-NEXT: bytepick.w $a2, $a2, $a3, 1
206 ; LA32-NEXT: bytepick.w $a1, $a3, $a0, 1
207 ; LA32-NEXT: move $a0, $a2
210 ; LA64-LABEL: pick_i64_5:
212 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 5
220 ;; a=0011223344556677 b=8899aabbccddeeff
221 ;; expected 66778899aabbccdd
222 define i64 @pick_i64_6(i64 %a, i64 %b) {
223 ; LA32-LABEL: pick_i64_6:
225 ; LA32-NEXT: bytepick.w $a2, $a2, $a3, 2
226 ; LA32-NEXT: bytepick.w $a1, $a3, $a0, 2
227 ; LA32-NEXT: move $a0, $a2
230 ; LA64-LABEL: pick_i64_6:
232 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 6
240 ;; a=0011223344556677 b=8899aabbccddeeff
241 ;; expected 778899aabbccddee
242 define i64 @pick_i64_7(i64 %a, i64 %b) {
243 ; LA32-LABEL: pick_i64_7:
245 ; LA32-NEXT: bytepick.w $a2, $a2, $a3, 3
246 ; LA32-NEXT: bytepick.w $a1, $a3, $a0, 3
247 ; LA32-NEXT: move $a0, $a2
250 ; LA64-LABEL: pick_i64_7:
252 ; LA64-NEXT: bytepick.d $a0, $a1, $a0, 7