1 # RUN: llc -mtriple=thumbv8.1m.main %s -run-pass=arm-low-overhead-loops -o -
2 # CHECK: bb.1.for.body.preheader:
6 # CHECK: $lr = t2LEUpdate renamable $lr, %bb.2
9 define dso_local arm_aapcscc i32 @search(i8* nocapture readonly %c, i32 %N) {
11 %cmp11 = icmp eq i32 %N, 0
12 br i1 %cmp11, label %for.cond.cleanup, label %for.body.preheader
14 for.body.preheader: ; preds = %entry
15 call void @llvm.set.loop.iterations.i32(i32 %N)
18 for.cond.cleanup: ; preds = %for.inc, %entry
19 %found.0.lcssa = phi i32 [ 0, %entry ], [ %found.1, %for.inc ]
20 %spaces.0.lcssa = phi i32 [ 0, %entry ], [ %spaces.1, %for.inc ]
21 %sub = sub nsw i32 %found.0.lcssa, %spaces.0.lcssa
24 for.body: ; preds = %for.inc, %for.body.preheader
25 %lsr.iv1 = phi i8* [ %c, %for.body.preheader ], [ %scevgep, %for.inc ]
26 %spaces.013 = phi i32 [ %spaces.1, %for.inc ], [ 0, %for.body.preheader ]
27 %found.012 = phi i32 [ %found.1, %for.inc ], [ 0, %for.body.preheader ]
28 %0 = phi i32 [ %N, %for.body.preheader ], [ %3, %for.inc ]
29 %1 = load i8, i8* %lsr.iv1, align 1
30 %2 = zext i8 %1 to i32
31 switch i32 %2, label %for.inc [
38 sw.bb: ; preds = %for.body, %for.body, %for.body
39 %inc = add nsw i32 %found.012, 1
42 sw.bb1: ; preds = %for.body
43 %inc2 = add nsw i32 %spaces.013, 1
46 for.inc: ; preds = %sw.bb1, %sw.bb, %for.body
47 %found.1 = phi i32 [ %found.012, %for.body ], [ %found.012, %sw.bb1 ], [ %inc, %sw.bb ]
48 %spaces.1 = phi i32 [ %spaces.013, %for.body ], [ %inc2, %sw.bb1 ], [ %spaces.013, %sw.bb ]
49 %scevgep = getelementptr i8, i8* %lsr.iv1, i32 1
50 %3 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %0, i32 1)
51 %4 = icmp ne i32 %3, 0
52 br i1 %4, label %for.body, label %for.cond.cleanup
55 declare void @llvm.set.loop.iterations.i32(i32) #1
56 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #1
57 attributes #1 = { noduplicate nounwind }
58 attributes #2 = { nounwind }
64 exposesReturnsTwice: false
66 regBankSelected: false
69 tracksRegLiveness: false
73 - { reg: '$r0', virtual-reg: '' }
74 - { reg: '$r1', virtual-reg: '' }
76 isFrameAddressTaken: false
77 isReturnAddressTaken: false
87 cvBytesOfCalleeSavedRegisters: 0
88 hasOpaqueSPAdjustment: false
90 hasMustTailInVarArgFunc: false
96 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
97 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
98 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
99 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
100 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
101 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
102 - { id: 2, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
103 stack-id: default, callee-saved-register: '$r6', callee-saved-restored: true,
104 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
105 - { id: 3, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,
106 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
107 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
110 machineFunctionInfo: {}
113 successors: %bb.7(0x30000000), %bb.1(0x50000000)
115 frame-setup tPUSH 14, $noreg, killed $r4, killed $r6, $r7, killed $lr, implicit-def $sp, implicit $sp
116 frame-setup CFI_INSTRUCTION def_cfa_offset 16
117 frame-setup CFI_INSTRUCTION offset $lr, -4
118 frame-setup CFI_INSTRUCTION offset $r7, -8
119 frame-setup CFI_INSTRUCTION offset $r6, -12
120 frame-setup CFI_INSTRUCTION offset $r4, -16
121 $r7 = frame-setup tADDrSPi $sp, 2, 14, $noreg
122 frame-setup CFI_INSTRUCTION def_cfa $r7, 8
125 bb.1.for.body.preheader:
126 successors: %bb.4(0x80000000)
128 $lr = tMOVr $r1, 14, $noreg
129 t2DoLoopStart killed $r1
130 renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
131 renamable $r12 = t2MOVi 1, 14, $noreg, $noreg
132 renamable $r2, dead $cpsr = tMOVi8 0, 14, $noreg
136 successors: %bb.3(0x80000000)
138 tCMPi8 killed renamable $r3, 32, 14, $noreg, implicit-def $cpsr
139 t2IT 0, 8, implicit-def $itstate
140 renamable $r1 = nsw tADDi8 $noreg, killed renamable $r1, 1, 0, killed $cpsr, implicit $r1, implicit killed $itstate
143 successors: %bb.4(0x7c000000), %bb.8(0x04000000)
145 renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 1, 14, $noreg
146 renamable $lr = t2LoopDec killed renamable $lr, 1
147 t2LoopEnd renamable $lr, %bb.4, implicit-def dead $cpsr
151 successors: %bb.2(0x26666665), %bb.5(0x5999999b)
153 renamable $r3 = tLDRBi renamable $r0, 0, 14, $noreg :: (load 1 from %ir.lsr.iv1)
154 renamable $r4 = t2SUBri renamable $r3, 108, 14, $noreg, $noreg
155 tCMPi8 renamable $r4, 4, 14, $noreg, implicit-def $cpsr
156 tBcc %bb.2, 8, killed $cpsr
159 successors: %bb.6(0x6db6db6e), %bb.2(0x12492492)
161 renamable $r4 = t2LSLrr renamable $r12, killed renamable $r4, 14, $noreg, $noreg
162 t2TSTri killed renamable $r4, 25, 14, $noreg, implicit-def $cpsr
163 tBcc %bb.2, 0, killed $cpsr
166 successors: %bb.3(0x80000000)
168 renamable $r2, dead $cpsr = nsw tADDi8 killed renamable $r2, 1, 14, $noreg
172 successors: %bb.8(0x80000000)
174 renamable $r2, dead $cpsr = tMOVi8 0, 14, $noreg
175 renamable $r1, dead $cpsr = tMOVi8 0, 14, $noreg
177 bb.8.for.cond.cleanup:
178 renamable $r0, dead $cpsr = nsw tSUBrr killed renamable $r2, killed renamable $r1, 14, $noreg
179 tPOP_RET 14, $noreg, def $r4, def $r6, def $r7, def $pc, implicit killed $r0