1 # RUN: llc -mtriple=thumbv8.1m.main -run-pass=arm-low-overhead-loops %s -verify-machineinstrs -o - | FileCheck %s
3 # CHECK-NOT: DoLoopStart
5 # CHECK: bb.1.for.body:
6 # CHECK: $lr = t2SUBri killed renamable $lr, 1, 14, $noreg, def $cpsr
7 # CHECK-NOT: t2CMPri $lr
8 # CHECK: tBcc %bb.3, 1, $cpsr
9 # CHECK: tB %bb.2, 14, $noreg
10 # CHECK: bb.2.for.cond.cleanup:
11 # CHECK: bb.3.for.header:
14 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
15 target triple = "thumbv8.1m.main"
17 define void @size_limit(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) {
19 call void @llvm.set.loop.iterations.i32(i32 %N)
20 %scevgep = getelementptr i32, i32* %a, i32 -1
21 %scevgep4 = getelementptr i32, i32* %c, i32 -1
22 %scevgep8 = getelementptr i32, i32* %b, i32 -1
25 for.body: ; preds = %for.header
26 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1
27 %ld1 = load i32, i32* %scevgep11, align 4
28 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1
29 %ld2 = load i32, i32* %scevgep7, align 4
30 %mul = mul nsw i32 %ld2, %ld1
31 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1
32 store i32 %mul, i32* %scevgep3, align 4
33 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1
34 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1
35 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1
36 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1)
37 %cmp = icmp ne i32 %count.next, 0
38 br i1 %cmp, label %for.header, label %for.cond.cleanup
40 for.cond.cleanup: ; preds = %for.body
43 for.header: ; preds = %for.body, %entry
44 %lsr.iv9 = phi i32* [ %scevgep8, %entry ], [ %scevgep10, %for.body ]
45 %lsr.iv5 = phi i32* [ %scevgep4, %entry ], [ %scevgep6, %for.body ]
46 %lsr.iv1 = phi i32* [ %scevgep, %entry ], [ %scevgep2, %for.body ]
47 %count = phi i32 [ %N, %entry ], [ %count.next, %for.body ]
51 ; Function Attrs: nounwind
52 declare i32 @llvm.arm.space(i32 immarg, i32) #0
54 ; Function Attrs: noduplicate nounwind
55 declare void @llvm.set.loop.iterations.i32(i32) #1
57 ; Function Attrs: noduplicate nounwind
58 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #1
60 attributes #0 = { nounwind }
61 attributes #1 = { noduplicate nounwind }
67 exposesReturnsTwice: false
69 regBankSelected: false
72 tracksRegLiveness: true
76 - { reg: '$r0', virtual-reg: '' }
77 - { reg: '$r1', virtual-reg: '' }
78 - { reg: '$r2', virtual-reg: '' }
79 - { reg: '$r3', virtual-reg: '' }
81 isFrameAddressTaken: false
82 isReturnAddressTaken: false
92 cvBytesOfCalleeSavedRegisters: 0
93 hasOpaqueSPAdjustment: false
95 hasMustTailInVarArgFunc: false
101 - { id: 0, name: '', type: spill-slot, offset: -12, 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: 1, name: '', type: spill-slot, offset: -16, 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: 2, name: '', type: spill-slot, offset: -20, 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: 3, name: '', type: spill-slot, offset: -24, 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: 4, name: '', type: spill-slot, offset: -28, 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: 5, name: '', type: spill-slot, offset: -32, size: 4, alignment: 4,
117 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
118 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
119 - { id: 6, name: '', type: spill-slot, offset: -36, size: 4, alignment: 4,
120 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
121 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
122 - { id: 7, name: '', type: spill-slot, offset: -40, size: 4, alignment: 4,
123 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
124 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
125 - { id: 8, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
126 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
127 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
128 - { id: 9, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
129 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
130 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
133 machineFunctionInfo: {}
136 successors: %bb.3(0x80000000)
137 liveins: $r0, $r1, $r2, $r3, $r7, $lr
139 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
140 frame-setup CFI_INSTRUCTION def_cfa_offset 8
141 frame-setup CFI_INSTRUCTION offset $lr, -4
142 frame-setup CFI_INSTRUCTION offset $r7, -8
143 $sp = frame-setup tSUBspi $sp, 8, 14, $noreg
144 frame-setup CFI_INSTRUCTION def_cfa_offset 40
145 t2DoLoopStart renamable $r3
146 renamable $r0, dead $cpsr = tSUBi8 killed renamable $r0, 4, 14, $noreg
147 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 4, 14, $noreg
148 renamable $r1, dead $cpsr = tSUBi8 killed renamable $r1, 4, 14, $noreg
149 tSTRspi killed $r1, $sp, 7, 14, $noreg :: (store 4 into %stack.0)
150 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store 4 into %stack.1)
151 tSTRspi killed $r0, $sp, 5, 14, $noreg :: (store 4 into %stack.2)
152 tSTRspi killed $r3, $sp, 4, 14, $noreg :: (store 4 into %stack.3)
156 successors: %bb.3(0x40000000), %bb.2(0x40000000)
158 $r0 = tLDRspi $sp, 3, 14, $noreg :: (load 4 from %stack.4)
159 renamable $r1, renamable $r0 = t2LDR_PRE renamable $r0, 4, 14, $noreg :: (load 4 from %ir.scevgep11)
160 $r2 = tLDRspi $sp, 2, 14, $noreg :: (load 4 from %stack.5)
161 renamable $r3, renamable $r2 = t2LDR_PRE renamable $r2, 4, 14, $noreg :: (load 4 from %ir.scevgep7)
162 renamable $r1, dead $cpsr = nsw tMUL killed renamable $r3, killed renamable $r1, 14, $noreg
163 $r3 = tLDRspi $sp, 1, 14, $noreg :: (load 4 from %stack.6)
164 early-clobber renamable $r3 = t2STR_PRE killed renamable $r1, renamable $r3, 4, 14, $noreg :: (store 4 into %ir.scevgep3)
165 $r1 = tLDRspi $sp, 0, 14, $noreg :: (load 4 from %stack.7)
166 $lr = tMOVr killed $r1, 14, $noreg
167 renamable $lr = t2LoopDec killed renamable $lr, 1
168 $r12 = tMOVr $lr, 14, $noreg
169 tSTRspi killed $r0, $sp, 7, 14, $noreg :: (store 4 into %stack.0)
170 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store 4 into %stack.1)
171 tSTRspi killed $r3, $sp, 5, 14, $noreg :: (store 4 into %stack.2)
172 t2STRi12 killed $r12, $sp, 16, 14, $noreg :: (store 4 into %stack.3)
173 t2LoopEnd killed renamable $lr, %bb.3, implicit-def dead $cpsr
176 bb.2.for.cond.cleanup:
177 $sp = tADDspi $sp, 8, 14, $noreg
178 tPOP_RET 14, $noreg, def $r7, def $pc
181 successors: %bb.1(0x80000000)
183 $r0 = tLDRspi $sp, 4, 14, $noreg :: (load 4 from %stack.3)
184 $r1 = tLDRspi $sp, 5, 14, $noreg :: (load 4 from %stack.2)
185 $r2 = tLDRspi $sp, 6, 14, $noreg :: (load 4 from %stack.1)
186 $r3 = tLDRspi $sp, 7, 14, $noreg :: (load 4 from %stack.0)
187 tSTRspi killed $r0, $sp, 0, 14, $noreg :: (store 4 into %stack.7)
188 tSTRspi killed $r1, $sp, 1, 14, $noreg :: (store 4 into %stack.6)
189 tSTRspi killed $r2, $sp, 2, 14, $noreg :: (store 4 into %stack.5)
190 tSTRspi killed $r3, $sp, 3, 14, $noreg :: (store 4 into %stack.4)