1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 -mattr=+d -O0 < %s | FileCheck %s --check-prefix=NOSHRINKW
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d -O2 < %s | FileCheck %s --check-prefix=SHRINKW
7 define void @eliminate_restore(i32 %n) nounwind {
8 ; NOSHRINKW-LABEL: eliminate_restore:
10 ; NOSHRINKW-NEXT: addi.d $sp, $sp, -16
11 ; NOSHRINKW-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
12 ; NOSHRINKW-NEXT: addi.w $a1, $a0, 0
13 ; NOSHRINKW-NEXT: ori $a0, $zero, 32
14 ; NOSHRINKW-NEXT: bltu $a0, $a1, .LBB0_2
15 ; NOSHRINKW-NEXT: b .LBB0_1
16 ; NOSHRINKW-NEXT: .LBB0_1: # %if.then
17 ; NOSHRINKW-NEXT: bl %plt(abort)
18 ; NOSHRINKW-NEXT: .LBB0_2: # %if.end
19 ; NOSHRINKW-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
20 ; NOSHRINKW-NEXT: addi.d $sp, $sp, 16
23 ; SHRINKW-LABEL: eliminate_restore:
25 ; SHRINKW-NEXT: addi.w $a0, $a0, 0
26 ; SHRINKW-NEXT: ori $a1, $zero, 32
27 ; SHRINKW-NEXT: bgeu $a1, $a0, .LBB0_2
28 ; SHRINKW-NEXT: # %bb.1: # %if.end
30 ; SHRINKW-NEXT: .LBB0_2: # %if.then
31 ; SHRINKW-NEXT: addi.d $sp, $sp, -16
32 ; SHRINKW-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
33 ; SHRINKW-NEXT: bl %plt(abort)
34 %cmp = icmp ule i32 %n, 32
35 br i1 %cmp, label %if.then, label %if.end
45 declare void @notdead(ptr)
47 define void @conditional_alloca(i32 %n) nounwind {
48 ; NOSHRINKW-LABEL: conditional_alloca:
50 ; NOSHRINKW-NEXT: addi.d $sp, $sp, -32
51 ; NOSHRINKW-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
52 ; NOSHRINKW-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
53 ; NOSHRINKW-NEXT: addi.d $fp, $sp, 32
54 ; NOSHRINKW-NEXT: addi.w $a1, $a0, 0
55 ; NOSHRINKW-NEXT: st.d $a0, $fp, -24 # 8-byte Folded Spill
56 ; NOSHRINKW-NEXT: ori $a0, $zero, 32
57 ; NOSHRINKW-NEXT: bltu $a0, $a1, .LBB1_2
58 ; NOSHRINKW-NEXT: b .LBB1_1
59 ; NOSHRINKW-NEXT: .LBB1_1: # %if.then
60 ; NOSHRINKW-NEXT: ld.d $a0, $fp, -24 # 8-byte Folded Reload
61 ; NOSHRINKW-NEXT: bstrpick.d $a0, $a0, 31, 0
62 ; NOSHRINKW-NEXT: addi.d $a0, $a0, 15
63 ; NOSHRINKW-NEXT: bstrpick.d $a0, $a0, 32, 4
64 ; NOSHRINKW-NEXT: slli.d $a1, $a0, 4
65 ; NOSHRINKW-NEXT: move $a0, $sp
66 ; NOSHRINKW-NEXT: sub.d $a0, $a0, $a1
67 ; NOSHRINKW-NEXT: move $sp, $a0
68 ; NOSHRINKW-NEXT: bl %plt(notdead)
69 ; NOSHRINKW-NEXT: b .LBB1_2
70 ; NOSHRINKW-NEXT: .LBB1_2: # %if.end
71 ; NOSHRINKW-NEXT: addi.d $sp, $fp, -32
72 ; NOSHRINKW-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
73 ; NOSHRINKW-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
74 ; NOSHRINKW-NEXT: addi.d $sp, $sp, 32
77 ; SHRINKW-LABEL: conditional_alloca:
79 ; SHRINKW-NEXT: addi.w $a1, $a0, 0
80 ; SHRINKW-NEXT: ori $a2, $zero, 32
81 ; SHRINKW-NEXT: bltu $a2, $a1, .LBB1_2
82 ; SHRINKW-NEXT: # %bb.1: # %if.then
83 ; SHRINKW-NEXT: addi.d $sp, $sp, -16
84 ; SHRINKW-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
85 ; SHRINKW-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
86 ; SHRINKW-NEXT: addi.d $fp, $sp, 16
87 ; SHRINKW-NEXT: bstrpick.d $a0, $a0, 31, 0
88 ; SHRINKW-NEXT: addi.d $a0, $a0, 15
89 ; SHRINKW-NEXT: bstrpick.d $a0, $a0, 32, 4
90 ; SHRINKW-NEXT: slli.d $a0, $a0, 4
91 ; SHRINKW-NEXT: sub.d $a0, $sp, $a0
92 ; SHRINKW-NEXT: move $sp, $a0
93 ; SHRINKW-NEXT: bl %plt(notdead)
94 ; SHRINKW-NEXT: addi.d $sp, $fp, -16
95 ; SHRINKW-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
96 ; SHRINKW-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
97 ; SHRINKW-NEXT: addi.d $sp, $sp, 16
98 ; SHRINKW-NEXT: .LBB1_2: # %if.end
100 %cmp = icmp ule i32 %n, 32
101 br i1 %cmp, label %if.then, label %if.end
104 %addr = alloca i8, i32 %n
105 call void @notdead(ptr %addr)