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