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: t2CMPri $lr, 0, 14, $noreg, implicit-def $cpsr
7 # CHECK: t2Bcc %bb.3, 1, $cpsr
8 # CHECK: tB %bb.2, 14, $noreg
9 # CHECK: bb.2.for.cond.cleanup:
10 # CHECK: bb.3.for.header:
13 define void @size_limit(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) {
15 call void @llvm.set.loop.iterations.i32(i32 %N)
16 %scevgep = getelementptr i32, i32* %a, i32 -1
17 %scevgep4 = getelementptr i32, i32* %c, i32 -1
18 %scevgep8 = getelementptr i32, i32* %b, i32 -1
21 for.body: ; preds = %for.header
22 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1
23 %ld1 = load i32, i32* %scevgep11, align 4
24 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1
25 %ld2 = load i32, i32* %scevgep7, align 4
26 %mul = mul nsw i32 %ld2, %ld1
27 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1
28 store i32 %mul, i32* %scevgep3, align 4
29 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1
30 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1
31 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1
32 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1)
33 %cmp = icmp ne i32 %count.next, 0
34 br i1 %cmp, label %for.header, label %for.cond.cleanup
36 for.cond.cleanup: ; preds = %for.body
39 for.header: ; preds = %for.body, %entry
40 %lsr.iv9 = phi i32* [ %scevgep8, %entry ], [ %scevgep10, %for.body ]
41 %lsr.iv5 = phi i32* [ %scevgep4, %entry ], [ %scevgep6, %for.body ]
42 %lsr.iv1 = phi i32* [ %scevgep, %entry ], [ %scevgep2, %for.body ]
43 %count = phi i32 [ %N, %entry ], [ %count.next, %for.body ]
47 ; Function Attrs: nounwind
48 declare i32 @llvm.arm.space(i32 immarg, i32) #0
49 ; Function Attrs: noduplicate nounwind
50 declare void @llvm.set.loop.iterations.i32(i32) #1
51 ; Function Attrs: noduplicate nounwind
52 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #1
54 attributes #0 = { nounwind }
55 attributes #1 = { noduplicate nounwind }
61 exposesReturnsTwice: false
63 regBankSelected: false
66 tracksRegLiveness: false
70 - { reg: '$r0', virtual-reg: '' }
71 - { reg: '$r1', virtual-reg: '' }
72 - { reg: '$r2', virtual-reg: '' }
73 - { reg: '$r3', virtual-reg: '' }
75 isFrameAddressTaken: false
76 isReturnAddressTaken: false
86 cvBytesOfCalleeSavedRegisters: 0
87 hasOpaqueSPAdjustment: false
89 hasMustTailInVarArgFunc: false
95 - { id: 0, name: '', type: spill-slot, offset: -12, 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: 1, name: '', type: spill-slot, offset: -16, 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: 2, name: '', type: spill-slot, offset: -20, 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: 3, name: '', type: spill-slot, offset: -24, 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: 4, name: '', type: spill-slot, offset: -28, 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: 5, name: '', type: spill-slot, offset: -32, 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: 6, name: '', type: spill-slot, offset: -36, 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: 7, name: '', type: spill-slot, offset: -40, 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: 8, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
120 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
121 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
122 - { id: 9, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
123 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
124 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
127 machineFunctionInfo: {}
130 successors: %bb.3(0x80000000)
132 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
133 frame-setup CFI_INSTRUCTION def_cfa_offset 8
134 frame-setup CFI_INSTRUCTION offset $lr, -4
135 frame-setup CFI_INSTRUCTION offset $r7, -8
136 $sp = frame-setup tSUBspi $sp, 8, 14, $noreg
137 frame-setup CFI_INSTRUCTION def_cfa_offset 40
138 t2DoLoopStart renamable $r3
139 renamable $r0, dead $cpsr = tSUBi8 killed renamable $r0, 4, 14, $noreg
140 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 4, 14, $noreg
141 renamable $r1, dead $cpsr = tSUBi8 killed renamable $r1, 4, 14, $noreg
142 tSTRspi killed $r1, $sp, 7, 14, $noreg :: (store 4 into %stack.0)
143 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store 4 into %stack.1)
144 tSTRspi killed $r0, $sp, 5, 14, $noreg :: (store 4 into %stack.2)
145 tSTRspi killed $r3, $sp, 4, 14, $noreg :: (store 4 into %stack.3)
149 successors: %bb.3(0x40000000), %bb.2(0x40000000)
151 $r0 = tLDRspi $sp, 3, 14, $noreg :: (load 4 from %stack.4)
152 renamable $r1, renamable $r0 = t2LDR_PRE renamable $r0, 4, 14, $noreg :: (load 4 from %ir.scevgep11)
153 $r2 = tLDRspi $sp, 2, 14, $noreg :: (load 4 from %stack.5)
154 renamable $r3, renamable $r2 = t2LDR_PRE renamable $r2, 4, 14, $noreg :: (load 4 from %ir.scevgep7)
155 renamable $r1, dead $cpsr = nsw tMUL killed renamable $r3, killed renamable $r1, 14, $noreg
156 $r3 = tLDRspi $sp, 1, 14, $noreg :: (load 4 from %stack.6)
157 early-clobber renamable $r3 = t2STR_PRE killed renamable $r1, renamable $r3, 4, 14, $noreg :: (store 4 into %ir.scevgep3)
158 $r1 = tLDRspi $sp, 0, 14, $noreg :: (load 4 from %stack.7)
159 $lr = tMOVr killed $r1, 14, $noreg
160 renamable $lr = t2LoopDec killed renamable $lr, 1
161 $r12 = tMOVr $lr, 14, $noreg
162 tSTRspi killed $r0, $sp, 7, 14, $noreg :: (store 4 into %stack.0)
163 tSTRspi killed $r2, $sp, 6, 14, $noreg :: (store 4 into %stack.1)
164 tSTRspi killed $r3, $sp, 5, 14, $noreg :: (store 4 into %stack.2)
165 t2STRi12 killed $r12, $sp, 16, 14, $noreg :: (store 4 into %stack.3)
166 t2LoopEnd killed renamable $lr, %bb.3, implicit-def dead $cpsr
169 bb.2.for.cond.cleanup:
170 $sp = tADDspi $sp, 8, 14, $noreg
171 tPOP_RET 14, $noreg, def $r7, def $pc
174 successors: %bb.1(0x80000000)
176 $r0 = tLDRspi $sp, 4, 14, $noreg :: (load 4 from %stack.3)
177 $r1 = tLDRspi $sp, 5, 14, $noreg :: (load 4 from %stack.2)
178 $r2 = tLDRspi $sp, 6, 14, $noreg :: (load 4 from %stack.1)
179 $r3 = tLDRspi $sp, 7, 14, $noreg :: (load 4 from %stack.0)
180 tSTRspi killed $r0, $sp, 0, 14, $noreg :: (store 4 into %stack.7)
181 tSTRspi killed $r1, $sp, 1, 14, $noreg :: (store 4 into %stack.6)
182 tSTRspi killed $r2, $sp, 2, 14, $noreg :: (store 4 into %stack.5)
183 tSTRspi killed $r3, $sp, 3, 14, $noreg :: (store 4 into %stack.4)