1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64I
4 ; RUN: llc -mtriple=riscv64 -mattr=+zbb -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64ZBB
7 declare i32 @llvm.ctlz.i32(i32, i1)
9 define signext i32 @ctlz_i32(i32 signext %a) nounwind {
10 ; RV64I-LABEL: ctlz_i32:
12 ; RV64I-NEXT: beqz a0, .LBB0_2
13 ; RV64I-NEXT: # %bb.1: # %cond.false
14 ; RV64I-NEXT: addi sp, sp, -16
15 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
16 ; RV64I-NEXT: srliw a1, a0, 1
17 ; RV64I-NEXT: or a0, a0, a1
18 ; RV64I-NEXT: srliw a1, a0, 2
19 ; RV64I-NEXT: or a0, a0, a1
20 ; RV64I-NEXT: srliw a1, a0, 4
21 ; RV64I-NEXT: or a0, a0, a1
22 ; RV64I-NEXT: srliw a1, a0, 8
23 ; RV64I-NEXT: or a0, a0, a1
24 ; RV64I-NEXT: srliw a1, a0, 16
25 ; RV64I-NEXT: or a0, a0, a1
26 ; RV64I-NEXT: not a0, a0
27 ; RV64I-NEXT: srli a1, a0, 1
28 ; RV64I-NEXT: lui a2, 349525
29 ; RV64I-NEXT: addiw a2, a2, 1365
30 ; RV64I-NEXT: and a1, a1, a2
31 ; RV64I-NEXT: sub a0, a0, a1
32 ; RV64I-NEXT: lui a1, 209715
33 ; RV64I-NEXT: addiw a1, a1, 819
34 ; RV64I-NEXT: and a2, a0, a1
35 ; RV64I-NEXT: srli a0, a0, 2
36 ; RV64I-NEXT: and a0, a0, a1
37 ; RV64I-NEXT: add a0, a2, a0
38 ; RV64I-NEXT: srli a1, a0, 4
39 ; RV64I-NEXT: add a0, a0, a1
40 ; RV64I-NEXT: lui a1, 61681
41 ; RV64I-NEXT: addiw a1, a1, -241
42 ; RV64I-NEXT: and a0, a0, a1
43 ; RV64I-NEXT: lui a1, 4112
44 ; RV64I-NEXT: addiw a1, a1, 257
45 ; RV64I-NEXT: call __muldi3@plt
46 ; RV64I-NEXT: srliw a0, a0, 24
47 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
48 ; RV64I-NEXT: addi sp, sp, 16
50 ; RV64I-NEXT: .LBB0_2:
51 ; RV64I-NEXT: li a0, 32
54 ; RV64ZBB-LABEL: ctlz_i32:
56 ; RV64ZBB-NEXT: clzw a0, a0
58 %1 = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
62 define signext i32 @log2_i32(i32 signext %a) nounwind {
63 ; RV64I-LABEL: log2_i32:
65 ; RV64I-NEXT: beqz a0, .LBB1_2
66 ; RV64I-NEXT: # %bb.1: # %cond.false
67 ; RV64I-NEXT: addi sp, sp, -16
68 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
69 ; RV64I-NEXT: srliw a1, a0, 1
70 ; RV64I-NEXT: or a0, a0, a1
71 ; RV64I-NEXT: srliw a1, a0, 2
72 ; RV64I-NEXT: or a0, a0, a1
73 ; RV64I-NEXT: srliw a1, a0, 4
74 ; RV64I-NEXT: or a0, a0, a1
75 ; RV64I-NEXT: srliw a1, a0, 8
76 ; RV64I-NEXT: or a0, a0, a1
77 ; RV64I-NEXT: srliw a1, a0, 16
78 ; RV64I-NEXT: or a0, a0, a1
79 ; RV64I-NEXT: not a0, a0
80 ; RV64I-NEXT: srli a1, a0, 1
81 ; RV64I-NEXT: lui a2, 349525
82 ; RV64I-NEXT: addiw a2, a2, 1365
83 ; RV64I-NEXT: and a1, a1, a2
84 ; RV64I-NEXT: sub a0, a0, a1
85 ; RV64I-NEXT: lui a1, 209715
86 ; RV64I-NEXT: addiw a1, a1, 819
87 ; RV64I-NEXT: and a2, a0, a1
88 ; RV64I-NEXT: srli a0, a0, 2
89 ; RV64I-NEXT: and a0, a0, a1
90 ; RV64I-NEXT: add a0, a2, a0
91 ; RV64I-NEXT: srli a1, a0, 4
92 ; RV64I-NEXT: add a0, a0, a1
93 ; RV64I-NEXT: lui a1, 61681
94 ; RV64I-NEXT: addiw a1, a1, -241
95 ; RV64I-NEXT: and a0, a0, a1
96 ; RV64I-NEXT: lui a1, 4112
97 ; RV64I-NEXT: addiw a1, a1, 257
98 ; RV64I-NEXT: call __muldi3@plt
99 ; RV64I-NEXT: srliw a0, a0, 24
100 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
101 ; RV64I-NEXT: addi sp, sp, 16
102 ; RV64I-NEXT: j .LBB1_3
103 ; RV64I-NEXT: .LBB1_2:
104 ; RV64I-NEXT: li a0, 32
105 ; RV64I-NEXT: .LBB1_3: # %cond.end
106 ; RV64I-NEXT: li a1, 31
107 ; RV64I-NEXT: sub a0, a1, a0
110 ; RV64ZBB-LABEL: log2_i32:
112 ; RV64ZBB-NEXT: clzw a0, a0
113 ; RV64ZBB-NEXT: li a1, 31
114 ; RV64ZBB-NEXT: sub a0, a1, a0
116 %1 = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
121 define signext i32 @log2_ceil_i32(i32 signext %a) nounwind {
122 ; RV64I-LABEL: log2_ceil_i32:
124 ; RV64I-NEXT: addi sp, sp, -16
125 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
126 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
127 ; RV64I-NEXT: addiw a0, a0, -1
128 ; RV64I-NEXT: li s0, 32
129 ; RV64I-NEXT: li a1, 32
130 ; RV64I-NEXT: beqz a0, .LBB2_2
131 ; RV64I-NEXT: # %bb.1: # %cond.false
132 ; RV64I-NEXT: srliw a1, a0, 1
133 ; RV64I-NEXT: or a0, a0, a1
134 ; RV64I-NEXT: srliw a1, a0, 2
135 ; RV64I-NEXT: or a0, a0, a1
136 ; RV64I-NEXT: srliw a1, a0, 4
137 ; RV64I-NEXT: or a0, a0, a1
138 ; RV64I-NEXT: srliw a1, a0, 8
139 ; RV64I-NEXT: or a0, a0, a1
140 ; RV64I-NEXT: srliw a1, a0, 16
141 ; RV64I-NEXT: or a0, a0, a1
142 ; RV64I-NEXT: not a0, a0
143 ; RV64I-NEXT: srli a1, a0, 1
144 ; RV64I-NEXT: lui a2, 349525
145 ; RV64I-NEXT: addiw a2, a2, 1365
146 ; RV64I-NEXT: and a1, a1, a2
147 ; RV64I-NEXT: sub a0, a0, a1
148 ; RV64I-NEXT: lui a1, 209715
149 ; RV64I-NEXT: addiw a1, a1, 819
150 ; RV64I-NEXT: and a2, a0, a1
151 ; RV64I-NEXT: srli a0, a0, 2
152 ; RV64I-NEXT: and a0, a0, a1
153 ; RV64I-NEXT: add a0, a2, a0
154 ; RV64I-NEXT: srli a1, a0, 4
155 ; RV64I-NEXT: add a0, a0, a1
156 ; RV64I-NEXT: lui a1, 61681
157 ; RV64I-NEXT: addiw a1, a1, -241
158 ; RV64I-NEXT: and a0, a0, a1
159 ; RV64I-NEXT: lui a1, 4112
160 ; RV64I-NEXT: addiw a1, a1, 257
161 ; RV64I-NEXT: call __muldi3@plt
162 ; RV64I-NEXT: srliw a1, a0, 24
163 ; RV64I-NEXT: .LBB2_2: # %cond.end
164 ; RV64I-NEXT: sub a0, s0, a1
165 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
166 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
167 ; RV64I-NEXT: addi sp, sp, 16
170 ; RV64ZBB-LABEL: log2_ceil_i32:
172 ; RV64ZBB-NEXT: addiw a0, a0, -1
173 ; RV64ZBB-NEXT: clzw a0, a0
174 ; RV64ZBB-NEXT: li a1, 32
175 ; RV64ZBB-NEXT: sub a0, a1, a0
178 %2 = call i32 @llvm.ctlz.i32(i32 %1, i1 false)
183 define signext i32 @findLastSet_i32(i32 signext %a) nounwind {
184 ; RV64I-LABEL: findLastSet_i32:
186 ; RV64I-NEXT: addi sp, sp, -16
187 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
188 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
189 ; RV64I-NEXT: mv s0, a0
190 ; RV64I-NEXT: srliw a0, a0, 1
191 ; RV64I-NEXT: or a0, s0, a0
192 ; RV64I-NEXT: srliw a1, a0, 2
193 ; RV64I-NEXT: or a0, a0, a1
194 ; RV64I-NEXT: srliw a1, a0, 4
195 ; RV64I-NEXT: or a0, a0, a1
196 ; RV64I-NEXT: srliw a1, a0, 8
197 ; RV64I-NEXT: or a0, a0, a1
198 ; RV64I-NEXT: srliw a1, a0, 16
199 ; RV64I-NEXT: or a0, a0, a1
200 ; RV64I-NEXT: not a0, a0
201 ; RV64I-NEXT: srli a1, a0, 1
202 ; RV64I-NEXT: lui a2, 349525
203 ; RV64I-NEXT: addiw a2, a2, 1365
204 ; RV64I-NEXT: and a1, a1, a2
205 ; RV64I-NEXT: sub a0, a0, a1
206 ; RV64I-NEXT: lui a1, 209715
207 ; RV64I-NEXT: addiw a1, a1, 819
208 ; RV64I-NEXT: and a2, a0, a1
209 ; RV64I-NEXT: srli a0, a0, 2
210 ; RV64I-NEXT: and a0, a0, a1
211 ; RV64I-NEXT: add a0, a2, a0
212 ; RV64I-NEXT: srli a1, a0, 4
213 ; RV64I-NEXT: add a0, a0, a1
214 ; RV64I-NEXT: lui a1, 61681
215 ; RV64I-NEXT: addiw a1, a1, -241
216 ; RV64I-NEXT: and a0, a0, a1
217 ; RV64I-NEXT: lui a1, 4112
218 ; RV64I-NEXT: addiw a1, a1, 257
219 ; RV64I-NEXT: call __muldi3@plt
220 ; RV64I-NEXT: mv a1, a0
221 ; RV64I-NEXT: li a0, -1
222 ; RV64I-NEXT: beqz s0, .LBB3_2
223 ; RV64I-NEXT: # %bb.1:
224 ; RV64I-NEXT: srliw a0, a1, 24
225 ; RV64I-NEXT: xori a0, a0, 31
226 ; RV64I-NEXT: .LBB3_2:
227 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
228 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
229 ; RV64I-NEXT: addi sp, sp, 16
232 ; RV64ZBB-LABEL: findLastSet_i32:
234 ; RV64ZBB-NEXT: mv a1, a0
235 ; RV64ZBB-NEXT: li a0, -1
236 ; RV64ZBB-NEXT: beqz a1, .LBB3_2
237 ; RV64ZBB-NEXT: # %bb.1:
238 ; RV64ZBB-NEXT: clzw a0, a1
239 ; RV64ZBB-NEXT: xori a0, a0, 31
240 ; RV64ZBB-NEXT: .LBB3_2:
242 %1 = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
244 %3 = icmp eq i32 %a, 0
245 %4 = select i1 %3, i32 -1, i32 %2
249 define i32 @ctlz_lshr_i32(i32 signext %a) {
250 ; RV64I-LABEL: ctlz_lshr_i32:
252 ; RV64I-NEXT: srliw a0, a0, 1
253 ; RV64I-NEXT: beqz a0, .LBB4_2
254 ; RV64I-NEXT: # %bb.1: # %cond.false
255 ; RV64I-NEXT: addi sp, sp, -16
256 ; RV64I-NEXT: .cfi_def_cfa_offset 16
257 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
258 ; RV64I-NEXT: .cfi_offset ra, -8
259 ; RV64I-NEXT: srliw a1, a0, 1
260 ; RV64I-NEXT: or a0, a0, a1
261 ; RV64I-NEXT: srliw a1, a0, 2
262 ; RV64I-NEXT: or a0, a0, a1
263 ; RV64I-NEXT: srliw a1, a0, 4
264 ; RV64I-NEXT: or a0, a0, a1
265 ; RV64I-NEXT: srliw a1, a0, 8
266 ; RV64I-NEXT: or a0, a0, a1
267 ; RV64I-NEXT: srliw a1, a0, 16
268 ; RV64I-NEXT: or a0, a0, a1
269 ; RV64I-NEXT: not a0, a0
270 ; RV64I-NEXT: srli a1, a0, 1
271 ; RV64I-NEXT: lui a2, 349525
272 ; RV64I-NEXT: addiw a2, a2, 1365
273 ; RV64I-NEXT: and a1, a1, a2
274 ; RV64I-NEXT: sub a0, a0, a1
275 ; RV64I-NEXT: lui a1, 209715
276 ; RV64I-NEXT: addiw a1, a1, 819
277 ; RV64I-NEXT: and a2, a0, a1
278 ; RV64I-NEXT: srli a0, a0, 2
279 ; RV64I-NEXT: and a0, a0, a1
280 ; RV64I-NEXT: add a0, a2, a0
281 ; RV64I-NEXT: srli a1, a0, 4
282 ; RV64I-NEXT: add a0, a0, a1
283 ; RV64I-NEXT: lui a1, 61681
284 ; RV64I-NEXT: addiw a1, a1, -241
285 ; RV64I-NEXT: and a0, a0, a1
286 ; RV64I-NEXT: lui a1, 4112
287 ; RV64I-NEXT: addiw a1, a1, 257
288 ; RV64I-NEXT: call __muldi3@plt
289 ; RV64I-NEXT: srliw a0, a0, 24
290 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
291 ; RV64I-NEXT: addi sp, sp, 16
293 ; RV64I-NEXT: .LBB4_2:
294 ; RV64I-NEXT: li a0, 32
297 ; RV64ZBB-LABEL: ctlz_lshr_i32:
299 ; RV64ZBB-NEXT: srliw a0, a0, 1
300 ; RV64ZBB-NEXT: clzw a0, a0
303 %2 = call i32 @llvm.ctlz.i32(i32 %1, i1 false)
307 declare i64 @llvm.ctlz.i64(i64, i1)
309 define i64 @ctlz_i64(i64 %a) nounwind {
310 ; RV64I-LABEL: ctlz_i64:
312 ; RV64I-NEXT: beqz a0, .LBB5_2
313 ; RV64I-NEXT: # %bb.1: # %cond.false
314 ; RV64I-NEXT: addi sp, sp, -16
315 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
316 ; RV64I-NEXT: srli a1, a0, 1
317 ; RV64I-NEXT: or a0, a0, a1
318 ; RV64I-NEXT: srli a1, a0, 2
319 ; RV64I-NEXT: or a0, a0, a1
320 ; RV64I-NEXT: srli a1, a0, 4
321 ; RV64I-NEXT: or a0, a0, a1
322 ; RV64I-NEXT: srli a1, a0, 8
323 ; RV64I-NEXT: or a0, a0, a1
324 ; RV64I-NEXT: srli a1, a0, 16
325 ; RV64I-NEXT: or a0, a0, a1
326 ; RV64I-NEXT: srli a1, a0, 32
327 ; RV64I-NEXT: or a0, a0, a1
328 ; RV64I-NEXT: not a0, a0
329 ; RV64I-NEXT: lui a1, %hi(.LCPI5_0)
330 ; RV64I-NEXT: ld a1, %lo(.LCPI5_0)(a1)
331 ; RV64I-NEXT: lui a2, %hi(.LCPI5_1)
332 ; RV64I-NEXT: ld a2, %lo(.LCPI5_1)(a2)
333 ; RV64I-NEXT: srli a3, a0, 1
334 ; RV64I-NEXT: and a1, a3, a1
335 ; RV64I-NEXT: sub a0, a0, a1
336 ; RV64I-NEXT: and a1, a0, a2
337 ; RV64I-NEXT: srli a0, a0, 2
338 ; RV64I-NEXT: and a0, a0, a2
339 ; RV64I-NEXT: lui a2, %hi(.LCPI5_2)
340 ; RV64I-NEXT: ld a2, %lo(.LCPI5_2)(a2)
341 ; RV64I-NEXT: add a0, a1, a0
342 ; RV64I-NEXT: srli a1, a0, 4
343 ; RV64I-NEXT: add a0, a0, a1
344 ; RV64I-NEXT: and a0, a0, a2
345 ; RV64I-NEXT: lui a1, %hi(.LCPI5_3)
346 ; RV64I-NEXT: ld a1, %lo(.LCPI5_3)(a1)
347 ; RV64I-NEXT: call __muldi3@plt
348 ; RV64I-NEXT: srli a0, a0, 56
349 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
350 ; RV64I-NEXT: addi sp, sp, 16
352 ; RV64I-NEXT: .LBB5_2:
353 ; RV64I-NEXT: li a0, 64
356 ; RV64ZBB-LABEL: ctlz_i64:
358 ; RV64ZBB-NEXT: clz a0, a0
360 %1 = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
364 declare i32 @llvm.cttz.i32(i32, i1)
366 define signext i32 @cttz_i32(i32 signext %a) nounwind {
367 ; RV64I-LABEL: cttz_i32:
369 ; RV64I-NEXT: beqz a0, .LBB6_4
370 ; RV64I-NEXT: # %bb.1: # %cond.false
371 ; RV64I-NEXT: addi sp, sp, -16
372 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
373 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
374 ; RV64I-NEXT: mv s0, a0
375 ; RV64I-NEXT: neg a0, a0
376 ; RV64I-NEXT: and a0, s0, a0
377 ; RV64I-NEXT: lui a1, 30667
378 ; RV64I-NEXT: addiw a1, a1, 1329
379 ; RV64I-NEXT: call __muldi3@plt
380 ; RV64I-NEXT: mv a1, a0
381 ; RV64I-NEXT: li a0, 32
382 ; RV64I-NEXT: beqz s0, .LBB6_3
383 ; RV64I-NEXT: # %bb.2: # %cond.false
384 ; RV64I-NEXT: srliw a0, a1, 27
385 ; RV64I-NEXT: lui a1, %hi(.LCPI6_0)
386 ; RV64I-NEXT: addi a1, a1, %lo(.LCPI6_0)
387 ; RV64I-NEXT: add a0, a1, a0
388 ; RV64I-NEXT: lbu a0, 0(a0)
389 ; RV64I-NEXT: .LBB6_3: # %cond.false
390 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
391 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
392 ; RV64I-NEXT: addi sp, sp, 16
394 ; RV64I-NEXT: .LBB6_4:
395 ; RV64I-NEXT: li a0, 32
398 ; RV64ZBB-LABEL: cttz_i32:
400 ; RV64ZBB-NEXT: ctzw a0, a0
402 %1 = call i32 @llvm.cttz.i32(i32 %a, i1 false)
406 define signext i32 @cttz_zero_undef_i32(i32 signext %a) nounwind {
407 ; RV64I-LABEL: cttz_zero_undef_i32:
409 ; RV64I-NEXT: addi sp, sp, -16
410 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
411 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
412 ; RV64I-NEXT: mv s0, a0
413 ; RV64I-NEXT: neg a0, a0
414 ; RV64I-NEXT: and a0, s0, a0
415 ; RV64I-NEXT: lui a1, 30667
416 ; RV64I-NEXT: addiw a1, a1, 1329
417 ; RV64I-NEXT: call __muldi3@plt
418 ; RV64I-NEXT: mv a1, a0
419 ; RV64I-NEXT: li a0, 32
420 ; RV64I-NEXT: beqz s0, .LBB7_2
421 ; RV64I-NEXT: # %bb.1:
422 ; RV64I-NEXT: srliw a0, a1, 27
423 ; RV64I-NEXT: lui a1, %hi(.LCPI7_0)
424 ; RV64I-NEXT: addi a1, a1, %lo(.LCPI7_0)
425 ; RV64I-NEXT: add a0, a1, a0
426 ; RV64I-NEXT: lbu a0, 0(a0)
427 ; RV64I-NEXT: .LBB7_2:
428 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
429 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
430 ; RV64I-NEXT: addi sp, sp, 16
433 ; RV64ZBB-LABEL: cttz_zero_undef_i32:
435 ; RV64ZBB-NEXT: ctzw a0, a0
437 %1 = call i32 @llvm.cttz.i32(i32 %a, i1 true)
441 define signext i32 @findFirstSet_i32(i32 signext %a) nounwind {
442 ; RV64I-LABEL: findFirstSet_i32:
444 ; RV64I-NEXT: addi sp, sp, -16
445 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
446 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
447 ; RV64I-NEXT: mv s0, a0
448 ; RV64I-NEXT: neg a0, a0
449 ; RV64I-NEXT: and a0, s0, a0
450 ; RV64I-NEXT: lui a1, 30667
451 ; RV64I-NEXT: addiw a1, a1, 1329
452 ; RV64I-NEXT: call __muldi3@plt
453 ; RV64I-NEXT: li a1, 32
454 ; RV64I-NEXT: beqz s0, .LBB8_2
455 ; RV64I-NEXT: # %bb.1:
456 ; RV64I-NEXT: srliw a0, a0, 27
457 ; RV64I-NEXT: lui a1, %hi(.LCPI8_0)
458 ; RV64I-NEXT: addi a1, a1, %lo(.LCPI8_0)
459 ; RV64I-NEXT: add a0, a1, a0
460 ; RV64I-NEXT: lbu a1, 0(a0)
461 ; RV64I-NEXT: .LBB8_2:
462 ; RV64I-NEXT: li a0, -1
463 ; RV64I-NEXT: beqz s0, .LBB8_4
464 ; RV64I-NEXT: # %bb.3:
465 ; RV64I-NEXT: mv a0, a1
466 ; RV64I-NEXT: .LBB8_4:
467 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
468 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
469 ; RV64I-NEXT: addi sp, sp, 16
472 ; RV64ZBB-LABEL: findFirstSet_i32:
474 ; RV64ZBB-NEXT: mv a1, a0
475 ; RV64ZBB-NEXT: li a0, -1
476 ; RV64ZBB-NEXT: beqz a1, .LBB8_2
477 ; RV64ZBB-NEXT: # %bb.1:
478 ; RV64ZBB-NEXT: ctzw a0, a1
479 ; RV64ZBB-NEXT: .LBB8_2:
481 %1 = call i32 @llvm.cttz.i32(i32 %a, i1 true)
482 %2 = icmp eq i32 %a, 0
483 %3 = select i1 %2, i32 -1, i32 %1
487 define signext i32 @ffs_i32(i32 signext %a) nounwind {
488 ; RV64I-LABEL: ffs_i32:
490 ; RV64I-NEXT: addi sp, sp, -32
491 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
492 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
493 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
494 ; RV64I-NEXT: mv s1, a0
495 ; RV64I-NEXT: li s0, 0
496 ; RV64I-NEXT: neg a0, a0
497 ; RV64I-NEXT: and a0, s1, a0
498 ; RV64I-NEXT: lui a1, 30667
499 ; RV64I-NEXT: addiw a1, a1, 1329
500 ; RV64I-NEXT: call __muldi3@plt
501 ; RV64I-NEXT: li a1, 32
502 ; RV64I-NEXT: beqz s1, .LBB9_2
503 ; RV64I-NEXT: # %bb.1:
504 ; RV64I-NEXT: srliw a0, a0, 27
505 ; RV64I-NEXT: lui a1, %hi(.LCPI9_0)
506 ; RV64I-NEXT: addi a1, a1, %lo(.LCPI9_0)
507 ; RV64I-NEXT: add a0, a1, a0
508 ; RV64I-NEXT: lbu a1, 0(a0)
509 ; RV64I-NEXT: .LBB9_2:
510 ; RV64I-NEXT: beqz s1, .LBB9_4
511 ; RV64I-NEXT: # %bb.3:
512 ; RV64I-NEXT: addi s0, a1, 1
513 ; RV64I-NEXT: .LBB9_4:
514 ; RV64I-NEXT: mv a0, s0
515 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
516 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
517 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
518 ; RV64I-NEXT: addi sp, sp, 32
521 ; RV64ZBB-LABEL: ffs_i32:
523 ; RV64ZBB-NEXT: mv a1, a0
524 ; RV64ZBB-NEXT: li a0, 0
525 ; RV64ZBB-NEXT: beqz a1, .LBB9_2
526 ; RV64ZBB-NEXT: # %bb.1:
527 ; RV64ZBB-NEXT: ctzw a0, a1
528 ; RV64ZBB-NEXT: addi a0, a0, 1
529 ; RV64ZBB-NEXT: .LBB9_2:
531 %1 = call i32 @llvm.cttz.i32(i32 %a, i1 true)
533 %3 = icmp eq i32 %a, 0
534 %4 = select i1 %3, i32 0, i32 %2
538 declare i64 @llvm.cttz.i64(i64, i1)
540 define i64 @cttz_i64(i64 %a) nounwind {
541 ; RV64I-LABEL: cttz_i64:
543 ; RV64I-NEXT: beqz a0, .LBB10_4
544 ; RV64I-NEXT: # %bb.1: # %cond.false
545 ; RV64I-NEXT: addi sp, sp, -16
546 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
547 ; RV64I-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
548 ; RV64I-NEXT: mv s0, a0
549 ; RV64I-NEXT: neg a0, a0
550 ; RV64I-NEXT: and a0, s0, a0
551 ; RV64I-NEXT: lui a1, %hi(.LCPI10_0)
552 ; RV64I-NEXT: ld a1, %lo(.LCPI10_0)(a1)
553 ; RV64I-NEXT: call __muldi3@plt
554 ; RV64I-NEXT: mv a1, a0
555 ; RV64I-NEXT: li a0, 64
556 ; RV64I-NEXT: beqz s0, .LBB10_3
557 ; RV64I-NEXT: # %bb.2: # %cond.false
558 ; RV64I-NEXT: srli a0, a1, 58
559 ; RV64I-NEXT: lui a1, %hi(.LCPI10_1)
560 ; RV64I-NEXT: addi a1, a1, %lo(.LCPI10_1)
561 ; RV64I-NEXT: add a0, a1, a0
562 ; RV64I-NEXT: lbu a0, 0(a0)
563 ; RV64I-NEXT: .LBB10_3: # %cond.false
564 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
565 ; RV64I-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
566 ; RV64I-NEXT: addi sp, sp, 16
568 ; RV64I-NEXT: .LBB10_4:
569 ; RV64I-NEXT: li a0, 64
572 ; RV64ZBB-LABEL: cttz_i64:
574 ; RV64ZBB-NEXT: ctz a0, a0
576 %1 = call i64 @llvm.cttz.i64(i64 %a, i1 false)
580 declare i32 @llvm.ctpop.i32(i32)
582 define signext i32 @ctpop_i32(i32 signext %a) nounwind {
583 ; RV64I-LABEL: ctpop_i32:
585 ; RV64I-NEXT: addi sp, sp, -16
586 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
587 ; RV64I-NEXT: srli a1, a0, 1
588 ; RV64I-NEXT: lui a2, 349525
589 ; RV64I-NEXT: addiw a2, a2, 1365
590 ; RV64I-NEXT: and a1, a1, a2
591 ; RV64I-NEXT: sub a0, a0, a1
592 ; RV64I-NEXT: lui a1, 209715
593 ; RV64I-NEXT: addiw a1, a1, 819
594 ; RV64I-NEXT: and a2, a0, a1
595 ; RV64I-NEXT: srli a0, a0, 2
596 ; RV64I-NEXT: and a0, a0, a1
597 ; RV64I-NEXT: add a0, a2, a0
598 ; RV64I-NEXT: srli a1, a0, 4
599 ; RV64I-NEXT: add a0, a0, a1
600 ; RV64I-NEXT: lui a1, 61681
601 ; RV64I-NEXT: addiw a1, a1, -241
602 ; RV64I-NEXT: and a0, a0, a1
603 ; RV64I-NEXT: lui a1, 4112
604 ; RV64I-NEXT: addiw a1, a1, 257
605 ; RV64I-NEXT: call __muldi3@plt
606 ; RV64I-NEXT: srliw a0, a0, 24
607 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
608 ; RV64I-NEXT: addi sp, sp, 16
611 ; RV64ZBB-LABEL: ctpop_i32:
613 ; RV64ZBB-NEXT: cpopw a0, a0
615 %1 = call i32 @llvm.ctpop.i32(i32 %a)
619 define signext i32 @ctpop_i32_load(i32* %p) nounwind {
620 ; RV64I-LABEL: ctpop_i32_load:
622 ; RV64I-NEXT: addi sp, sp, -16
623 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
624 ; RV64I-NEXT: lw a0, 0(a0)
625 ; RV64I-NEXT: srli a1, a0, 1
626 ; RV64I-NEXT: lui a2, 349525
627 ; RV64I-NEXT: addiw a2, a2, 1365
628 ; RV64I-NEXT: and a1, a1, a2
629 ; RV64I-NEXT: sub a0, a0, a1
630 ; RV64I-NEXT: lui a1, 209715
631 ; RV64I-NEXT: addiw a1, a1, 819
632 ; RV64I-NEXT: and a2, a0, a1
633 ; RV64I-NEXT: srli a0, a0, 2
634 ; RV64I-NEXT: and a0, a0, a1
635 ; RV64I-NEXT: add a0, a2, a0
636 ; RV64I-NEXT: srli a1, a0, 4
637 ; RV64I-NEXT: add a0, a0, a1
638 ; RV64I-NEXT: lui a1, 61681
639 ; RV64I-NEXT: addiw a1, a1, -241
640 ; RV64I-NEXT: and a0, a0, a1
641 ; RV64I-NEXT: lui a1, 4112
642 ; RV64I-NEXT: addiw a1, a1, 257
643 ; RV64I-NEXT: call __muldi3@plt
644 ; RV64I-NEXT: srliw a0, a0, 24
645 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
646 ; RV64I-NEXT: addi sp, sp, 16
649 ; RV64ZBB-LABEL: ctpop_i32_load:
651 ; RV64ZBB-NEXT: lwu a0, 0(a0)
652 ; RV64ZBB-NEXT: cpopw a0, a0
654 %a = load i32, i32* %p
655 %1 = call i32 @llvm.ctpop.i32(i32 %a)
659 declare i64 @llvm.ctpop.i64(i64)
661 define i64 @ctpop_i64(i64 %a) nounwind {
662 ; RV64I-LABEL: ctpop_i64:
664 ; RV64I-NEXT: addi sp, sp, -16
665 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
666 ; RV64I-NEXT: lui a1, %hi(.LCPI13_0)
667 ; RV64I-NEXT: ld a1, %lo(.LCPI13_0)(a1)
668 ; RV64I-NEXT: lui a2, %hi(.LCPI13_1)
669 ; RV64I-NEXT: ld a2, %lo(.LCPI13_1)(a2)
670 ; RV64I-NEXT: srli a3, a0, 1
671 ; RV64I-NEXT: and a1, a3, a1
672 ; RV64I-NEXT: sub a0, a0, a1
673 ; RV64I-NEXT: and a1, a0, a2
674 ; RV64I-NEXT: srli a0, a0, 2
675 ; RV64I-NEXT: and a0, a0, a2
676 ; RV64I-NEXT: lui a2, %hi(.LCPI13_2)
677 ; RV64I-NEXT: ld a2, %lo(.LCPI13_2)(a2)
678 ; RV64I-NEXT: add a0, a1, a0
679 ; RV64I-NEXT: srli a1, a0, 4
680 ; RV64I-NEXT: add a0, a0, a1
681 ; RV64I-NEXT: and a0, a0, a2
682 ; RV64I-NEXT: lui a1, %hi(.LCPI13_3)
683 ; RV64I-NEXT: ld a1, %lo(.LCPI13_3)(a1)
684 ; RV64I-NEXT: call __muldi3@plt
685 ; RV64I-NEXT: srli a0, a0, 56
686 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
687 ; RV64I-NEXT: addi sp, sp, 16
690 ; RV64ZBB-LABEL: ctpop_i64:
692 ; RV64ZBB-NEXT: cpop a0, a0
694 %1 = call i64 @llvm.ctpop.i64(i64 %a)
698 define signext i32 @sextb_i32(i32 signext %a) nounwind {
699 ; RV64I-LABEL: sextb_i32:
701 ; RV64I-NEXT: slli a0, a0, 56
702 ; RV64I-NEXT: srai a0, a0, 56
705 ; RV64ZBB-LABEL: sextb_i32:
707 ; RV64ZBB-NEXT: sext.b a0, a0
709 %shl = shl i32 %a, 24
710 %shr = ashr exact i32 %shl, 24
714 define i64 @sextb_i64(i64 %a) nounwind {
715 ; RV64I-LABEL: sextb_i64:
717 ; RV64I-NEXT: slli a0, a0, 56
718 ; RV64I-NEXT: srai a0, a0, 56
721 ; RV64ZBB-LABEL: sextb_i64:
723 ; RV64ZBB-NEXT: sext.b a0, a0
725 %shl = shl i64 %a, 56
726 %shr = ashr exact i64 %shl, 56
730 define signext i32 @sexth_i32(i32 signext %a) nounwind {
731 ; RV64I-LABEL: sexth_i32:
733 ; RV64I-NEXT: slli a0, a0, 48
734 ; RV64I-NEXT: srai a0, a0, 48
737 ; RV64ZBB-LABEL: sexth_i32:
739 ; RV64ZBB-NEXT: sext.h a0, a0
741 %shl = shl i32 %a, 16
742 %shr = ashr exact i32 %shl, 16
746 define i64 @sexth_i64(i64 %a) nounwind {
747 ; RV64I-LABEL: sexth_i64:
749 ; RV64I-NEXT: slli a0, a0, 48
750 ; RV64I-NEXT: srai a0, a0, 48
753 ; RV64ZBB-LABEL: sexth_i64:
755 ; RV64ZBB-NEXT: sext.h a0, a0
757 %shl = shl i64 %a, 48
758 %shr = ashr exact i64 %shl, 48
762 define signext i32 @min_i32(i32 signext %a, i32 signext %b) nounwind {
763 ; RV64I-LABEL: min_i32:
765 ; RV64I-NEXT: blt a0, a1, .LBB18_2
766 ; RV64I-NEXT: # %bb.1:
767 ; RV64I-NEXT: mv a0, a1
768 ; RV64I-NEXT: .LBB18_2:
771 ; RV64ZBB-LABEL: min_i32:
773 ; RV64ZBB-NEXT: min a0, a0, a1
775 %cmp = icmp slt i32 %a, %b
776 %cond = select i1 %cmp, i32 %a, i32 %b
780 define i64 @min_i64(i64 %a, i64 %b) nounwind {
781 ; RV64I-LABEL: min_i64:
783 ; RV64I-NEXT: blt a0, a1, .LBB19_2
784 ; RV64I-NEXT: # %bb.1:
785 ; RV64I-NEXT: mv a0, a1
786 ; RV64I-NEXT: .LBB19_2:
789 ; RV64ZBB-LABEL: min_i64:
791 ; RV64ZBB-NEXT: min a0, a0, a1
793 %cmp = icmp slt i64 %a, %b
794 %cond = select i1 %cmp, i64 %a, i64 %b
798 define signext i32 @max_i32(i32 signext %a, i32 signext %b) nounwind {
799 ; RV64I-LABEL: max_i32:
801 ; RV64I-NEXT: blt a1, a0, .LBB20_2
802 ; RV64I-NEXT: # %bb.1:
803 ; RV64I-NEXT: mv a0, a1
804 ; RV64I-NEXT: .LBB20_2:
807 ; RV64ZBB-LABEL: max_i32:
809 ; RV64ZBB-NEXT: max a0, a0, a1
811 %cmp = icmp sgt i32 %a, %b
812 %cond = select i1 %cmp, i32 %a, i32 %b
816 define i64 @max_i64(i64 %a, i64 %b) nounwind {
817 ; RV64I-LABEL: max_i64:
819 ; RV64I-NEXT: blt a1, a0, .LBB21_2
820 ; RV64I-NEXT: # %bb.1:
821 ; RV64I-NEXT: mv a0, a1
822 ; RV64I-NEXT: .LBB21_2:
825 ; RV64ZBB-LABEL: max_i64:
827 ; RV64ZBB-NEXT: max a0, a0, a1
829 %cmp = icmp sgt i64 %a, %b
830 %cond = select i1 %cmp, i64 %a, i64 %b
834 define signext i32 @minu_i32(i32 signext %a, i32 signext %b) nounwind {
835 ; RV64I-LABEL: minu_i32:
837 ; RV64I-NEXT: bltu a0, a1, .LBB22_2
838 ; RV64I-NEXT: # %bb.1:
839 ; RV64I-NEXT: mv a0, a1
840 ; RV64I-NEXT: .LBB22_2:
843 ; RV64ZBB-LABEL: minu_i32:
845 ; RV64ZBB-NEXT: minu a0, a0, a1
847 %cmp = icmp ult i32 %a, %b
848 %cond = select i1 %cmp, i32 %a, i32 %b
852 define i64 @minu_i64(i64 %a, i64 %b) nounwind {
853 ; RV64I-LABEL: minu_i64:
855 ; RV64I-NEXT: bltu a0, a1, .LBB23_2
856 ; RV64I-NEXT: # %bb.1:
857 ; RV64I-NEXT: mv a0, a1
858 ; RV64I-NEXT: .LBB23_2:
861 ; RV64ZBB-LABEL: minu_i64:
863 ; RV64ZBB-NEXT: minu a0, a0, a1
865 %cmp = icmp ult i64 %a, %b
866 %cond = select i1 %cmp, i64 %a, i64 %b
870 define signext i32 @maxu_i32(i32 signext %a, i32 signext %b) nounwind {
871 ; RV64I-LABEL: maxu_i32:
873 ; RV64I-NEXT: bltu a1, a0, .LBB24_2
874 ; RV64I-NEXT: # %bb.1:
875 ; RV64I-NEXT: mv a0, a1
876 ; RV64I-NEXT: .LBB24_2:
879 ; RV64ZBB-LABEL: maxu_i32:
881 ; RV64ZBB-NEXT: maxu a0, a0, a1
883 %cmp = icmp ugt i32 %a, %b
884 %cond = select i1 %cmp, i32 %a, i32 %b
888 define i64 @maxu_i64(i64 %a, i64 %b) nounwind {
889 ; RV64I-LABEL: maxu_i64:
891 ; RV64I-NEXT: bltu a1, a0, .LBB25_2
892 ; RV64I-NEXT: # %bb.1:
893 ; RV64I-NEXT: mv a0, a1
894 ; RV64I-NEXT: .LBB25_2:
897 ; RV64ZBB-LABEL: maxu_i64:
899 ; RV64ZBB-NEXT: maxu a0, a0, a1
901 %cmp = icmp ugt i64 %a, %b
902 %cond = select i1 %cmp, i64 %a, i64 %b
906 declare i32 @llvm.abs.i32(i32, i1 immarg)
908 define i32 @abs_i32(i32 %x) {
909 ; RV64I-LABEL: abs_i32:
911 ; RV64I-NEXT: sraiw a1, a0, 31
912 ; RV64I-NEXT: xor a0, a0, a1
913 ; RV64I-NEXT: subw a0, a0, a1
916 ; RV64ZBB-LABEL: abs_i32:
918 ; RV64ZBB-NEXT: sext.w a0, a0
919 ; RV64ZBB-NEXT: neg a1, a0
920 ; RV64ZBB-NEXT: max a0, a0, a1
922 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
926 define signext i32 @abs_i32_sext(i32 signext %x) {
927 ; RV64I-LABEL: abs_i32_sext:
929 ; RV64I-NEXT: srai a1, a0, 31
930 ; RV64I-NEXT: xor a0, a0, a1
931 ; RV64I-NEXT: subw a0, a0, a1
934 ; RV64ZBB-LABEL: abs_i32_sext:
936 ; RV64ZBB-NEXT: negw a1, a0
937 ; RV64ZBB-NEXT: max a0, a0, a1
939 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
943 declare i64 @llvm.abs.i64(i64, i1 immarg)
945 define i64 @abs_i64(i64 %x) {
946 ; RV64I-LABEL: abs_i64:
948 ; RV64I-NEXT: srai a1, a0, 63
949 ; RV64I-NEXT: xor a0, a0, a1
950 ; RV64I-NEXT: sub a0, a0, a1
953 ; RV64ZBB-LABEL: abs_i64:
955 ; RV64ZBB-NEXT: neg a1, a0
956 ; RV64ZBB-NEXT: max a0, a0, a1
958 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
962 define i32 @zexth_i32(i32 %a) nounwind {
963 ; RV64I-LABEL: zexth_i32:
965 ; RV64I-NEXT: slli a0, a0, 48
966 ; RV64I-NEXT: srli a0, a0, 48
969 ; RV64ZBB-LABEL: zexth_i32:
971 ; RV64ZBB-NEXT: zext.h a0, a0
973 %and = and i32 %a, 65535
977 define i64 @zexth_i64(i64 %a) nounwind {
978 ; RV64I-LABEL: zexth_i64:
980 ; RV64I-NEXT: slli a0, a0, 48
981 ; RV64I-NEXT: srli a0, a0, 48
984 ; RV64ZBB-LABEL: zexth_i64:
986 ; RV64ZBB-NEXT: zext.h a0, a0
988 %and = and i64 %a, 65535
992 declare i32 @llvm.bswap.i32(i32)
994 define signext i32 @bswap_i32(i32 signext %a) nounwind {
995 ; RV64I-LABEL: bswap_i32:
997 ; RV64I-NEXT: srli a1, a0, 8
998 ; RV64I-NEXT: lui a2, 16
999 ; RV64I-NEXT: addiw a2, a2, -256
1000 ; RV64I-NEXT: and a1, a1, a2
1001 ; RV64I-NEXT: srliw a2, a0, 24
1002 ; RV64I-NEXT: or a1, a1, a2
1003 ; RV64I-NEXT: slli a2, a0, 8
1004 ; RV64I-NEXT: lui a3, 4080
1005 ; RV64I-NEXT: and a2, a2, a3
1006 ; RV64I-NEXT: slliw a0, a0, 24
1007 ; RV64I-NEXT: or a0, a0, a2
1008 ; RV64I-NEXT: or a0, a0, a1
1011 ; RV64ZBB-LABEL: bswap_i32:
1013 ; RV64ZBB-NEXT: rev8 a0, a0
1014 ; RV64ZBB-NEXT: srai a0, a0, 32
1016 %1 = tail call i32 @llvm.bswap.i32(i32 %a)
1020 ; Similar to bswap_i32 but the result is not sign extended.
1021 define void @bswap_i32_nosext(i32 signext %a, i32* %x) nounwind {
1022 ; RV64I-LABEL: bswap_i32_nosext:
1024 ; RV64I-NEXT: srli a2, a0, 8
1025 ; RV64I-NEXT: lui a3, 16
1026 ; RV64I-NEXT: addiw a3, a3, -256
1027 ; RV64I-NEXT: and a2, a2, a3
1028 ; RV64I-NEXT: srliw a3, a0, 24
1029 ; RV64I-NEXT: or a2, a2, a3
1030 ; RV64I-NEXT: slli a3, a0, 8
1031 ; RV64I-NEXT: lui a4, 4080
1032 ; RV64I-NEXT: and a3, a3, a4
1033 ; RV64I-NEXT: slli a0, a0, 24
1034 ; RV64I-NEXT: or a0, a0, a3
1035 ; RV64I-NEXT: or a0, a0, a2
1036 ; RV64I-NEXT: sw a0, 0(a1)
1039 ; RV64ZBB-LABEL: bswap_i32_nosext:
1041 ; RV64ZBB-NEXT: rev8 a0, a0
1042 ; RV64ZBB-NEXT: srli a0, a0, 32
1043 ; RV64ZBB-NEXT: sw a0, 0(a1)
1045 %1 = tail call i32 @llvm.bswap.i32(i32 %a)
1046 store i32 %1, i32* %x
1050 declare i64 @llvm.bswap.i64(i64)
1052 define i64 @bswap_i64(i64 %a) {
1053 ; RV64I-LABEL: bswap_i64:
1055 ; RV64I-NEXT: srli a1, a0, 24
1056 ; RV64I-NEXT: lui a2, 4080
1057 ; RV64I-NEXT: and a1, a1, a2
1058 ; RV64I-NEXT: srli a2, a0, 8
1059 ; RV64I-NEXT: li a3, 255
1060 ; RV64I-NEXT: slli a4, a3, 24
1061 ; RV64I-NEXT: and a2, a2, a4
1062 ; RV64I-NEXT: or a1, a2, a1
1063 ; RV64I-NEXT: srli a2, a0, 40
1064 ; RV64I-NEXT: lui a4, 16
1065 ; RV64I-NEXT: addiw a4, a4, -256
1066 ; RV64I-NEXT: and a2, a2, a4
1067 ; RV64I-NEXT: srli a4, a0, 56
1068 ; RV64I-NEXT: or a2, a2, a4
1069 ; RV64I-NEXT: or a1, a1, a2
1070 ; RV64I-NEXT: slli a2, a0, 24
1071 ; RV64I-NEXT: slli a4, a3, 40
1072 ; RV64I-NEXT: and a2, a2, a4
1073 ; RV64I-NEXT: srliw a4, a0, 24
1074 ; RV64I-NEXT: slli a4, a4, 32
1075 ; RV64I-NEXT: or a2, a2, a4
1076 ; RV64I-NEXT: slli a4, a0, 40
1077 ; RV64I-NEXT: slli a3, a3, 48
1078 ; RV64I-NEXT: and a3, a4, a3
1079 ; RV64I-NEXT: slli a0, a0, 56
1080 ; RV64I-NEXT: or a0, a0, a3
1081 ; RV64I-NEXT: or a0, a0, a2
1082 ; RV64I-NEXT: or a0, a0, a1
1085 ; RV64ZBB-LABEL: bswap_i64:
1087 ; RV64ZBB-NEXT: rev8 a0, a0
1089 %1 = call i64 @llvm.bswap.i64(i64 %a)