1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=thumbv8.1m.main -run-pass=arm-low-overhead-loops %s -verify-machineinstrs -o - | FileCheck %s
5 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
6 target triple = "thumbv8.1m.main"
8 define void @size_limit(ptr nocapture %a, ptr nocapture readonly %b, ptr nocapture readonly %c, i32 %N) {
10 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N)
11 %scevgep = getelementptr i32, ptr %a, i32 -1
12 %scevgep4 = getelementptr i32, ptr %c, i32 -1
13 %scevgep8 = getelementptr i32, ptr %b, i32 -1
16 for.body: ; preds = %for.header
17 %scevgep11 = getelementptr i32, ptr %lsr.iv9, i32 1
18 %ld1 = load i32, ptr %scevgep11, align 4
19 %scevgep7 = getelementptr i32, ptr %lsr.iv5, i32 1
20 %ld2 = load i32, ptr %scevgep7, align 4
21 %mul = mul nsw i32 %ld2, %ld1
22 %scevgep3 = getelementptr i32, ptr %lsr.iv1, i32 1
23 store i32 %mul, ptr %scevgep3, align 4
24 %scevgep2 = getelementptr i32, ptr %lsr.iv1, i32 1
25 %scevgep6 = getelementptr i32, ptr %lsr.iv5, i32 1
26 %scevgep10 = getelementptr i32, ptr %lsr.iv9, i32 1
27 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1)
28 %cmp = icmp ne i32 %count.next, 0
29 br i1 %cmp, label %for.header, label %for.cond.cleanup
31 for.cond.cleanup: ; preds = %for.body
34 for.header: ; preds = %for.body, %entry
35 %lsr.iv9 = phi ptr [ %scevgep8, %entry ], [ %scevgep10, %for.body ]
36 %lsr.iv5 = phi ptr [ %scevgep4, %entry ], [ %scevgep6, %for.body ]
37 %lsr.iv1 = phi ptr [ %scevgep, %entry ], [ %scevgep2, %for.body ]
38 %count = phi i32 [ %start, %entry ], [ %count.next, %for.body ]
42 ; Function Attrs: nounwind
43 declare i32 @llvm.arm.space(i32 immarg, i32) #0
45 ; Function Attrs: noduplicate nounwind
46 declare i32 @llvm.start.loop.iterations.i32(i32) #1
48 ; Function Attrs: noduplicate nounwind
49 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #1
51 attributes #0 = { nounwind }
52 attributes #1 = { noduplicate nounwind }
58 exposesReturnsTwice: false
60 regBankSelected: false
63 tracksRegLiveness: true
67 - { reg: '$r0', virtual-reg: '' }
68 - { reg: '$r1', virtual-reg: '' }
69 - { reg: '$r2', virtual-reg: '' }
70 - { reg: '$r3', virtual-reg: '' }
72 isFrameAddressTaken: false
73 isReturnAddressTaken: false
83 cvBytesOfCalleeSavedRegisters: 0
84 hasOpaqueSPAdjustment: false
86 hasMustTailInVarArgFunc: false
92 - { id: 0, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
93 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
94 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
95 - { id: 1, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,
96 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
97 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
98 - { id: 2, name: '', type: spill-slot, offset: -20, size: 4, alignment: 4,
99 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
100 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
101 - { id: 3, name: '', type: spill-slot, offset: -24, size: 4, alignment: 4,
102 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
103 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
104 - { id: 4, name: '', type: spill-slot, offset: -28, size: 4, alignment: 4,
105 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
106 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
107 - { id: 5, name: '', type: spill-slot, offset: -32, size: 4, alignment: 4,
108 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
109 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
110 - { id: 6, name: '', type: spill-slot, offset: -36, size: 4, alignment: 4,
111 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
112 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
113 - { id: 7, name: '', type: spill-slot, offset: -40, size: 4, alignment: 4,
114 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
115 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
116 - { id: 8, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
117 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
118 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
119 - { id: 9, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
120 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
121 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
124 machineFunctionInfo: {}
126 ; CHECK-LABEL: name: size_limit
128 ; CHECK: successors: %bb.3(0x80000000)
129 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r3, $r7
130 ; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
131 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 8
132 ; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
133 ; CHECK: frame-setup CFI_INSTRUCTION offset $r7, -8
134 ; CHECK: $sp = frame-setup tSUBspi $sp, 8, 14 /* CC::al */, $noreg
135 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 40
136 ; CHECK: dead $lr = tMOVr renamable $r3, 14 /* CC::al */, $noreg
137 ; CHECK: renamable $r0, dead $cpsr = tSUBi8 killed renamable $r0, 4, 14 /* CC::al */, $noreg
138 ; CHECK: renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 4, 14 /* CC::al */, $noreg
139 ; CHECK: renamable $r1, dead $cpsr = tSUBi8 killed renamable $r1, 4, 14 /* CC::al */, $noreg
140 ; CHECK: tSTRspi killed $r1, $sp, 7, 14 /* CC::al */, $noreg :: (store (s32) into %stack.0)
141 ; CHECK: tSTRspi killed $r2, $sp, 6, 14 /* CC::al */, $noreg :: (store (s32) into %stack.1)
142 ; CHECK: tSTRspi killed $r0, $sp, 5, 14 /* CC::al */, $noreg :: (store (s32) into %stack.2)
143 ; CHECK: tSTRspi killed $r3, $sp, 4, 14 /* CC::al */, $noreg :: (store (s32) into %stack.3)
144 ; CHECK: tB %bb.3, 14 /* CC::al */, $noreg
145 ; CHECK: bb.1.for.body:
146 ; CHECK: successors: %bb.3(0x40000000), %bb.2(0x40000000)
147 ; CHECK: $r0 = tLDRspi $sp, 3, 14 /* CC::al */, $noreg :: (load (s32) from %stack.4)
148 ; CHECK: renamable $r1, renamable $r0 = t2LDR_PRE killed renamable $r0, 4, 14 /* CC::al */, $noreg :: (load (s32) from %ir.scevgep11)
149 ; CHECK: $r2 = tLDRspi $sp, 2, 14 /* CC::al */, $noreg :: (load (s32) from %stack.5)
150 ; CHECK: renamable $r3, renamable $r2 = t2LDR_PRE killed renamable $r2, 4, 14 /* CC::al */, $noreg :: (load (s32) from %ir.scevgep7)
151 ; CHECK: renamable $r1, dead $cpsr = nsw tMUL killed renamable $r3, killed renamable $r1, 14 /* CC::al */, $noreg
152 ; CHECK: $r3 = tLDRspi $sp, 1, 14 /* CC::al */, $noreg :: (load (s32) from %stack.6)
153 ; CHECK: early-clobber renamable $r3 = t2STR_PRE killed renamable $r1, killed renamable $r3, 4, 14 /* CC::al */, $noreg :: (store (s32) into %ir.scevgep3)
154 ; CHECK: $r1 = tLDRspi $sp, 0, 14 /* CC::al */, $noreg :: (load (s32) from %stack.7)
155 ; CHECK: $lr = tMOVr killed $r1, 14 /* CC::al */, $noreg
156 ; CHECK: renamable $lr = t2SUBri killed renamable $lr, 1, 14 /* CC::al */, $noreg, def $cpsr
157 ; CHECK: $r12 = tMOVr killed $lr, 14 /* CC::al */, $noreg
158 ; CHECK: tSTRspi killed $r0, $sp, 7, 14 /* CC::al */, $noreg :: (store (s32) into %stack.0)
159 ; CHECK: tSTRspi killed $r2, $sp, 6, 14 /* CC::al */, $noreg :: (store (s32) into %stack.1)
160 ; CHECK: tSTRspi killed $r3, $sp, 5, 14 /* CC::al */, $noreg :: (store (s32) into %stack.2)
161 ; CHECK: t2STRi12 killed $r12, $sp, 16, 14 /* CC::al */, $noreg :: (store (s32) into %stack.3)
162 ; CHECK: tBcc %bb.3, 1 /* CC::ne */, killed $cpsr
163 ; CHECK: tB %bb.2, 14 /* CC::al */, $noreg
164 ; CHECK: bb.2.for.cond.cleanup:
165 ; CHECK: $sp = tADDspi $sp, 8, 14 /* CC::al */, $noreg
166 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r7, def $pc
167 ; CHECK: bb.3.for.header:
168 ; CHECK: successors: %bb.1(0x80000000)
169 ; CHECK: $r0 = tLDRspi $sp, 4, 14 /* CC::al */, $noreg :: (load (s32) from %stack.3)
170 ; CHECK: $r1 = tLDRspi $sp, 5, 14 /* CC::al */, $noreg :: (load (s32) from %stack.2)
171 ; CHECK: $r2 = tLDRspi $sp, 6, 14 /* CC::al */, $noreg :: (load (s32) from %stack.1)
172 ; CHECK: $r3 = tLDRspi $sp, 7, 14 /* CC::al */, $noreg :: (load (s32) from %stack.0)
173 ; CHECK: tSTRspi killed $r0, $sp, 0, 14 /* CC::al */, $noreg :: (store (s32) into %stack.7)
174 ; CHECK: tSTRspi killed $r1, $sp, 1, 14 /* CC::al */, $noreg :: (store (s32) into %stack.6)
175 ; CHECK: tSTRspi killed $r2, $sp, 2, 14 /* CC::al */, $noreg :: (store (s32) into %stack.5)
176 ; CHECK: tSTRspi killed $r3, $sp, 3, 14 /* CC::al */, $noreg :: (store (s32) into %stack.4)
177 ; CHECK: tB %bb.1, 14 /* CC::al */, $noreg
179 successors: %bb.3(0x80000000)
180 liveins: $r0, $r1, $r2, $r3, $r7, $lr
182 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
183 frame-setup CFI_INSTRUCTION def_cfa_offset 8
184 frame-setup CFI_INSTRUCTION offset $lr, -4
185 frame-setup CFI_INSTRUCTION offset $r7, -8
186 $sp = frame-setup tSUBspi $sp, 8, 14, $noreg
187 frame-setup CFI_INSTRUCTION def_cfa_offset 40
188 $lr = t2DoLoopStart renamable $r3
189 renamable $r0, dead $cpsr = tSUBi8 killed renamable $r0, 4, 14, $noreg
190 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 4, 14, $noreg
191 renamable $r1, dead $cpsr = tSUBi8 killed renamable $r1, 4, 14, $noreg
192 tSTRspi killed $r1, $sp, 7, 14, $noreg :: (store (s32) into %stack.0)
193 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store (s32) into %stack.1)
194 tSTRspi killed $r0, $sp, 5, 14, $noreg :: (store (s32) into %stack.2)
195 tSTRspi killed $r3, $sp, 4, 14, $noreg :: (store (s32) into %stack.3)
199 successors: %bb.3(0x40000000), %bb.2(0x40000000)
201 $r0 = tLDRspi $sp, 3, 14, $noreg :: (load (s32) from %stack.4)
202 renamable $r1, renamable $r0 = t2LDR_PRE renamable $r0, 4, 14, $noreg :: (load (s32) from %ir.scevgep11)
203 $r2 = tLDRspi $sp, 2, 14, $noreg :: (load (s32) from %stack.5)
204 renamable $r3, renamable $r2 = t2LDR_PRE renamable $r2, 4, 14, $noreg :: (load (s32) from %ir.scevgep7)
205 renamable $r1, dead $cpsr = nsw tMUL killed renamable $r3, killed renamable $r1, 14, $noreg
206 $r3 = tLDRspi $sp, 1, 14, $noreg :: (load (s32) from %stack.6)
207 early-clobber renamable $r3 = t2STR_PRE killed renamable $r1, renamable $r3, 4, 14, $noreg :: (store (s32) into %ir.scevgep3)
208 $r1 = tLDRspi $sp, 0, 14, $noreg :: (load (s32) from %stack.7)
209 $lr = tMOVr killed $r1, 14, $noreg
210 renamable $lr = t2LoopDec killed renamable $lr, 1
211 $r12 = tMOVr $lr, 14, $noreg
212 tSTRspi killed $r0, $sp, 7, 14, $noreg :: (store (s32) into %stack.0)
213 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store (s32) into %stack.1)
214 tSTRspi killed $r3, $sp, 5, 14, $noreg :: (store (s32) into %stack.2)
215 t2STRi12 killed $r12, $sp, 16, 14, $noreg :: (store (s32) into %stack.3)
216 t2LoopEnd killed renamable $lr, %bb.3, implicit-def dead $cpsr
219 bb.2.for.cond.cleanup:
220 $sp = tADDspi $sp, 8, 14, $noreg
221 tPOP_RET 14, $noreg, def $r7, def $pc
224 successors: %bb.1(0x80000000)
226 $r0 = tLDRspi $sp, 4, 14, $noreg :: (load (s32) from %stack.3)
227 $r1 = tLDRspi $sp, 5, 14, $noreg :: (load (s32) from %stack.2)
228 $r2 = tLDRspi $sp, 6, 14, $noreg :: (load (s32) from %stack.1)
229 $r3 = tLDRspi $sp, 7, 14, $noreg :: (load (s32) from %stack.0)
230 tSTRspi killed $r0, $sp, 0, 14, $noreg :: (store (s32) into %stack.7)
231 tSTRspi killed $r1, $sp, 1, 14, $noreg :: (store (s32) into %stack.6)
232 tSTRspi killed $r2, $sp, 2, 14, $noreg :: (store (s32) into %stack.5)
233 tSTRspi killed $r3, $sp, 3, 14, $noreg :: (store (s32) into %stack.4)