1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV32I
4 ; RUN: llc -mtriple=riscv32 -mattr=+zbb -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefixes=CHECK,RV32ZBB
7 define i32 @orc_b_i32_mul255(i32 %x) nounwind {
8 ; RV32I-LABEL: orc_b_i32_mul255:
9 ; RV32I: # %bb.0: # %entry
10 ; RV32I-NEXT: lui a1, 4112
11 ; RV32I-NEXT: addi a1, a1, 257
12 ; RV32I-NEXT: and a0, a0, a1
13 ; RV32I-NEXT: slli a1, a0, 8
14 ; RV32I-NEXT: sub a0, a1, a0
17 ; RV32ZBB-LABEL: orc_b_i32_mul255:
18 ; RV32ZBB: # %bb.0: # %entry
19 ; RV32ZBB-NEXT: lui a1, 4112
20 ; RV32ZBB-NEXT: addi a1, a1, 257
21 ; RV32ZBB-NEXT: and a0, a0, a1
22 ; RV32ZBB-NEXT: orc.b a0, a0
25 %and = and i32 %x, 16843009
26 %mul = mul nuw nsw i32 %and, 255
31 define i32 @orc_b_i32_sub_shl8x_x_lsb(i32 %x) {
32 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_lsb:
33 ; RV32I: # %bb.0: # %entry
34 ; RV32I-NEXT: lui a1, 4112
35 ; RV32I-NEXT: addi a1, a1, 257
36 ; RV32I-NEXT: and a0, a0, a1
37 ; RV32I-NEXT: slli a1, a0, 8
38 ; RV32I-NEXT: sub a0, a1, a0
41 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_lsb:
42 ; RV32ZBB: # %bb.0: # %entry
43 ; RV32ZBB-NEXT: lui a1, 4112
44 ; RV32ZBB-NEXT: addi a1, a1, 257
45 ; RV32ZBB-NEXT: and a0, a0, a1
46 ; RV32ZBB-NEXT: orc.b a0, a0
49 %and = and i32 %x, 16843009
50 %sub = mul nuw i32 %and, 255
54 define i32 @orc_b_i32_sub_shl8x_x_lsb_preshifted(i32 %x){
55 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_lsb_preshifted:
56 ; RV32I: # %bb.0: # %entry
57 ; RV32I-NEXT: srli a0, a0, 11
58 ; RV32I-NEXT: lui a1, 16
59 ; RV32I-NEXT: addi a1, a1, 257
60 ; RV32I-NEXT: and a0, a0, a1
61 ; RV32I-NEXT: slli a1, a0, 8
62 ; RV32I-NEXT: sub a0, a1, a0
65 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_lsb_preshifted:
66 ; RV32ZBB: # %bb.0: # %entry
67 ; RV32ZBB-NEXT: srli a0, a0, 11
68 ; RV32ZBB-NEXT: lui a1, 16
69 ; RV32ZBB-NEXT: addi a1, a1, 257
70 ; RV32ZBB-NEXT: and a0, a0, a1
71 ; RV32ZBB-NEXT: orc.b a0, a0
74 %shr = lshr i32 %x, 11
75 %and = and i32 %shr, 16843009
76 %sub = mul nuw i32 %and, 255
81 define i32 @orc_b_i32_sub_shl8x_x_b1(i32 %x) {
82 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_b1:
83 ; RV32I: # %bb.0: # %entry
84 ; RV32I-NEXT: lui a1, 8224
85 ; RV32I-NEXT: addi a1, a1, 514
86 ; RV32I-NEXT: and a0, a0, a1
87 ; RV32I-NEXT: slli a1, a0, 7
88 ; RV32I-NEXT: srli a0, a0, 1
89 ; RV32I-NEXT: sub a0, a1, a0
92 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_b1:
93 ; RV32ZBB: # %bb.0: # %entry
94 ; RV32ZBB-NEXT: lui a1, 8224
95 ; RV32ZBB-NEXT: addi a1, a1, 514
96 ; RV32ZBB-NEXT: and a0, a0, a1
97 ; RV32ZBB-NEXT: orc.b a0, a0
100 %and = and i32 %x, 33686018
101 %shl = shl i32 %and, 7
102 %shr = lshr exact i32 %and, 1
103 %sub = sub nsw i32 %shl, %shr
108 define i32 @orc_b_i32_sub_shl8x_x_b2(i32 %x) {
109 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_b2:
110 ; RV32I: # %bb.0: # %entry
111 ; RV32I-NEXT: lui a1, 16448
112 ; RV32I-NEXT: addi a1, a1, 1028
113 ; RV32I-NEXT: and a0, a0, a1
114 ; RV32I-NEXT: slli a1, a0, 6
115 ; RV32I-NEXT: srli a0, a0, 2
116 ; RV32I-NEXT: sub a0, a1, a0
119 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_b2:
120 ; RV32ZBB: # %bb.0: # %entry
121 ; RV32ZBB-NEXT: lui a1, 16448
122 ; RV32ZBB-NEXT: addi a1, a1, 1028
123 ; RV32ZBB-NEXT: and a0, a0, a1
124 ; RV32ZBB-NEXT: orc.b a0, a0
127 %and = and i32 %x, 67372036
128 %shl = shl i32 %and, 6
129 %shr = lshr exact i32 %and, 2
130 %sub = sub nsw i32 %shl, %shr
135 define i32 @orc_b_i32_sub_shl8x_x_b3(i32 %x) {
136 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b3:
137 ; CHECK: # %bb.0: # %entry
138 ; CHECK-NEXT: lui a1, 24672
139 ; CHECK-NEXT: addi a1, a1, 1542
140 ; CHECK-NEXT: and a0, a0, a1
141 ; CHECK-NEXT: slli a1, a0, 5
142 ; CHECK-NEXT: srli a0, a0, 3
143 ; CHECK-NEXT: sub a0, a1, a0
146 %and = and i32 %x, 101058054
147 %shl = shl nuw i32 %and, 5
148 %shr = lshr i32 %and, 3
149 %sub = sub nsw i32 %shl, %shr
154 define i32 @orc_b_i32_sub_shl8x_x_b4(i32 %x) {
155 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b4:
156 ; CHECK: # %bb.0: # %entry
157 ; CHECK-NEXT: lui a1, 32897
158 ; CHECK-NEXT: addi a1, a1, -2040
159 ; CHECK-NEXT: and a0, a0, a1
160 ; CHECK-NEXT: slli a1, a0, 4
161 ; CHECK-NEXT: srli a0, a0, 4
162 ; CHECK-NEXT: sub a0, a1, a0
165 %and = and i32 %x, 134744072
166 %shl = shl nuw i32 %and, 4
167 %shr = lshr i32 %and, 4
168 %sub = sub nsw i32 %shl, %shr
173 define i32 @orc_b_i32_sub_shl8x_x_b5(i32 %x) {
174 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b5:
175 ; CHECK: # %bb.0: # %entry
176 ; CHECK-NEXT: lui a1, 65793
177 ; CHECK-NEXT: addi a1, a1, 16
178 ; CHECK-NEXT: and a0, a0, a1
179 ; CHECK-NEXT: slli a1, a0, 3
180 ; CHECK-NEXT: srli a0, a0, 5
181 ; CHECK-NEXT: sub a0, a1, a0
184 %and = and i32 %x, 269488144
185 %shl = shl nuw i32 %and, 3
186 %shr = lshr i32 %and, 5
187 %sub = sub nsw i32 %shl, %shr
192 define i32 @orc_b_i32_sub_shl8x_x_b6(i32 %x) {
193 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b6:
194 ; CHECK: # %bb.0: # %entry
195 ; CHECK-NEXT: lui a1, 131586
196 ; CHECK-NEXT: addi a1, a1, 32
197 ; CHECK-NEXT: and a0, a0, a1
198 ; CHECK-NEXT: slli a1, a0, 2
199 ; CHECK-NEXT: srli a0, a0, 6
200 ; CHECK-NEXT: sub a0, a1, a0
203 %and = and i32 %x, 538976288
204 %shl = shl nuw i32 %and, 2
205 %shr = lshr i32 %and, 6
206 %sub = sub nsw i32 %shl, %shr
211 define i32 @orc_b_i32_sub_shl8x_x_b7(i32 %x) {
212 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b7:
213 ; CHECK: # %bb.0: # %entry
214 ; CHECK-NEXT: lui a1, 263172
215 ; CHECK-NEXT: addi a1, a1, 64
216 ; CHECK-NEXT: and a0, a0, a1
217 ; CHECK-NEXT: slli a1, a0, 1
218 ; CHECK-NEXT: srli a0, a0, 7
219 ; CHECK-NEXT: sub a0, a1, a0
222 %and = and i32 %x, 1077952576
223 %shl = shl nuw i32 %and, 1
224 %shr = lshr i32 %and, 7
225 %sub = sub nsw i32 %shl, %shr
229 define i32 @orc_b_i32_sub_shl8x_x_b1_shl_used(i32 %x, ptr %arr) {
230 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_b1_shl_used:
231 ; RV32I: # %bb.0: # %entry
232 ; RV32I-NEXT: lui a2, 8224
233 ; RV32I-NEXT: addi a2, a2, 514
234 ; RV32I-NEXT: and a0, a0, a2
235 ; RV32I-NEXT: slli a2, a0, 7
236 ; RV32I-NEXT: srli a3, a0, 1
237 ; RV32I-NEXT: sub a0, a2, a3
238 ; RV32I-NEXT: sw a3, 0(a1)
241 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_b1_shl_used:
242 ; RV32ZBB: # %bb.0: # %entry
243 ; RV32ZBB-NEXT: lui a2, 8224
244 ; RV32ZBB-NEXT: addi a2, a2, 514
245 ; RV32ZBB-NEXT: and a0, a0, a2
246 ; RV32ZBB-NEXT: srli a2, a0, 1
247 ; RV32ZBB-NEXT: orc.b a0, a0
248 ; RV32ZBB-NEXT: sw a2, 0(a1)
251 %and = and i32 %x, 33686018
252 %shl = shl i32 %and, 7
253 %shr = lshr exact i32 %and, 1
254 store i32 %shr, ptr %arr, align 4
255 %sub = sub nsw i32 %shl, %shr
259 define i32 @orc_b_i32_sub_shl8x_x_b1_srl_used(i32 %x, ptr %arr) {
260 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_b1_srl_used:
261 ; RV32I: # %bb.0: # %entry
262 ; RV32I-NEXT: lui a2, 8224
263 ; RV32I-NEXT: addi a2, a2, 514
264 ; RV32I-NEXT: and a0, a0, a2
265 ; RV32I-NEXT: slli a2, a0, 7
266 ; RV32I-NEXT: srli a0, a0, 1
267 ; RV32I-NEXT: sub a0, a2, a0
268 ; RV32I-NEXT: sw a2, 0(a1)
271 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_b1_srl_used:
272 ; RV32ZBB: # %bb.0: # %entry
273 ; RV32ZBB-NEXT: lui a2, 8224
274 ; RV32ZBB-NEXT: addi a2, a2, 514
275 ; RV32ZBB-NEXT: and a0, a0, a2
276 ; RV32ZBB-NEXT: slli a2, a0, 7
277 ; RV32ZBB-NEXT: orc.b a0, a0
278 ; RV32ZBB-NEXT: sw a2, 0(a1)
281 %and = and i32 %x, 33686018
282 %shl = shl i32 %and, 7
283 %shr = lshr exact i32 %and, 1
284 store i32 %shl, ptr %arr, align 4
285 %sub = sub nsw i32 %shl, %shr
290 define i32 @orc_b_i32_sub_shl8x_x_b1_not_used(i32 %x, ptr %arr) {
291 ; RV32I-LABEL: orc_b_i32_sub_shl8x_x_b1_not_used:
292 ; RV32I: # %bb.0: # %entry
293 ; RV32I-NEXT: lui a1, 8224
294 ; RV32I-NEXT: addi a1, a1, 514
295 ; RV32I-NEXT: and a0, a0, a1
296 ; RV32I-NEXT: slli a1, a0, 7
297 ; RV32I-NEXT: srli a0, a0, 1
298 ; RV32I-NEXT: sub a0, a1, a0
301 ; RV32ZBB-LABEL: orc_b_i32_sub_shl8x_x_b1_not_used:
302 ; RV32ZBB: # %bb.0: # %entry
303 ; RV32ZBB-NEXT: lui a1, 8224
304 ; RV32ZBB-NEXT: addi a1, a1, 514
305 ; RV32ZBB-NEXT: and a0, a0, a1
306 ; RV32ZBB-NEXT: orc.b a0, a0
309 %and = and i32 %x, 33686018
310 %shl = shl i32 %and, 7
311 %shr = lshr exact i32 %and, 1
312 %sub = sub nsw i32 %shl, %shr
316 define i32 @orc_b_i32_sub_shl8x_x_shl_used(i32 %x, ptr %arr){
317 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_shl_used:
318 ; CHECK: # %bb.0: # %entry
319 ; CHECK-NEXT: lui a2, 4112
320 ; CHECK-NEXT: addi a2, a2, 257
321 ; CHECK-NEXT: and a0, a0, a2
322 ; CHECK-NEXT: slli a2, a0, 8
323 ; CHECK-NEXT: sub a0, a2, a0
324 ; CHECK-NEXT: sw a2, 0(a1)
327 %and = and i32 %x, 16843009
328 %shl = shl i32 %and, 8
329 store i32 %shl, ptr %arr, align 4
330 %sub = mul nuw i32 %and, 255
334 define i32 @orc_b_i32_sub_shl8x_x_b1_both_used(i32 %x, ptr %arr) {
335 ; CHECK-LABEL: orc_b_i32_sub_shl8x_x_b1_both_used:
336 ; CHECK: # %bb.0: # %entry
337 ; CHECK-NEXT: lui a2, 8224
338 ; CHECK-NEXT: addi a2, a2, 514
339 ; CHECK-NEXT: and a0, a0, a2
340 ; CHECK-NEXT: slli a2, a0, 7
341 ; CHECK-NEXT: srli a3, a0, 1
342 ; CHECK-NEXT: sub a0, a2, a3
343 ; CHECK-NEXT: sw a2, 0(a1)
344 ; CHECK-NEXT: sw a3, 4(a1)
347 %and = and i32 %x, 33686018
348 %shl = shl i32 %and, 7
349 %shr = lshr exact i32 %and, 1
350 store i32 %shl, ptr %arr, align 4
351 %arrayidx1 = getelementptr inbounds i8, ptr %arr, i32 4
352 store i32 %shr, ptr %arrayidx1, align 4
353 %sub = sub nsw i32 %shl, %shr
358 define i32 @orc_b_i32_sub_x_shr8x(i32 %x) {
359 ; CHECK-LABEL: orc_b_i32_sub_x_shr8x:
360 ; CHECK: # %bb.0: # %entry
361 ; CHECK-NEXT: lui a1, 4112
362 ; CHECK-NEXT: addi a1, a1, 257
363 ; CHECK-NEXT: and a0, a0, a1
364 ; CHECK-NEXT: srli a1, a0, 8
365 ; CHECK-NEXT: sub a0, a0, a1
368 %and = and i32 %x, 16843009
369 %shr = lshr i32 %and, 8
370 %sub = sub nsw i32 %and, %shr