1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s --mtriple=loongarch64 | FileCheck %s --check-prefixes=CHECK
3 ; RUN: llc < %s --mtriple=loongarch64 --loongarch-disable-sextw-removal | \
4 ; RUN: FileCheck %s --check-prefix=NORMV
6 define void @test1(i32 signext %arg, i32 signext %arg1) nounwind {
8 ; CHECK: # %bb.0: # %bb
9 ; CHECK-NEXT: addi.d $sp, $sp, -32
10 ; CHECK-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
11 ; CHECK-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
12 ; CHECK-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
13 ; CHECK-NEXT: move $fp, $a1
14 ; CHECK-NEXT: sra.w $s0, $a0, $a1
15 ; CHECK-NEXT: .p2align 4, , 16
16 ; CHECK-NEXT: .LBB0_1: # %bb2
17 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
18 ; CHECK-NEXT: move $a0, $s0
19 ; CHECK-NEXT: bl %plt(bar)
20 ; CHECK-NEXT: sll.w $s0, $s0, $fp
21 ; CHECK-NEXT: bnez $a0, .LBB0_1
22 ; CHECK-NEXT: # %bb.2: # %bb7
23 ; CHECK-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
24 ; CHECK-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
25 ; CHECK-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
26 ; CHECK-NEXT: addi.d $sp, $sp, 32
30 ; NORMV: # %bb.0: # %bb
31 ; NORMV-NEXT: addi.d $sp, $sp, -32
32 ; NORMV-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
33 ; NORMV-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
34 ; NORMV-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
35 ; NORMV-NEXT: move $fp, $a1
36 ; NORMV-NEXT: sra.w $s0, $a0, $a1
37 ; NORMV-NEXT: .p2align 4, , 16
38 ; NORMV-NEXT: .LBB0_1: # %bb2
39 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
40 ; NORMV-NEXT: addi.w $a0, $s0, 0
41 ; NORMV-NEXT: bl %plt(bar)
42 ; NORMV-NEXT: sll.w $s0, $s0, $fp
43 ; NORMV-NEXT: bnez $a0, .LBB0_1
44 ; NORMV-NEXT: # %bb.2: # %bb7
45 ; NORMV-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
46 ; NORMV-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
47 ; NORMV-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
48 ; NORMV-NEXT: addi.d $sp, $sp, 32
51 %i = ashr i32 %arg, %arg1
54 bb2: ; preds = %bb2, %bb
55 %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
56 %i4 = tail call signext i32 @bar(i32 signext %i3)
57 %i5 = shl i32 %i3, %arg1
58 %i6 = icmp eq i32 %i4, 0
59 br i1 %i6, label %bb7, label %bb2
65 declare signext i32 @bar(i32 signext)
67 define signext i32 @test2(ptr %p, i32 signext %b) nounwind {
70 ; CHECK-NEXT: ld.w $a0, $a0, 0
71 ; CHECK-NEXT: ori $a2, $zero, 1
72 ; CHECK-NEXT: sll.w $a1, $a2, $a1
73 ; CHECK-NEXT: andn $a0, $a0, $a1
78 ; NORMV-NEXT: ld.w $a0, $a0, 0
79 ; NORMV-NEXT: ori $a2, $zero, 1
80 ; NORMV-NEXT: sll.w $a1, $a2, $a1
81 ; NORMV-NEXT: andn $a0, $a0, $a1
82 ; NORMV-NEXT: addi.w $a0, $a0, 0
86 %neg = xor i32 %shl, -1
87 %and1 = and i32 %neg, %a
91 define signext i32 @test3(ptr %p, i32 signext %b) nounwind {
94 ; CHECK-NEXT: ld.w $a0, $a0, 0
95 ; CHECK-NEXT: ori $a2, $zero, 1
96 ; CHECK-NEXT: sll.w $a1, $a2, $a1
97 ; CHECK-NEXT: orn $a0, $a0, $a1
100 ; NORMV-LABEL: test3:
102 ; NORMV-NEXT: ld.w $a0, $a0, 0
103 ; NORMV-NEXT: ori $a2, $zero, 1
104 ; NORMV-NEXT: sll.w $a1, $a2, $a1
105 ; NORMV-NEXT: orn $a0, $a0, $a1
106 ; NORMV-NEXT: addi.w $a0, $a0, 0
108 %a = load i32, ptr %p
110 %neg = xor i32 %shl, -1
111 %and1 = or i32 %neg, %a
115 define signext i32 @test4(ptr %p, i32 signext %b) nounwind {
116 ; CHECK-LABEL: test4:
118 ; CHECK-NEXT: ld.w $a0, $a0, 0
119 ; CHECK-NEXT: ori $a2, $zero, 1
120 ; CHECK-NEXT: sll.w $a1, $a2, $a1
121 ; CHECK-NEXT: xor $a0, $a1, $a0
122 ; CHECK-NEXT: nor $a0, $a0, $zero
123 ; CHECK-NEXT: addi.w $a0, $a0, 0
126 ; NORMV-LABEL: test4:
128 ; NORMV-NEXT: ld.w $a0, $a0, 0
129 ; NORMV-NEXT: ori $a2, $zero, 1
130 ; NORMV-NEXT: sll.w $a1, $a2, $a1
131 ; NORMV-NEXT: xor $a0, $a1, $a0
132 ; NORMV-NEXT: nor $a0, $a0, $zero
133 ; NORMV-NEXT: addi.w $a0, $a0, 0
135 %a = load i32, ptr %p
137 %neg = xor i32 %shl, -1
138 %and1 = xor i32 %neg, %a
142 define void @test5(i32 signext %arg, i32 signext %arg1) nounwind {
143 ; CHECK-LABEL: test5:
144 ; CHECK: # %bb.0: # %bb
145 ; CHECK-NEXT: addi.d $sp, $sp, -16
146 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
147 ; CHECK-NEXT: sra.w $a1, $a0, $a1
148 ; CHECK-NEXT: .p2align 4, , 16
149 ; CHECK-NEXT: .LBB4_1: # %bb2
150 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
151 ; CHECK-NEXT: addi.w $a0, $a1, 0
152 ; CHECK-NEXT: bl %plt(bar)
153 ; CHECK-NEXT: bstrpick.d $a1, $a0, 31, 0
154 ; CHECK-NEXT: vldi $vr0, 0
155 ; CHECK-NEXT: vinsgr2vr.d $vr0, $a1, 0
156 ; CHECK-NEXT: vpcnt.d $vr0, $vr0
157 ; CHECK-NEXT: vpickve2gr.d $a1, $vr0, 0
158 ; CHECK-NEXT: bnez $a0, .LBB4_1
159 ; CHECK-NEXT: # %bb.2: # %bb7
160 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
161 ; CHECK-NEXT: addi.d $sp, $sp, 16
164 ; NORMV-LABEL: test5:
165 ; NORMV: # %bb.0: # %bb
166 ; NORMV-NEXT: addi.d $sp, $sp, -16
167 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
168 ; NORMV-NEXT: sra.w $a1, $a0, $a1
169 ; NORMV-NEXT: .p2align 4, , 16
170 ; NORMV-NEXT: .LBB4_1: # %bb2
171 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
172 ; NORMV-NEXT: addi.w $a0, $a1, 0
173 ; NORMV-NEXT: bl %plt(bar)
174 ; NORMV-NEXT: bstrpick.d $a1, $a0, 31, 0
175 ; NORMV-NEXT: vldi $vr0, 0
176 ; NORMV-NEXT: vinsgr2vr.d $vr0, $a1, 0
177 ; NORMV-NEXT: vpcnt.d $vr0, $vr0
178 ; NORMV-NEXT: vpickve2gr.d $a1, $vr0, 0
179 ; NORMV-NEXT: bnez $a0, .LBB4_1
180 ; NORMV-NEXT: # %bb.2: # %bb7
181 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
182 ; NORMV-NEXT: addi.d $sp, $sp, 16
185 %i = ashr i32 %arg, %arg1
188 bb2: ; preds = %bb2, %bb
189 %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
190 %i4 = tail call signext i32 @bar(i32 signext %i3)
191 %i5 = tail call i32 @llvm.ctpop.i32(i32 %i4)
192 %i6 = icmp eq i32 %i4, 0
193 br i1 %i6, label %bb7, label %bb2
199 declare i32 @llvm.ctpop.i32(i32)
201 define void @test6(i32 signext %arg, i32 signext %arg1) nounwind {
202 ; CHECK-LABEL: test6:
203 ; CHECK: # %bb.0: # %bb
204 ; CHECK-NEXT: addi.d $sp, $sp, -16
205 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
206 ; CHECK-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
207 ; CHECK-NEXT: sra.w $a0, $a0, $a1
208 ; CHECK-NEXT: movgr2fr.w $fs0, $zero
209 ; CHECK-NEXT: .p2align 4, , 16
210 ; CHECK-NEXT: .LBB5_1: # %bb2
211 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
212 ; CHECK-NEXT: bl %plt(baz)
213 ; CHECK-NEXT: ftintrz.w.s $fa1, $fa0
214 ; CHECK-NEXT: fcmp.cune.s $fcc0, $fa0, $fs0
215 ; CHECK-NEXT: movfr2gr.s $a0, $fa1
216 ; CHECK-NEXT: bcnez $fcc0, .LBB5_1
217 ; CHECK-NEXT: # %bb.2: # %bb7
218 ; CHECK-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
219 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
220 ; CHECK-NEXT: addi.d $sp, $sp, 16
223 ; NORMV-LABEL: test6:
224 ; NORMV: # %bb.0: # %bb
225 ; NORMV-NEXT: addi.d $sp, $sp, -16
226 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
227 ; NORMV-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
228 ; NORMV-NEXT: sra.w $a0, $a0, $a1
229 ; NORMV-NEXT: movgr2fr.w $fs0, $zero
230 ; NORMV-NEXT: .p2align 4, , 16
231 ; NORMV-NEXT: .LBB5_1: # %bb2
232 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
233 ; NORMV-NEXT: addi.w $a0, $a0, 0
234 ; NORMV-NEXT: bl %plt(baz)
235 ; NORMV-NEXT: ftintrz.w.s $fa1, $fa0
236 ; NORMV-NEXT: fcmp.cune.s $fcc0, $fa0, $fs0
237 ; NORMV-NEXT: movfr2gr.s $a0, $fa1
238 ; NORMV-NEXT: bcnez $fcc0, .LBB5_1
239 ; NORMV-NEXT: # %bb.2: # %bb7
240 ; NORMV-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
241 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
242 ; NORMV-NEXT: addi.d $sp, $sp, 16
245 %i = ashr i32 %arg, %arg1
248 bb2: ; preds = %bb2, %bb
249 %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
250 %i4 = tail call float @baz(i32 signext %i3)
251 %i5 = fptosi float %i4 to i32
252 %i6 = fcmp oeq float %i4, zeroinitializer
253 br i1 %i6, label %bb7, label %bb2
258 declare float @baz(i32 signext %i3)
260 define void @test7(i32 signext %arg, i32 signext %arg1) nounwind {
261 ; CHECK-LABEL: test7:
262 ; CHECK: # %bb.0: # %bb
263 ; CHECK-NEXT: addi.d $sp, $sp, -16
264 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
265 ; CHECK-NEXT: sra.w $a0, $a0, $a1
266 ; CHECK-NEXT: .p2align 4, , 16
267 ; CHECK-NEXT: .LBB6_1: # %bb2
268 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
269 ; CHECK-NEXT: addi.w $a0, $a0, 0
270 ; CHECK-NEXT: bl %plt(foo)
271 ; CHECK-NEXT: vldi $vr0, 0
272 ; CHECK-NEXT: vinsgr2vr.d $vr0, $a0, 0
273 ; CHECK-NEXT: vpcnt.d $vr0, $vr0
274 ; CHECK-NEXT: vpickve2gr.d $a0, $vr0, 0
275 ; CHECK-NEXT: bnez $a0, .LBB6_1
276 ; CHECK-NEXT: # %bb.2: # %bb7
277 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
278 ; CHECK-NEXT: addi.d $sp, $sp, 16
281 ; NORMV-LABEL: test7:
282 ; NORMV: # %bb.0: # %bb
283 ; NORMV-NEXT: addi.d $sp, $sp, -16
284 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
285 ; NORMV-NEXT: sra.w $a0, $a0, $a1
286 ; NORMV-NEXT: .p2align 4, , 16
287 ; NORMV-NEXT: .LBB6_1: # %bb2
288 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
289 ; NORMV-NEXT: addi.w $a0, $a0, 0
290 ; NORMV-NEXT: bl %plt(foo)
291 ; NORMV-NEXT: vldi $vr0, 0
292 ; NORMV-NEXT: vinsgr2vr.d $vr0, $a0, 0
293 ; NORMV-NEXT: vpcnt.d $vr0, $vr0
294 ; NORMV-NEXT: vpickve2gr.d $a0, $vr0, 0
295 ; NORMV-NEXT: bnez $a0, .LBB6_1
296 ; NORMV-NEXT: # %bb.2: # %bb7
297 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
298 ; NORMV-NEXT: addi.d $sp, $sp, 16
301 %i = ashr i32 %arg, %arg1
304 bb2: ; preds = %bb2, %bb
305 %i3 = phi i32 [ %i, %bb ], [ %i6, %bb2 ]
306 %i4 = tail call signext i64 @foo(i32 signext %i3)
307 %i5 = tail call i64 @llvm.ctpop.i64(i64 %i4)
308 %i6 = trunc i64 %i5 to i32
309 %i7 = icmp eq i32 %i6, 0
310 br i1 %i7, label %bb7, label %bb2
316 declare i64 @llvm.ctpop.i64(i64)
318 define void @test8(i32 signext %arg, i32 signext %arg1) nounwind {
319 ; CHECK-LABEL: test8:
320 ; CHECK: # %bb.0: # %bb
321 ; CHECK-NEXT: addi.d $sp, $sp, -16
322 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
323 ; CHECK-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
324 ; CHECK-NEXT: sra.w $a0, $a0, $a1
325 ; CHECK-NEXT: addi.w $fp, $zero, -256
326 ; CHECK-NEXT: .p2align 4, , 16
327 ; CHECK-NEXT: .LBB7_1: # %bb2
328 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
329 ; CHECK-NEXT: addi.w $a0, $a0, 0
330 ; CHECK-NEXT: bl %plt(foo)
331 ; CHECK-NEXT: or $a0, $a0, $fp
332 ; CHECK-NEXT: bnez $a0, .LBB7_1
333 ; CHECK-NEXT: # %bb.2: # %bb7
334 ; CHECK-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
335 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
336 ; CHECK-NEXT: addi.d $sp, $sp, 16
339 ; NORMV-LABEL: test8:
340 ; NORMV: # %bb.0: # %bb
341 ; NORMV-NEXT: addi.d $sp, $sp, -16
342 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
343 ; NORMV-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
344 ; NORMV-NEXT: sra.w $a0, $a0, $a1
345 ; NORMV-NEXT: addi.w $fp, $zero, -256
346 ; NORMV-NEXT: .p2align 4, , 16
347 ; NORMV-NEXT: .LBB7_1: # %bb2
348 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
349 ; NORMV-NEXT: addi.w $a0, $a0, 0
350 ; NORMV-NEXT: bl %plt(foo)
351 ; NORMV-NEXT: or $a0, $a0, $fp
352 ; NORMV-NEXT: bnez $a0, .LBB7_1
353 ; NORMV-NEXT: # %bb.2: # %bb7
354 ; NORMV-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
355 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
356 ; NORMV-NEXT: addi.d $sp, $sp, 16
359 %i = ashr i32 %arg, %arg1
362 bb2: ; preds = %bb2, %bb
363 %i3 = phi i32 [ %i, %bb ], [ %i6, %bb2 ]
364 %i4 = tail call signext i64 @foo(i32 signext %i3)
365 %i5 = or i64 %i4, -256
366 %i6 = trunc i64 %i5 to i32
367 %i7 = icmp eq i32 %i6, 0
368 br i1 %i7, label %bb7, label %bb2
374 declare i64 @foo(i32 signext)
376 define void @test9(i32 signext %arg, i32 signext %arg1) nounwind {
377 ; CHECK-LABEL: test9:
378 ; CHECK: # %bb.0: # %bb
379 ; CHECK-NEXT: addi.d $sp, $sp, -16
380 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
381 ; CHECK-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
382 ; CHECK-NEXT: sra.w $a0, $a0, $a1
383 ; CHECK-NEXT: ori $fp, $zero, 254
384 ; CHECK-NEXT: .p2align 4, , 16
385 ; CHECK-NEXT: .LBB8_1: # %bb2
386 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
387 ; CHECK-NEXT: bl %plt(bar)
388 ; CHECK-NEXT: move $a1, $a0
389 ; CHECK-NEXT: slti $a0, $a0, 255
390 ; CHECK-NEXT: blt $fp, $a1, .LBB8_1
391 ; CHECK-NEXT: # %bb.2: # %bb7
392 ; CHECK-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
393 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
394 ; CHECK-NEXT: addi.d $sp, $sp, 16
397 ; NORMV-LABEL: test9:
398 ; NORMV: # %bb.0: # %bb
399 ; NORMV-NEXT: addi.d $sp, $sp, -16
400 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
401 ; NORMV-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
402 ; NORMV-NEXT: sra.w $a1, $a0, $a1
403 ; NORMV-NEXT: ori $fp, $zero, 254
404 ; NORMV-NEXT: .p2align 4, , 16
405 ; NORMV-NEXT: .LBB8_1: # %bb2
406 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
407 ; NORMV-NEXT: addi.w $a0, $a1, 0
408 ; NORMV-NEXT: bl %plt(bar)
409 ; NORMV-NEXT: slti $a1, $a0, 255
410 ; NORMV-NEXT: blt $fp, $a0, .LBB8_1
411 ; NORMV-NEXT: # %bb.2: # %bb7
412 ; NORMV-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
413 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
414 ; NORMV-NEXT: addi.d $sp, $sp, 16
417 %i = ashr i32 %arg, %arg1
420 bb2: ; preds = %bb2, %bb
421 %i3 = phi i32 [ %i, %bb ], [ %i7, %bb2 ]
422 %i4 = tail call signext i32 @bar(i32 signext %i3)
423 %i5 = icmp slt i32 %i4, 255
424 %i6 = sext i1 %i5 to i32
426 br i1 %i5, label %bb7, label %bb2
432 define void @test10(i32 signext %arg, i32 signext %arg1) nounwind {
433 ; CHECK-LABEL: test10:
434 ; CHECK: # %bb.0: # %bb
435 ; CHECK-NEXT: addi.d $sp, $sp, -16
436 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
437 ; CHECK-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
438 ; CHECK-NEXT: sra.w $a0, $a0, $a1
439 ; CHECK-NEXT: movgr2fr.w $fs0, $zero
440 ; CHECK-NEXT: .p2align 4, , 16
441 ; CHECK-NEXT: .LBB9_1: # %bb2
442 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
443 ; CHECK-NEXT: bl %plt(baz)
444 ; CHECK-NEXT: fcmp.cune.s $fcc0, $fa0, $fs0
445 ; CHECK-NEXT: movfr2gr.s $a0, $fa0
446 ; CHECK-NEXT: bcnez $fcc0, .LBB9_1
447 ; CHECK-NEXT: # %bb.2: # %bb7
448 ; CHECK-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
449 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
450 ; CHECK-NEXT: addi.d $sp, $sp, 16
453 ; NORMV-LABEL: test10:
454 ; NORMV: # %bb.0: # %bb
455 ; NORMV-NEXT: addi.d $sp, $sp, -16
456 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
457 ; NORMV-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
458 ; NORMV-NEXT: sra.w $a0, $a0, $a1
459 ; NORMV-NEXT: movgr2fr.w $fs0, $zero
460 ; NORMV-NEXT: .p2align 4, , 16
461 ; NORMV-NEXT: .LBB9_1: # %bb2
462 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
463 ; NORMV-NEXT: addi.w $a0, $a0, 0
464 ; NORMV-NEXT: bl %plt(baz)
465 ; NORMV-NEXT: fcmp.cune.s $fcc0, $fa0, $fs0
466 ; NORMV-NEXT: movfr2gr.s $a0, $fa0
467 ; NORMV-NEXT: bcnez $fcc0, .LBB9_1
468 ; NORMV-NEXT: # %bb.2: # %bb7
469 ; NORMV-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
470 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
471 ; NORMV-NEXT: addi.d $sp, $sp, 16
474 %i = ashr i32 %arg, %arg1
477 bb2: ; preds = %bb2, %bb
478 %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
479 %i4 = tail call float @baz(i32 signext %i3)
480 %i5 = bitcast float %i4 to i32
481 %i6 = fcmp oeq float %i4, zeroinitializer
482 br i1 %i6, label %bb7, label %bb2
488 define signext i32 @test11(i64 %arg1, i64 %arg2, i64 %arg3) {
489 ; CHECK-LABEL: test11:
490 ; CHECK: # %bb.0: # %entry
491 ; CHECK-NEXT: addi.d $a2, $a2, -1
492 ; CHECK-NEXT: ori $a3, $zero, 256
493 ; CHECK-NEXT: .p2align 4, , 16
494 ; CHECK-NEXT: .LBB10_1: # %bb2
495 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
496 ; CHECK-NEXT: andi $a0, $a0, 1234
497 ; CHECK-NEXT: addi.d $a2, $a2, 1
498 ; CHECK-NEXT: add.w $a0, $a0, $a1
499 ; CHECK-NEXT: bltu $a2, $a3, .LBB10_1
500 ; CHECK-NEXT: # %bb.2: # %bb7
503 ; NORMV-LABEL: test11:
504 ; NORMV: # %bb.0: # %entry
505 ; NORMV-NEXT: addi.d $a2, $a2, -1
506 ; NORMV-NEXT: ori $a3, $zero, 256
507 ; NORMV-NEXT: .p2align 4, , 16
508 ; NORMV-NEXT: .LBB10_1: # %bb2
509 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
510 ; NORMV-NEXT: andi $a0, $a0, 1234
511 ; NORMV-NEXT: addi.d $a2, $a2, 1
512 ; NORMV-NEXT: add.d $a0, $a0, $a1
513 ; NORMV-NEXT: bltu $a2, $a3, .LBB10_1
514 ; NORMV-NEXT: # %bb.2: # %bb7
515 ; NORMV-NEXT: addi.w $a0, $a0, 0
520 bb2: ; preds = %bb2, %entry
521 %i1 = phi i64 [ %arg1, %entry ], [ %i5, %bb2 ]
522 %i2 = phi i64 [ %arg3, %entry ], [ %i3, %bb2 ]
524 %i4 = and i64 %i1, 1234
525 %i5 = add i64 %i4, %arg2
526 %i6 = icmp ugt i64 %i2, 255
527 br i1 %i6, label %bb7, label %bb2
530 %i7 = trunc i64 %i5 to i32
534 define signext i32 @test12(i64 %arg1, i64 %arg2, i64 %arg3) {
535 ; CHECK-LABEL: test12:
536 ; CHECK: # %bb.0: # %entry
537 ; CHECK-NEXT: addi.d $a3, $a2, -1
538 ; CHECK-NEXT: ori $a4, $zero, 256
539 ; CHECK-NEXT: .p2align 4, , 16
540 ; CHECK-NEXT: .LBB11_1: # %bb2
541 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
542 ; CHECK-NEXT: xor $a0, $a0, $a1
543 ; CHECK-NEXT: mul.w $a2, $a0, $a1
544 ; CHECK-NEXT: add.w $a0, $a0, $a2
545 ; CHECK-NEXT: and $a2, $a2, $a0
546 ; CHECK-NEXT: addi.d $a3, $a3, 1
547 ; CHECK-NEXT: add.d $a0, $a2, $a1
548 ; CHECK-NEXT: bltu $a3, $a4, .LBB11_1
549 ; CHECK-NEXT: # %bb.2: # %bb7
550 ; CHECK-NEXT: move $a0, $a2
553 ; NORMV-LABEL: test12:
554 ; NORMV: # %bb.0: # %entry
555 ; NORMV-NEXT: addi.d $a2, $a2, -1
556 ; NORMV-NEXT: ori $a3, $zero, 256
557 ; NORMV-NEXT: .p2align 4, , 16
558 ; NORMV-NEXT: .LBB11_1: # %bb2
559 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
560 ; NORMV-NEXT: xor $a0, $a0, $a1
561 ; NORMV-NEXT: mul.d $a4, $a0, $a1
562 ; NORMV-NEXT: add.d $a0, $a0, $a4
563 ; NORMV-NEXT: and $a4, $a4, $a0
564 ; NORMV-NEXT: addi.d $a2, $a2, 1
565 ; NORMV-NEXT: add.d $a0, $a4, $a1
566 ; NORMV-NEXT: bltu $a2, $a3, .LBB11_1
567 ; NORMV-NEXT: # %bb.2: # %bb7
568 ; NORMV-NEXT: addi.w $a0, $a4, 0
573 bb2: ; preds = %bb2, %entry
574 %i1 = phi i64 [ %arg1, %entry ], [ %i6, %bb2 ]
575 %i2 = phi i64 [ %arg3, %entry ], [ %i3, %bb2 ]
577 %i4 = xor i64 %i1, %arg2
578 %i5 = mul i64 %i4, %arg2
579 %i9 = add i64 %i4, %i5
580 %i8 = and i64 %i5, %i9
581 %i6 = add i64 %i8, %arg2
582 %i7 = icmp ugt i64 %i2, 255
583 br i1 %i7, label %bb7, label %bb2
586 %r = trunc i64 %i8 to i32
590 define signext i32 @test13(i64 %arg1, i64 %arg2, i64 %arg3) {
591 ; CHECK-LABEL: test13:
592 ; CHECK: # %bb.0: # %entry
593 ; CHECK-NEXT: addi.d $a2, $a2, -1
594 ; CHECK-NEXT: ori $a3, $zero, 256
595 ; CHECK-NEXT: .p2align 4, , 16
596 ; CHECK-NEXT: .LBB12_1: # %bb2
597 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
598 ; CHECK-NEXT: div.d $a0, $a0, $a1
599 ; CHECK-NEXT: addi.d $a2, $a2, 1
600 ; CHECK-NEXT: add.d $a0, $a0, $a1
601 ; CHECK-NEXT: bltu $a2, $a3, .LBB12_1
602 ; CHECK-NEXT: # %bb.2: # %bb7
603 ; CHECK-NEXT: addi.w $a0, $a0, 0
606 ; NORMV-LABEL: test13:
607 ; NORMV: # %bb.0: # %entry
608 ; NORMV-NEXT: addi.d $a2, $a2, -1
609 ; NORMV-NEXT: ori $a3, $zero, 256
610 ; NORMV-NEXT: .p2align 4, , 16
611 ; NORMV-NEXT: .LBB12_1: # %bb2
612 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
613 ; NORMV-NEXT: div.d $a0, $a0, $a1
614 ; NORMV-NEXT: addi.d $a2, $a2, 1
615 ; NORMV-NEXT: add.d $a0, $a0, $a1
616 ; NORMV-NEXT: bltu $a2, $a3, .LBB12_1
617 ; NORMV-NEXT: # %bb.2: # %bb7
618 ; NORMV-NEXT: addi.w $a0, $a0, 0
623 bb2: ; preds = %bb2, %entry
624 %i1 = phi i64 [ %arg1, %entry ], [ %i5, %bb2 ]
625 %i2 = phi i64 [ %arg3, %entry ], [ %i3, %bb2 ]
627 %i4 = sdiv i64 %i1, %arg2
628 %i5 = add i64 %i4, %arg2
629 %i6 = icmp ugt i64 %i2, 255
630 br i1 %i6, label %bb7, label %bb2
633 %i8 = trunc i64 %i5 to i32
638 define signext i32 @test14(i32 signext %0, i32 signext %1) {
639 ; CHECK-LABEL: test14:
641 ; CHECK-NEXT: ori $a2, $zero, 2
642 ; CHECK-NEXT: blt $a1, $a2, .LBB13_4
643 ; CHECK-NEXT: # %bb.1: # %.preheader
644 ; CHECK-NEXT: ori $a3, $zero, 1
645 ; CHECK-NEXT: addi.w $a2, $zero, -1
646 ; CHECK-NEXT: ori $a4, $zero, 1000
647 ; CHECK-NEXT: .p2align 4, , 16
648 ; CHECK-NEXT: .LBB13_2: # =>This Inner Loop Header: Depth=1
649 ; CHECK-NEXT: blt $a4, $a0, .LBB13_5
650 ; CHECK-NEXT: # %bb.3: # in Loop: Header=BB13_2 Depth=1
651 ; CHECK-NEXT: add.w $a0, $a3, $a0
652 ; CHECK-NEXT: addi.w $a3, $a3, 1
653 ; CHECK-NEXT: blt $a3, $a1, .LBB13_2
654 ; CHECK-NEXT: .LBB13_4:
656 ; CHECK-NEXT: .LBB13_5:
657 ; CHECK-NEXT: move $a0, $a2
660 ; NORMV-LABEL: test14:
662 ; NORMV-NEXT: ori $a2, $zero, 2
663 ; NORMV-NEXT: blt $a1, $a2, .LBB13_4
664 ; NORMV-NEXT: # %bb.1: # %.preheader
665 ; NORMV-NEXT: ori $a3, $zero, 1
666 ; NORMV-NEXT: addi.w $a2, $zero, -1
667 ; NORMV-NEXT: ori $a4, $zero, 1000
668 ; NORMV-NEXT: .p2align 4, , 16
669 ; NORMV-NEXT: .LBB13_2: # =>This Inner Loop Header: Depth=1
670 ; NORMV-NEXT: addi.w $a5, $a0, 0
671 ; NORMV-NEXT: blt $a4, $a5, .LBB13_5
672 ; NORMV-NEXT: # %bb.3: # in Loop: Header=BB13_2 Depth=1
673 ; NORMV-NEXT: add.d $a0, $a3, $a0
674 ; NORMV-NEXT: addi.d $a3, $a3, 1
675 ; NORMV-NEXT: addi.w $a3, $a3, 0
676 ; NORMV-NEXT: addi.w $a0, $a0, 0
677 ; NORMV-NEXT: blt $a3, $a1, .LBB13_2
678 ; NORMV-NEXT: .LBB13_4:
680 ; NORMV-NEXT: .LBB13_5:
681 ; NORMV-NEXT: move $a0, $a2
683 %3 = icmp sgt i32 %1, 1
684 br i1 %3, label %4, label %12
687 %5 = phi i32 [ %10, %8 ], [ 1, %2 ]
688 %6 = phi i32 [ %9, %8 ], [ %0, %2 ]
689 %7 = icmp sgt i32 %6, 1000
690 br i1 %7, label %12, label %8
693 %9 = add nsw i32 %5, %6
694 %10 = add nuw nsw i32 %5, 1
695 %11 = icmp slt i32 %10, %1
696 br i1 %11, label %4, label %12
698 12: ; preds = %8, %4, %2
699 %13 = phi i32 [ %0, %2 ], [ -1, %4 ], [ %9, %8 ]
703 define signext i32 @test14b(i32 %0, i32 signext %1) {
704 ; CHECK-LABEL: test14b:
706 ; CHECK-NEXT: ori $a2, $zero, 2
707 ; CHECK-NEXT: blt $a1, $a2, .LBB14_4
708 ; CHECK-NEXT: # %bb.1: # %.preheader
709 ; CHECK-NEXT: ori $a2, $zero, 1
710 ; CHECK-NEXT: ori $a3, $zero, 1000
711 ; CHECK-NEXT: .p2align 4, , 16
712 ; CHECK-NEXT: .LBB14_2: # =>This Inner Loop Header: Depth=1
713 ; CHECK-NEXT: addi.w $a4, $a0, 0
714 ; CHECK-NEXT: blt $a3, $a4, .LBB14_5
715 ; CHECK-NEXT: # %bb.3: # in Loop: Header=BB14_2 Depth=1
716 ; CHECK-NEXT: add.d $a0, $a2, $a0
717 ; CHECK-NEXT: addi.w $a2, $a2, 1
718 ; CHECK-NEXT: blt $a2, $a1, .LBB14_2
719 ; CHECK-NEXT: .LBB14_4:
720 ; CHECK-NEXT: addi.w $a0, $a0, 0
722 ; CHECK-NEXT: .LBB14_5:
723 ; CHECK-NEXT: addi.d $a0, $zero, -1
724 ; CHECK-NEXT: addi.w $a0, $a0, 0
727 ; NORMV-LABEL: test14b:
729 ; NORMV-NEXT: ori $a2, $zero, 2
730 ; NORMV-NEXT: blt $a1, $a2, .LBB14_4
731 ; NORMV-NEXT: # %bb.1: # %.preheader
732 ; NORMV-NEXT: ori $a2, $zero, 1
733 ; NORMV-NEXT: ori $a3, $zero, 1000
734 ; NORMV-NEXT: .p2align 4, , 16
735 ; NORMV-NEXT: .LBB14_2: # =>This Inner Loop Header: Depth=1
736 ; NORMV-NEXT: addi.w $a4, $a0, 0
737 ; NORMV-NEXT: blt $a3, $a4, .LBB14_5
738 ; NORMV-NEXT: # %bb.3: # in Loop: Header=BB14_2 Depth=1
739 ; NORMV-NEXT: add.d $a0, $a2, $a0
740 ; NORMV-NEXT: addi.d $a2, $a2, 1
741 ; NORMV-NEXT: addi.w $a2, $a2, 0
742 ; NORMV-NEXT: addi.d $a0, $a0, 0
743 ; NORMV-NEXT: blt $a2, $a1, .LBB14_2
744 ; NORMV-NEXT: .LBB14_4:
745 ; NORMV-NEXT: addi.w $a0, $a0, 0
747 ; NORMV-NEXT: .LBB14_5:
748 ; NORMV-NEXT: addi.d $a0, $zero, -1
749 ; NORMV-NEXT: addi.w $a0, $a0, 0
751 %3 = icmp sgt i32 %1, 1
752 br i1 %3, label %4, label %12
755 %5 = phi i32 [ %10, %8 ], [ 1, %2 ]
756 %6 = phi i32 [ %9, %8 ], [ %0, %2 ]
757 %7 = icmp sgt i32 %6, 1000
758 br i1 %7, label %12, label %8
761 %9 = add nsw i32 %5, %6
762 %10 = add nuw nsw i32 %5, 1
763 %11 = icmp slt i32 %10, %1
764 br i1 %11, label %4, label %12
766 12: ; preds = %8, %4, %2
767 %13 = phi i32 [ %0, %2 ], [ -1, %4 ], [ %9, %8 ]
771 define signext i32 @test14c(i32 zeroext %0, i32 signext %1) {
772 ; CHECK-LABEL: test14c:
774 ; CHECK-NEXT: ori $a2, $zero, 2
775 ; CHECK-NEXT: blt $a1, $a2, .LBB15_4
776 ; CHECK-NEXT: # %bb.1: # %.preheader
777 ; CHECK-NEXT: ori $a2, $zero, 1
778 ; CHECK-NEXT: ori $a3, $zero, 1000
779 ; CHECK-NEXT: .p2align 4, , 16
780 ; CHECK-NEXT: .LBB15_2: # =>This Inner Loop Header: Depth=1
781 ; CHECK-NEXT: addi.w $a4, $a0, 0
782 ; CHECK-NEXT: blt $a3, $a4, .LBB15_5
783 ; CHECK-NEXT: # %bb.3: # in Loop: Header=BB15_2 Depth=1
784 ; CHECK-NEXT: add.d $a0, $a2, $a0
785 ; CHECK-NEXT: addi.w $a2, $a2, 1
786 ; CHECK-NEXT: blt $a2, $a1, .LBB15_2
787 ; CHECK-NEXT: .LBB15_4:
788 ; CHECK-NEXT: addi.w $a0, $a0, 0
790 ; CHECK-NEXT: .LBB15_5:
791 ; CHECK-NEXT: addi.d $a0, $zero, -1
792 ; CHECK-NEXT: addi.w $a0, $a0, 0
795 ; NORMV-LABEL: test14c:
797 ; NORMV-NEXT: ori $a2, $zero, 2
798 ; NORMV-NEXT: blt $a1, $a2, .LBB15_4
799 ; NORMV-NEXT: # %bb.1: # %.preheader
800 ; NORMV-NEXT: ori $a2, $zero, 1
801 ; NORMV-NEXT: ori $a3, $zero, 1000
802 ; NORMV-NEXT: .p2align 4, , 16
803 ; NORMV-NEXT: .LBB15_2: # =>This Inner Loop Header: Depth=1
804 ; NORMV-NEXT: addi.w $a4, $a0, 0
805 ; NORMV-NEXT: blt $a3, $a4, .LBB15_5
806 ; NORMV-NEXT: # %bb.3: # in Loop: Header=BB15_2 Depth=1
807 ; NORMV-NEXT: add.d $a0, $a2, $a0
808 ; NORMV-NEXT: addi.d $a2, $a2, 1
809 ; NORMV-NEXT: addi.w $a2, $a2, 0
810 ; NORMV-NEXT: addi.d $a0, $a0, 0
811 ; NORMV-NEXT: blt $a2, $a1, .LBB15_2
812 ; NORMV-NEXT: .LBB15_4:
813 ; NORMV-NEXT: addi.w $a0, $a0, 0
815 ; NORMV-NEXT: .LBB15_5:
816 ; NORMV-NEXT: addi.d $a0, $zero, -1
817 ; NORMV-NEXT: addi.w $a0, $a0, 0
819 %3 = icmp sgt i32 %1, 1
820 br i1 %3, label %4, label %12
823 %5 = phi i32 [ %10, %8 ], [ 1, %2 ]
824 %6 = phi i32 [ %9, %8 ], [ %0, %2 ]
825 %7 = icmp sgt i32 %6, 1000
826 br i1 %7, label %12, label %8
829 %9 = add nsw i32 %5, %6
830 %10 = add nuw nsw i32 %5, 1
831 %11 = icmp slt i32 %10, %1
832 br i1 %11, label %4, label %12
834 12: ; preds = %8, %4, %2
835 %13 = phi i32 [ %0, %2 ], [ -1, %4 ], [ %9, %8 ]
839 define signext i32 @test14d(i31 zeroext %0, i32 signext %1) {
840 ; CHECK-LABEL: test14d:
842 ; CHECK-NEXT: ori $a2, $zero, 2
843 ; CHECK-NEXT: blt $a1, $a2, .LBB16_4
844 ; CHECK-NEXT: # %bb.1: # %.preheader
845 ; CHECK-NEXT: ori $a3, $zero, 1
846 ; CHECK-NEXT: addi.w $a2, $zero, -1
847 ; CHECK-NEXT: ori $a4, $zero, 1000
848 ; CHECK-NEXT: .p2align 4, , 16
849 ; CHECK-NEXT: .LBB16_2: # =>This Inner Loop Header: Depth=1
850 ; CHECK-NEXT: blt $a4, $a0, .LBB16_5
851 ; CHECK-NEXT: # %bb.3: # in Loop: Header=BB16_2 Depth=1
852 ; CHECK-NEXT: add.w $a0, $a3, $a0
853 ; CHECK-NEXT: addi.w $a3, $a3, 1
854 ; CHECK-NEXT: blt $a3, $a1, .LBB16_2
855 ; CHECK-NEXT: .LBB16_4:
857 ; CHECK-NEXT: .LBB16_5:
858 ; CHECK-NEXT: move $a0, $a2
861 ; NORMV-LABEL: test14d:
863 ; NORMV-NEXT: ori $a2, $zero, 2
864 ; NORMV-NEXT: blt $a1, $a2, .LBB16_4
865 ; NORMV-NEXT: # %bb.1: # %.preheader
866 ; NORMV-NEXT: ori $a3, $zero, 1
867 ; NORMV-NEXT: addi.w $a2, $zero, -1
868 ; NORMV-NEXT: ori $a4, $zero, 1000
869 ; NORMV-NEXT: .p2align 4, , 16
870 ; NORMV-NEXT: .LBB16_2: # =>This Inner Loop Header: Depth=1
871 ; NORMV-NEXT: addi.w $a5, $a0, 0
872 ; NORMV-NEXT: blt $a4, $a5, .LBB16_5
873 ; NORMV-NEXT: # %bb.3: # in Loop: Header=BB16_2 Depth=1
874 ; NORMV-NEXT: add.d $a0, $a3, $a0
875 ; NORMV-NEXT: addi.d $a3, $a3, 1
876 ; NORMV-NEXT: addi.w $a3, $a3, 0
877 ; NORMV-NEXT: addi.w $a0, $a0, 0
878 ; NORMV-NEXT: blt $a3, $a1, .LBB16_2
879 ; NORMV-NEXT: .LBB16_4:
881 ; NORMV-NEXT: .LBB16_5:
882 ; NORMV-NEXT: move $a0, $a2
884 %zext = zext i31 %0 to i32
885 %3 = icmp sgt i32 %1, 1
886 br i1 %3, label %4, label %12
889 %5 = phi i32 [ %10, %8 ], [ 1, %2 ]
890 %6 = phi i32 [ %9, %8 ], [ %zext, %2 ]
891 %7 = icmp sgt i32 %6, 1000
892 br i1 %7, label %12, label %8
895 %9 = add nsw i32 %5, %6
896 %10 = add nuw nsw i32 %5, 1
897 %11 = icmp slt i32 %10, %1
898 br i1 %11, label %4, label %12
900 12: ; preds = %8, %4, %2
901 %13 = phi i32 [ %zext, %2 ], [ -1, %4 ], [ %9, %8 ]
905 define signext i32 @test15(i64 %arg1, i64 %arg2, i64 %arg3, ptr %arg4) {
906 ; CHECK-LABEL: test15:
907 ; CHECK: # %bb.0: # %entry
908 ; CHECK-NEXT: addi.d $a2, $a2, -1
909 ; CHECK-NEXT: ori $a4, $zero, 256
910 ; CHECK-NEXT: .p2align 4, , 16
911 ; CHECK-NEXT: .LBB17_1: # %bb2
912 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
913 ; CHECK-NEXT: andi $a0, $a0, 1234
914 ; CHECK-NEXT: add.w $a0, $a0, $a1
915 ; CHECK-NEXT: addi.d $a2, $a2, 1
916 ; CHECK-NEXT: st.w $a0, $a3, 0
917 ; CHECK-NEXT: bltu $a2, $a4, .LBB17_1
918 ; CHECK-NEXT: # %bb.2: # %bb7
921 ; NORMV-LABEL: test15:
922 ; NORMV: # %bb.0: # %entry
923 ; NORMV-NEXT: addi.d $a2, $a2, -1
924 ; NORMV-NEXT: ori $a4, $zero, 256
925 ; NORMV-NEXT: .p2align 4, , 16
926 ; NORMV-NEXT: .LBB17_1: # %bb2
927 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
928 ; NORMV-NEXT: andi $a0, $a0, 1234
929 ; NORMV-NEXT: add.d $a0, $a0, $a1
930 ; NORMV-NEXT: addi.d $a2, $a2, 1
931 ; NORMV-NEXT: st.w $a0, $a3, 0
932 ; NORMV-NEXT: bltu $a2, $a4, .LBB17_1
933 ; NORMV-NEXT: # %bb.2: # %bb7
934 ; NORMV-NEXT: addi.w $a0, $a0, 0
939 bb2: ; preds = %bb2, %entry
940 %i1 = phi i64 [ %arg1, %entry ], [ %i5, %bb2 ]
941 %i2 = phi i64 [ %arg3, %entry ], [ %i3, %bb2 ]
943 %i4 = and i64 %i1, 1234
944 %i5 = add i64 %i4, %arg2
945 %i8 = trunc i64 %i5 to i32
946 store i32 %i8, ptr %arg4
947 %i6 = icmp ugt i64 %i2, 255
948 br i1 %i6, label %bb7, label %bb2
951 %i7 = trunc i64 %i5 to i32
955 define signext i32 @bug(i32 signext %x) {
957 ; CHECK: # %bb.0: # %entry
958 ; CHECK-NEXT: beqz $a0, .LBB18_2
959 ; CHECK-NEXT: # %bb.1: # %if.end
960 ; CHECK-NEXT: bstrpick.d $a1, $a0, 31, 16
961 ; CHECK-NEXT: sltui $a1, $a1, 1
962 ; CHECK-NEXT: slli.d $a2, $a0, 16
963 ; CHECK-NEXT: masknez $a0, $a0, $a1
964 ; CHECK-NEXT: maskeqz $a2, $a2, $a1
965 ; CHECK-NEXT: or $a0, $a2, $a0
966 ; CHECK-NEXT: ori $a2, $zero, 32
967 ; CHECK-NEXT: masknez $a2, $a2, $a1
968 ; CHECK-NEXT: ori $a3, $zero, 16
969 ; CHECK-NEXT: maskeqz $a1, $a3, $a1
970 ; CHECK-NEXT: or $a1, $a1, $a2
971 ; CHECK-NEXT: bstrpick.d $a2, $a0, 31, 24
972 ; CHECK-NEXT: sltui $a2, $a2, 1
973 ; CHECK-NEXT: slli.d $a3, $a0, 8
974 ; CHECK-NEXT: addi.d $a4, $a1, -8
975 ; CHECK-NEXT: masknez $a0, $a0, $a2
976 ; CHECK-NEXT: maskeqz $a3, $a3, $a2
977 ; CHECK-NEXT: or $a0, $a3, $a0
978 ; CHECK-NEXT: masknez $a1, $a1, $a2
979 ; CHECK-NEXT: maskeqz $a2, $a4, $a2
980 ; CHECK-NEXT: or $a1, $a2, $a1
981 ; CHECK-NEXT: bstrpick.d $a2, $a0, 31, 28
982 ; CHECK-NEXT: sltui $a2, $a2, 1
983 ; CHECK-NEXT: slli.d $a3, $a0, 4
984 ; CHECK-NEXT: addi.d $a4, $a1, -4
985 ; CHECK-NEXT: masknez $a0, $a0, $a2
986 ; CHECK-NEXT: maskeqz $a3, $a3, $a2
987 ; CHECK-NEXT: or $a0, $a3, $a0
988 ; CHECK-NEXT: masknez $a1, $a1, $a2
989 ; CHECK-NEXT: maskeqz $a2, $a4, $a2
990 ; CHECK-NEXT: or $a1, $a2, $a1
991 ; CHECK-NEXT: bstrpick.d $a2, $a0, 31, 30
992 ; CHECK-NEXT: sltui $a2, $a2, 1
993 ; CHECK-NEXT: slli.d $a3, $a0, 2
994 ; CHECK-NEXT: addi.d $a4, $a1, -2
995 ; CHECK-NEXT: masknez $a0, $a0, $a2
996 ; CHECK-NEXT: maskeqz $a3, $a3, $a2
997 ; CHECK-NEXT: or $a0, $a3, $a0
998 ; CHECK-NEXT: addi.w $a0, $a0, 0
999 ; CHECK-NEXT: masknez $a1, $a1, $a2
1000 ; CHECK-NEXT: maskeqz $a2, $a4, $a2
1001 ; CHECK-NEXT: or $a1, $a2, $a1
1002 ; CHECK-NEXT: nor $a0, $a0, $zero
1003 ; CHECK-NEXT: srli.d $a0, $a0, 31
1004 ; CHECK-NEXT: add.w $a0, $a1, $a0
1006 ; CHECK-NEXT: .LBB18_2:
1007 ; CHECK-NEXT: move $a0, $zero
1011 ; NORMV: # %bb.0: # %entry
1012 ; NORMV-NEXT: beqz $a0, .LBB18_2
1013 ; NORMV-NEXT: # %bb.1: # %if.end
1014 ; NORMV-NEXT: bstrpick.d $a1, $a0, 31, 16
1015 ; NORMV-NEXT: sltui $a1, $a1, 1
1016 ; NORMV-NEXT: slli.d $a2, $a0, 16
1017 ; NORMV-NEXT: masknez $a0, $a0, $a1
1018 ; NORMV-NEXT: maskeqz $a2, $a2, $a1
1019 ; NORMV-NEXT: or $a0, $a2, $a0
1020 ; NORMV-NEXT: ori $a2, $zero, 32
1021 ; NORMV-NEXT: masknez $a2, $a2, $a1
1022 ; NORMV-NEXT: ori $a3, $zero, 16
1023 ; NORMV-NEXT: maskeqz $a1, $a3, $a1
1024 ; NORMV-NEXT: or $a1, $a1, $a2
1025 ; NORMV-NEXT: bstrpick.d $a2, $a0, 31, 24
1026 ; NORMV-NEXT: sltui $a2, $a2, 1
1027 ; NORMV-NEXT: slli.d $a3, $a0, 8
1028 ; NORMV-NEXT: addi.d $a4, $a1, -8
1029 ; NORMV-NEXT: masknez $a0, $a0, $a2
1030 ; NORMV-NEXT: maskeqz $a3, $a3, $a2
1031 ; NORMV-NEXT: or $a0, $a3, $a0
1032 ; NORMV-NEXT: masknez $a1, $a1, $a2
1033 ; NORMV-NEXT: maskeqz $a2, $a4, $a2
1034 ; NORMV-NEXT: or $a1, $a2, $a1
1035 ; NORMV-NEXT: bstrpick.d $a2, $a0, 31, 28
1036 ; NORMV-NEXT: sltui $a2, $a2, 1
1037 ; NORMV-NEXT: slli.d $a3, $a0, 4
1038 ; NORMV-NEXT: addi.d $a4, $a1, -4
1039 ; NORMV-NEXT: masknez $a0, $a0, $a2
1040 ; NORMV-NEXT: maskeqz $a3, $a3, $a2
1041 ; NORMV-NEXT: or $a0, $a3, $a0
1042 ; NORMV-NEXT: masknez $a1, $a1, $a2
1043 ; NORMV-NEXT: maskeqz $a2, $a4, $a2
1044 ; NORMV-NEXT: or $a1, $a2, $a1
1045 ; NORMV-NEXT: bstrpick.d $a2, $a0, 31, 30
1046 ; NORMV-NEXT: sltui $a2, $a2, 1
1047 ; NORMV-NEXT: slli.d $a3, $a0, 2
1048 ; NORMV-NEXT: addi.d $a4, $a1, -2
1049 ; NORMV-NEXT: masknez $a0, $a0, $a2
1050 ; NORMV-NEXT: maskeqz $a3, $a3, $a2
1051 ; NORMV-NEXT: or $a0, $a3, $a0
1052 ; NORMV-NEXT: addi.w $a0, $a0, 0
1053 ; NORMV-NEXT: masknez $a1, $a1, $a2
1054 ; NORMV-NEXT: maskeqz $a2, $a4, $a2
1055 ; NORMV-NEXT: or $a1, $a2, $a1
1056 ; NORMV-NEXT: nor $a0, $a0, $zero
1057 ; NORMV-NEXT: srli.d $a0, $a0, 31
1058 ; NORMV-NEXT: add.d $a0, $a1, $a0
1059 ; NORMV-NEXT: addi.w $a0, $a0, 0
1061 ; NORMV-NEXT: .LBB18_2:
1062 ; NORMV-NEXT: move $a0, $zero
1065 %tobool.not = icmp eq i32 %x, 0
1066 br i1 %tobool.not, label %cleanup, label %if.end
1068 if.end: ; preds = %entry
1069 %tobool1.not = icmp ult i32 %x, 65536
1070 %shl = shl i32 %x, 16
1071 %spec.select = select i1 %tobool1.not, i32 %shl, i32 %x
1072 %spec.select43 = select i1 %tobool1.not, i32 16, i32 32
1073 %tobool5.not = icmp ult i32 %spec.select, 16777216
1074 %shl7 = shl i32 %spec.select, 8
1075 %sub8 = add nsw i32 %spec.select43, -8
1076 %x.addr.1 = select i1 %tobool5.not, i32 %shl7, i32 %spec.select
1077 %r.1 = select i1 %tobool5.not, i32 %sub8, i32 %spec.select43
1078 %tobool11.not = icmp ult i32 %x.addr.1, 268435456
1079 %shl13 = shl i32 %x.addr.1, 4
1080 %sub14 = add nsw i32 %r.1, -4
1081 %x.addr.2 = select i1 %tobool11.not, i32 %shl13, i32 %x.addr.1
1082 %r.2 = select i1 %tobool11.not, i32 %sub14, i32 %r.1
1083 %tobool17.not = icmp ult i32 %x.addr.2, 1073741824
1084 %shl19 = shl i32 %x.addr.2, 2
1085 %sub20 = add nsw i32 %r.2, -2
1086 %x.addr.3 = select i1 %tobool17.not, i32 %shl19, i32 %x.addr.2
1087 %r.3 = select i1 %tobool17.not, i32 %sub20, i32 %r.2
1088 %x.addr.3.lobit = ashr i32 %x.addr.3, 31
1089 %x.addr.3.lobit.not = xor i32 %x.addr.3.lobit, -1
1090 %r.4 = add nsw i32 %r.3, %x.addr.3.lobit.not
1093 cleanup: ; preds = %entry, %if.end
1094 %retval.0 = phi i32 [ %r.4, %if.end ], [ 0, %entry ]
1098 define void @test16(i32 signext %arg, i32 signext %arg1) nounwind {
1099 ; CHECK-LABEL: test16:
1100 ; CHECK: # %bb.0: # %bb
1101 ; CHECK-NEXT: addi.d $sp, $sp, -32
1102 ; CHECK-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
1103 ; CHECK-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
1104 ; CHECK-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
1105 ; CHECK-NEXT: move $fp, $a1
1106 ; CHECK-NEXT: bl %plt(bar)
1107 ; CHECK-NEXT: move $s0, $a0
1108 ; CHECK-NEXT: .p2align 4, , 16
1109 ; CHECK-NEXT: .LBB19_1: # %bb2
1110 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
1111 ; CHECK-NEXT: move $a0, $s0
1112 ; CHECK-NEXT: bl %plt(bar)
1113 ; CHECK-NEXT: sll.w $s0, $s0, $fp
1114 ; CHECK-NEXT: bnez $a0, .LBB19_1
1115 ; CHECK-NEXT: # %bb.2: # %bb7
1116 ; CHECK-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
1117 ; CHECK-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
1118 ; CHECK-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
1119 ; CHECK-NEXT: addi.d $sp, $sp, 32
1122 ; NORMV-LABEL: test16:
1123 ; NORMV: # %bb.0: # %bb
1124 ; NORMV-NEXT: addi.d $sp, $sp, -32
1125 ; NORMV-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
1126 ; NORMV-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
1127 ; NORMV-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
1128 ; NORMV-NEXT: move $fp, $a1
1129 ; NORMV-NEXT: bl %plt(bar)
1130 ; NORMV-NEXT: move $s0, $a0
1131 ; NORMV-NEXT: .p2align 4, , 16
1132 ; NORMV-NEXT: .LBB19_1: # %bb2
1133 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
1134 ; NORMV-NEXT: addi.w $a0, $s0, 0
1135 ; NORMV-NEXT: bl %plt(bar)
1136 ; NORMV-NEXT: sll.w $s0, $s0, $fp
1137 ; NORMV-NEXT: bnez $a0, .LBB19_1
1138 ; NORMV-NEXT: # %bb.2: # %bb7
1139 ; NORMV-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
1140 ; NORMV-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
1141 ; NORMV-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
1142 ; NORMV-NEXT: addi.d $sp, $sp, 32
1145 %i = call signext i32 @bar(i32 signext %arg)
1148 bb2: ; preds = %bb2, %bb
1149 %i3 = phi i32 [ %i, %bb ], [ %i5, %bb2 ]
1150 %i4 = tail call signext i32 @bar(i32 signext %i3)
1151 %i5 = shl i32 %i3, %arg1
1152 %i6 = icmp eq i32 %i4, 0
1153 br i1 %i6, label %bb7, label %bb2
1159 define void @test17(i32 signext %arg, i32 signext %arg1) nounwind {
1160 ; CHECK-LABEL: test17:
1161 ; CHECK: # %bb.0: # %bb
1162 ; CHECK-NEXT: addi.d $sp, $sp, -32
1163 ; CHECK-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
1164 ; CHECK-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
1165 ; CHECK-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
1166 ; CHECK-NEXT: move $fp, $a1
1167 ; CHECK-NEXT: bl %plt(bat)
1168 ; CHECK-NEXT: move $s0, $a0
1169 ; CHECK-NEXT: .p2align 4, , 16
1170 ; CHECK-NEXT: .LBB20_1: # %bb2
1171 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
1172 ; CHECK-NEXT: move $a0, $s0
1173 ; CHECK-NEXT: bl %plt(bar)
1174 ; CHECK-NEXT: sll.w $s0, $s0, $fp
1175 ; CHECK-NEXT: bnez $a0, .LBB20_1
1176 ; CHECK-NEXT: # %bb.2: # %bb7
1177 ; CHECK-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
1178 ; CHECK-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
1179 ; CHECK-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
1180 ; CHECK-NEXT: addi.d $sp, $sp, 32
1183 ; NORMV-LABEL: test17:
1184 ; NORMV: # %bb.0: # %bb
1185 ; NORMV-NEXT: addi.d $sp, $sp, -32
1186 ; NORMV-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
1187 ; NORMV-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
1188 ; NORMV-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
1189 ; NORMV-NEXT: move $fp, $a1
1190 ; NORMV-NEXT: bl %plt(bat)
1191 ; NORMV-NEXT: move $s0, $a0
1192 ; NORMV-NEXT: .p2align 4, , 16
1193 ; NORMV-NEXT: .LBB20_1: # %bb2
1194 ; NORMV-NEXT: # =>This Inner Loop Header: Depth=1
1195 ; NORMV-NEXT: addi.w $a0, $s0, 0
1196 ; NORMV-NEXT: bl %plt(bar)
1197 ; NORMV-NEXT: sll.w $s0, $s0, $fp
1198 ; NORMV-NEXT: bnez $a0, .LBB20_1
1199 ; NORMV-NEXT: # %bb.2: # %bb7
1200 ; NORMV-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
1201 ; NORMV-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
1202 ; NORMV-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
1203 ; NORMV-NEXT: addi.d $sp, $sp, 32
1206 %i = call zeroext i16 @bat(i32 signext %arg)
1207 %zext = zext i16 %i to i32
1210 bb2: ; preds = %bb2, %bb
1211 %i3 = phi i32 [ %zext, %bb ], [ %i5, %bb2 ]
1212 %i4 = tail call signext i32 @bar(i32 signext %i3)
1213 %i5 = shl i32 %i3, %arg1
1214 %i6 = icmp eq i32 %i4, 0
1215 br i1 %i6, label %bb7, label %bb2
1220 declare zeroext i16 @bat(i32 signext)
1222 define signext i32 @sextw_sh2add(i1 zeroext %0, ptr %1, i32 signext %2, i32 signext %3, i32 signext %4) {
1223 ; CHECK-LABEL: sextw_sh2add:
1225 ; CHECK-NEXT: alsl.w $a2, $a2, $a3, 2
1226 ; CHECK-NEXT: beqz $a0, .LBB21_2
1227 ; CHECK-NEXT: # %bb.1:
1228 ; CHECK-NEXT: st.w $a2, $a1, 0
1229 ; CHECK-NEXT: .LBB21_2:
1230 ; CHECK-NEXT: add.w $a0, $a2, $a4
1233 ; NORMV-LABEL: sextw_sh2add:
1235 ; NORMV-NEXT: alsl.w $a2, $a2, $a3, 2
1236 ; NORMV-NEXT: beqz $a0, .LBB21_2
1237 ; NORMV-NEXT: # %bb.1:
1238 ; NORMV-NEXT: st.w $a2, $a1, 0
1239 ; NORMV-NEXT: .LBB21_2:
1240 ; NORMV-NEXT: add.d $a0, $a2, $a4
1241 ; NORMV-NEXT: addi.w $a0, $a0, 0
1245 br i1 %0, label %8, label %9
1248 store i32 %7, ptr %1, align 4
1252 %10 = add i32 %7, %4
1256 define signext i32 @test19(i64 %arg, i1 zeroext %c1, i1 zeroext %c2, ptr %p) nounwind {
1257 ; CHECK-LABEL: test19:
1258 ; CHECK: # %bb.0: # %bb
1259 ; CHECK-NEXT: addi.d $sp, $sp, -16
1260 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
1261 ; CHECK-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
1262 ; CHECK-NEXT: ori $a0, $zero, 35
1263 ; CHECK-NEXT: lu32i.d $a0, 1
1264 ; CHECK-NEXT: maskeqz $fp, $a0, $a1
1265 ; CHECK-NEXT: st.d $fp, $a3, 0
1266 ; CHECK-NEXT: beqz $a2, .LBB22_2
1267 ; CHECK-NEXT: # %bb.1: # %bb2
1268 ; CHECK-NEXT: move $a0, $zero
1269 ; CHECK-NEXT: bl %plt(bar)
1270 ; CHECK-NEXT: move $fp, $a0
1271 ; CHECK-NEXT: .LBB22_2: # %bb7
1272 ; CHECK-NEXT: bl %plt(side_effect)
1273 ; CHECK-NEXT: addi.w $a0, $fp, 0
1274 ; CHECK-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
1275 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
1276 ; CHECK-NEXT: addi.d $sp, $sp, 16
1279 ; NORMV-LABEL: test19:
1280 ; NORMV: # %bb.0: # %bb
1281 ; NORMV-NEXT: addi.d $sp, $sp, -16
1282 ; NORMV-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
1283 ; NORMV-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
1284 ; NORMV-NEXT: ori $a0, $zero, 35
1285 ; NORMV-NEXT: lu32i.d $a0, 1
1286 ; NORMV-NEXT: maskeqz $fp, $a0, $a1
1287 ; NORMV-NEXT: st.d $fp, $a3, 0
1288 ; NORMV-NEXT: beqz $a2, .LBB22_2
1289 ; NORMV-NEXT: # %bb.1: # %bb2
1290 ; NORMV-NEXT: move $a0, $zero
1291 ; NORMV-NEXT: bl %plt(bar)
1292 ; NORMV-NEXT: move $fp, $a0
1293 ; NORMV-NEXT: .LBB22_2: # %bb7
1294 ; NORMV-NEXT: bl %plt(side_effect)
1295 ; NORMV-NEXT: addi.w $a0, $fp, 0
1296 ; NORMV-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
1297 ; NORMV-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
1298 ; NORMV-NEXT: addi.d $sp, $sp, 16
1301 %sel = select i1 %c1, i64 4294967331, i64 0
1302 store i64 %sel, ptr %p, align 8
1303 br i1 %c2, label %bb2, label %bb7
1305 bb2: ; preds = %bb2, %bb
1306 %i4 = call signext i32 @bar(i32 0)
1307 %i4.sext = sext i32 %i4 to i64
1311 %phi = phi i64 [ %sel, %bb ], [ %i4.sext, %bb2 ]
1312 %trunc = trunc i64 %phi to i32
1313 call void @side_effect()
1317 declare void @side_effect(i64)