1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=armv8.1m.main -mattr=+lob -run-pass=arm-low-overhead-loops --verify-machineinstrs %s -o - | FileCheck %s
5 define void @size_limit(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) {
7 %cmp8 = icmp eq i32 %N, 0
8 br i1 %cmp8, label %for.cond.cleanup, label %for.body.preheader
10 for.body.preheader: ; preds = %entry
11 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N)
14 for.cond.cleanup: ; preds = %for.end, %entry
17 for.body: ; preds = %for.end, %for.body.preheader
18 %lsr.iv4 = phi i32* [ %b, %for.body.preheader ], [ %scevgep5, %for.end ]
19 %lsr.iv2 = phi i32* [ %c, %for.body.preheader ], [ %scevgep3, %for.end ]
20 %lsr.iv1 = phi i32* [ %a, %for.body.preheader ], [ %scevgep, %for.end ]
21 %lsr.iv = phi i32 [ %start, %for.body.preheader ], [ %lsr.iv.next, %for.end ]
22 %size = call i32 @llvm.arm.space(i32 3072, i32 undef)
23 %0 = load i32, i32* %lsr.iv4, align 4
24 %1 = load i32, i32* %lsr.iv2, align 4
25 %mul = mul nsw i32 %1, %0
26 store i32 %mul, i32* %lsr.iv1, align 4
27 %cmp = icmp ne i32 %0, 0
28 br i1 %cmp, label %middle.block, label %for.end
30 middle.block: ; preds = %for.body
31 %div = udiv i32 %1, %0
32 store i32 %div, i32* %lsr.iv1, align 4
33 %size.1 = call i32 @llvm.arm.space(i32 1024, i32 undef)
36 for.end: ; preds = %middle.block, %for.body
37 %scevgep = getelementptr i32, i32* %lsr.iv1, i32 1
38 %scevgep3 = getelementptr i32, i32* %lsr.iv2, i32 1
39 %scevgep5 = getelementptr i32, i32* %lsr.iv4, i32 1
40 %lsr.iv.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %lsr.iv, i32 1)
41 %exitcond = icmp eq i32 %lsr.iv.next, 0
42 br i1 %exitcond, label %for.cond.cleanup, label %for.body
45 ; Function Attrs: nounwind
46 declare i32 @llvm.arm.space(i32 immarg, i32) #0
48 ; Function Attrs: noduplicate nounwind
49 declare i32 @llvm.start.loop.iterations.i32(i32) #1
51 ; Function Attrs: noduplicate nounwind
52 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #1
54 ; Function Attrs: nounwind
55 declare void @llvm.stackprotector(i8*, i8**) #0
57 attributes #0 = { nounwind }
58 attributes #1 = { noduplicate nounwind }
64 exposesReturnsTwice: false
66 regBankSelected: false
69 tracksRegLiveness: true
73 - { reg: '$r0', virtual-reg: '' }
74 - { reg: '$r1', virtual-reg: '' }
75 - { reg: '$r2', virtual-reg: '' }
76 - { reg: '$r3', virtual-reg: '' }
78 isFrameAddressTaken: false
79 isReturnAddressTaken: false
89 cvBytesOfCalleeSavedRegisters: 0
90 hasOpaqueSPAdjustment: false
92 hasMustTailInVarArgFunc: false
98 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
99 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
100 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
101 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
102 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
103 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
106 machineFunctionInfo: {}
108 ; CHECK-LABEL: name: size_limit
110 ; CHECK: successors: %bb.1(0x80000000)
111 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r3, $r4
112 ; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r4, killed $lr, implicit-def $sp, implicit $sp
113 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 8
114 ; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
115 ; CHECK: frame-setup CFI_INSTRUCTION offset $r4, -8
116 ; CHECK: tCMPi8 $r3, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
117 ; CHECK: t2IT 0, 8, implicit-def $itstate
118 ; CHECK: tPOP_RET 0 /* CC::eq */, killed $cpsr, def $r4, def $pc, implicit killed $itstate
119 ; CHECK: bb.1.for.body.preheader:
120 ; CHECK: successors: %bb.2(0x80000000)
121 ; CHECK: liveins: $r0, $r1, $r2, $r3
122 ; CHECK: dead $lr = tMOVr $r3, 14 /* CC::al */, $noreg
123 ; CHECK: $lr = tMOVr killed $r3, 14 /* CC::al */, $noreg
124 ; CHECK: tB %bb.2, 14 /* CC::al */, $noreg
125 ; CHECK: bb.2.for.end:
126 ; CHECK: successors: %bb.5(0x04000000), %bb.3(0x7c000000)
127 ; CHECK: liveins: $lr, $r0, $r1, $r2
128 ; CHECK: renamable $r1, dead $cpsr = tADDi8 killed renamable $r1, 4, 14 /* CC::al */, $noreg
129 ; CHECK: renamable $r2, dead $cpsr = tADDi8 killed renamable $r2, 4, 14 /* CC::al */, $noreg
130 ; CHECK: renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 4, 14 /* CC::al */, $noreg
131 ; CHECK: renamable $lr = t2SUBri killed renamable $lr, 1, 14 /* CC::al */, $noreg, def $cpsr
132 ; CHECK: tBcc %bb.3, 1 /* CC::ne */, killed $cpsr
133 ; CHECK: t2B %bb.5, 14 /* CC::al */, $noreg
134 ; CHECK: bb.3.for.body:
135 ; CHECK: successors: %bb.4(0x50000000), %bb.2(0x30000000)
136 ; CHECK: liveins: $lr, $r0, $r1, $r2
137 ; CHECK: dead renamable $r3 = SPACE 3072, undef renamable $r0
138 ; CHECK: renamable $r3 = tLDRi renamable $r1, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.lsr.iv4)
139 ; CHECK: renamable $r12 = t2LDRi12 renamable $r2, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.lsr.iv2)
140 ; CHECK: tCMPi8 renamable $r3, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
141 ; CHECK: renamable $r4 = nsw t2MUL renamable $r12, renamable $r3, 14 /* CC::al */, $noreg
142 ; CHECK: tSTRi killed renamable $r4, renamable $r0, 0, 14 /* CC::al */, $noreg :: (store (s32) into %ir.lsr.iv1)
143 ; CHECK: t2Bcc %bb.2, 0 /* CC::eq */, killed $cpsr
144 ; CHECK: bb.4.middle.block:
145 ; CHECK: successors: %bb.2(0x80000000)
146 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r3, $r12
147 ; CHECK: renamable $r3 = t2UDIV killed renamable $r12, killed renamable $r3, 14 /* CC::al */, $noreg
148 ; CHECK: tSTRi killed renamable $r3, renamable $r0, 0, 14 /* CC::al */, $noreg :: (store (s32) into %ir.lsr.iv1)
149 ; CHECK: dead renamable $r3 = SPACE 1024, undef renamable $r0
150 ; CHECK: t2B %bb.2, 14 /* CC::al */, $noreg
151 ; CHECK: bb.5.for.cond.cleanup:
152 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r4, def $pc
154 successors: %bb.1(0x80000000)
155 liveins: $r0, $r1, $r2, $r3, $r4, $lr
157 frame-setup tPUSH 14, $noreg, killed $r4, killed $lr, implicit-def $sp, implicit $sp
158 frame-setup CFI_INSTRUCTION def_cfa_offset 8
159 frame-setup CFI_INSTRUCTION offset $lr, -4
160 frame-setup CFI_INSTRUCTION offset $r4, -8
161 tCMPi8 $r3, 0, 14, $noreg, implicit-def $cpsr
162 t2IT 0, 8, implicit-def $itstate
163 tPOP_RET 0, killed $cpsr, def $r4, def $pc, implicit killed $itstate
165 bb.1.for.body.preheader:
166 successors: %bb.2(0x80000000)
167 liveins: $r0, $r1, $r2, $r3, $r4, $lr
169 $lr = tMOVr $r3, 14, $noreg
170 $lr = t2DoLoopStart killed $r3
174 successors: %bb.5(0x04000000), %bb.3(0x7c000000)
175 liveins: $lr, $r0, $r1, $r2
177 renamable $r1, dead $cpsr = tADDi8 killed renamable $r1, 4, 14, $noreg
178 renamable $r2, dead $cpsr = tADDi8 killed renamable $r2, 4, 14, $noreg
179 renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 4, 14, $noreg
180 renamable $lr = t2LoopDec killed renamable $lr, 1
181 t2LoopEnd renamable $lr, %bb.3, implicit-def dead $cpsr
182 t2B %bb.5, 14, $noreg
185 successors: %bb.4(0x50000000), %bb.2(0x30000000)
186 liveins: $lr, $r0, $r1, $r2
188 dead renamable $r3 = SPACE 3072, undef renamable $r0
189 renamable $r3 = tLDRi renamable $r1, 0, 14, $noreg :: (load (s32) from %ir.lsr.iv4)
190 renamable $r12 = t2LDRi12 renamable $r2, 0, 14, $noreg :: (load (s32) from %ir.lsr.iv2)
191 tCMPi8 renamable $r3, 0, 14, $noreg, implicit-def $cpsr
192 renamable $r4 = nsw t2MUL renamable $r12, renamable $r3, 14, $noreg
193 tSTRi killed renamable $r4, renamable $r0, 0, 14, $noreg :: (store (s32) into %ir.lsr.iv1)
194 t2Bcc %bb.2, 0, killed $cpsr
197 successors: %bb.2(0x80000000)
198 liveins: $lr, $r0, $r1, $r2, $r3, $r12
200 renamable $r3 = t2UDIV killed renamable $r12, killed renamable $r3, 14, $noreg
201 tSTRi killed renamable $r3, renamable $r0, 0, 14, $noreg :: (store (s32) into %ir.lsr.iv1)
202 dead renamable $r3 = SPACE 1024, undef renamable $r0
203 t2B %bb.2, 14, $noreg
205 bb.5.for.cond.cleanup:
206 tPOP_RET 14, $noreg, def $r4, def $pc