1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc --force-dwarf-frame-section %s -o - | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv8.1m.main-arm-none-eabi"
12 ; for (int i = 0; i < n; ++i)
17 define hidden i32 @f(i32 %n) local_unnamed_addr #0 {
19 ; CHECK: .cfi_sections .debug_frame
20 ; CHECK-NEXT: .cfi_startproc
21 ; CHECK-NEXT: @ %bb.0: @ %entry
22 ; CHECK-NEXT: pac r12, lr, sp
23 ; CHECK-NEXT: .save {r4, r5, r6, r7, r8, r9, ra_auth_code, lr}
24 ; CHECK-NEXT: push.w {r4, r5, r6, r7, r8, r9, r12, lr}
25 ; CHECK-NEXT: .cfi_def_cfa_offset 32
26 ; CHECK-NEXT: .cfi_offset lr, -4
27 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
28 ; CHECK-NEXT: .cfi_offset r9, -12
29 ; CHECK-NEXT: .cfi_offset r8, -16
30 ; CHECK-NEXT: .cfi_offset r7, -20
31 ; CHECK-NEXT: .cfi_offset r6, -24
32 ; CHECK-NEXT: .cfi_offset r5, -28
33 ; CHECK-NEXT: .cfi_offset r4, -32
34 ; CHECK-NEXT: .setfp r7, sp, #12
35 ; CHECK-NEXT: add r7, sp, #12
36 ; CHECK-NEXT: .cfi_def_cfa r7, 20
37 ; CHECK-NEXT: mov r5, r0
38 ; CHECK-NEXT: movs r0, #7
39 ; CHECK-NEXT: add.w r0, r0, r5, lsl #2
40 ; CHECK-NEXT: bic r0, r0, #7
41 ; CHECK-NEXT: sub.w r4, sp, r0
42 ; CHECK-NEXT: mov sp, r4
43 ; CHECK-NEXT: mov r0, r5
44 ; CHECK-NEXT: mov r1, r4
46 ; CHECK-NEXT: cmp r5, #1
47 ; CHECK-NEXT: blt .LBB0_3
48 ; CHECK-NEXT: @ %bb.1: @ %for.body.preheader
49 ; CHECK-NEXT: subs r0, r5, #1
50 ; CHECK-NEXT: and r12, r5, #3
51 ; CHECK-NEXT: cmp r0, #3
52 ; CHECK-NEXT: bhs .LBB0_4
53 ; CHECK-NEXT: @ %bb.2:
54 ; CHECK-NEXT: movs r2, #0
55 ; CHECK-NEXT: movs r0, #0
56 ; CHECK-NEXT: b .LBB0_6
57 ; CHECK-NEXT: .LBB0_3:
58 ; CHECK-NEXT: movs r0, #0
59 ; CHECK-NEXT: b .LBB0_9
60 ; CHECK-NEXT: .LBB0_4: @ %for.body.preheader.new
61 ; CHECK-NEXT: bic r0, r5, #3
62 ; CHECK-NEXT: movs r2, #1
63 ; CHECK-NEXT: subs r0, #4
64 ; CHECK-NEXT: sub.w r3, r4, #16
65 ; CHECK-NEXT: add.w lr, r2, r0, lsr #2
66 ; CHECK-NEXT: movs r2, #0
67 ; CHECK-NEXT: movs r0, #0
68 ; CHECK-NEXT: .LBB0_5: @ %for.body
69 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
70 ; CHECK-NEXT: ldr r5, [r3, #16]!
71 ; CHECK-NEXT: adds r2, #4
72 ; CHECK-NEXT: add r0, r5
73 ; CHECK-NEXT: ldrd r5, r1, [r3, #4]
74 ; CHECK-NEXT: ldr r6, [r3, #12]
75 ; CHECK-NEXT: add r0, r5
76 ; CHECK-NEXT: add r0, r1
77 ; CHECK-NEXT: add r0, r6
78 ; CHECK-NEXT: le lr, .LBB0_5
79 ; CHECK-NEXT: .LBB0_6: @ %for.cond.cleanup.loopexit.unr-lcssa
80 ; CHECK-NEXT: cmp.w r12, #0
81 ; CHECK-NEXT: beq .LBB0_9
82 ; CHECK-NEXT: @ %bb.7: @ %for.body.epil
83 ; CHECK-NEXT: ldr.w r3, [r4, r2, lsl #2]
84 ; CHECK-NEXT: cmp.w r12, #1
85 ; CHECK-NEXT: add r0, r3
86 ; CHECK-NEXT: beq .LBB0_9
87 ; CHECK-NEXT: @ %bb.8: @ %for.body.epil.1
88 ; CHECK-NEXT: add.w r2, r4, r2, lsl #2
89 ; CHECK-NEXT: cmp.w r12, #2
90 ; CHECK-NEXT: ldr r1, [r2, #4]
91 ; CHECK-NEXT: add r0, r1
93 ; CHECK-NEXT: ldrne r1, [r2, #8]
94 ; CHECK-NEXT: addne r0, r1
95 ; CHECK-NEXT: .LBB0_9: @ %for.cond.cleanup
96 ; CHECK-NEXT: sub.w r4, r7, #12
97 ; CHECK-NEXT: mov sp, r4
98 ; CHECK-NEXT: pop.w {r4, r5, r6, r7, r8, r9, r12, lr}
99 ; CHECK-NEXT: aut r12, lr, sp
102 %vla = alloca i32, i32 %n, align 4
103 %call = call i32 @g(i32 %n, ptr nonnull %vla) #0
104 %cmp8 = icmp sgt i32 %n, 0
105 br i1 %cmp8, label %for.body.preheader, label %for.cond.cleanup
107 for.body.preheader: ; preds = %entry
109 %xtraiter = and i32 %n, 3
110 %1 = icmp ult i32 %0, 3
111 br i1 %1, label %for.cond.cleanup.loopexit.unr-lcssa, label %for.body.preheader.new
113 for.body.preheader.new: ; preds = %for.body.preheader
114 %unroll_iter = and i32 %n, -4
117 for.cond.cleanup.loopexit.unr-lcssa: ; preds = %for.body, %for.body.preheader
118 %add.lcssa.ph = phi i32 [ undef, %for.body.preheader ], [ %add.3, %for.body ]
119 %i.010.unr = phi i32 [ 0, %for.body.preheader ], [ %inc.3, %for.body ]
120 %s.09.unr = phi i32 [ 0, %for.body.preheader ], [ %add.3, %for.body ]
121 %lcmp.mod.not = icmp eq i32 %xtraiter, 0
122 br i1 %lcmp.mod.not, label %for.cond.cleanup, label %for.body.epil
124 for.body.epil: ; preds = %for.cond.cleanup.loopexit.unr-lcssa
125 %arrayidx.epil = getelementptr inbounds i32, ptr %vla, i32 %i.010.unr
126 %2 = load i32, ptr %arrayidx.epil, align 4
127 %add.epil = add nsw i32 %2, %s.09.unr
128 %epil.iter.cmp.not = icmp eq i32 %xtraiter, 1
129 br i1 %epil.iter.cmp.not, label %for.cond.cleanup, label %for.body.epil.1
131 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit.unr-lcssa, %for.body.epil.2, %for.body.epil.1, %for.body.epil, %entry
132 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add.lcssa.ph, %for.cond.cleanup.loopexit.unr-lcssa ], [ %add.epil, %for.body.epil ], [ %add.epil.1, %for.body.epil.1 ], [ %add.epil.2, %for.body.epil.2 ]
135 for.body: ; preds = %for.body, %for.body.preheader.new
136 %i.010 = phi i32 [ 0, %for.body.preheader.new ], [ %inc.3, %for.body ]
137 %s.09 = phi i32 [ 0, %for.body.preheader.new ], [ %add.3, %for.body ]
138 %niter = phi i32 [ %unroll_iter, %for.body.preheader.new ], [ %niter.nsub.3, %for.body ]
139 %arrayidx = getelementptr inbounds i32, ptr %vla, i32 %i.010
140 %3 = load i32, ptr %arrayidx, align 4
141 %add = add nsw i32 %3, %s.09
142 %inc = or disjoint i32 %i.010, 1
143 %arrayidx.1 = getelementptr inbounds i32, ptr %vla, i32 %inc
144 %4 = load i32, ptr %arrayidx.1, align 4
145 %add.1 = add nsw i32 %4, %add
146 %inc.1 = or disjoint i32 %i.010, 2
147 %arrayidx.2 = getelementptr inbounds i32, ptr %vla, i32 %inc.1
148 %5 = load i32, ptr %arrayidx.2, align 4
149 %add.2 = add nsw i32 %5, %add.1
150 %inc.2 = or disjoint i32 %i.010, 3
151 %arrayidx.3 = getelementptr inbounds i32, ptr %vla, i32 %inc.2
152 %6 = load i32, ptr %arrayidx.3, align 4
153 %add.3 = add nsw i32 %6, %add.2
154 %inc.3 = add nuw nsw i32 %i.010, 4
155 %niter.nsub.3 = add i32 %niter, -4
156 %niter.ncmp.3 = icmp eq i32 %niter.nsub.3, 0
157 br i1 %niter.ncmp.3, label %for.cond.cleanup.loopexit.unr-lcssa, label %for.body
159 for.body.epil.1: ; preds = %for.body.epil
160 %inc.epil = add nuw nsw i32 %i.010.unr, 1
161 %arrayidx.epil.1 = getelementptr inbounds i32, ptr %vla, i32 %inc.epil
162 %7 = load i32, ptr %arrayidx.epil.1, align 4
163 %add.epil.1 = add nsw i32 %7, %add.epil
164 %epil.iter.cmp.1.not = icmp eq i32 %xtraiter, 2
165 br i1 %epil.iter.cmp.1.not, label %for.cond.cleanup, label %for.body.epil.2
167 for.body.epil.2: ; preds = %for.body.epil.1
168 %inc.epil.1 = add nuw nsw i32 %i.010.unr, 2
169 %arrayidx.epil.2 = getelementptr inbounds i32, ptr %vla, i32 %inc.epil.1
170 %8 = load i32, ptr %arrayidx.epil.2, align 4
171 %add.epil.2 = add nsw i32 %8, %add.epil.1
172 br label %for.cond.cleanup
175 declare dso_local i32 @g(i32, ptr) local_unnamed_addr #0
177 attributes #0 = { nounwind "sign-return-address"="non-leaf"}
179 !llvm.module.flags = !{!0, !1, !2}
181 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
182 !1 = !{i32 8, !"sign-return-address", i32 1}
183 !2 = !{i32 8, !"sign-return-address-all", i32 0}