1 # RUN: llc -mtriple=thumbv8.1m.main -mattr=+lob %s -run-pass=arm-low-overhead-loops --verify-machineinstrs -o - | FileCheck %s
3 # TODO: Remove the lr = tMOVr
6 # CHECK: $lr = t2WLS $r2, [[EXIT:%bb[.0-9]+]]
7 # CHECK: [[PREHEADER:bb[.0-9a-z]+]]:
8 # CHECK: $lr = tMOVr killed $r2
9 # CHECK: [[BODY:bb[.0-9a-z]+]]:
10 # CHECK: $lr = t2LEUpdate renamable $lr
13 ; ModuleID = '/home/sampar01/src/llvm/test/CodeGen/Thumb2/LowOverheadLoops/while.ll'
14 source_filename = "/home/sampar01/src/llvm/test/CodeGen/Thumb2/LowOverheadLoops/while.ll"
15 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
16 target triple = "thumbv8.1m.main"
18 define dso_local arm_aapcscc void @copy(i16* nocapture %a, i16* nocapture readonly %b, i32 %N) {
20 %0 = call i1 @llvm.test.set.loop.iterations.i32(i32 %N)
21 br i1 %0, label %while.body.preheader, label %while.end
23 while.body.preheader: ; preds = %entry
24 %scevgep = getelementptr i16, i16* %a, i32 -1
25 %scevgep3 = getelementptr i16, i16* %b, i32 -1
28 while.body: ; preds = %while.body.preheader, %while.body
29 %lsr.iv4 = phi i16* [ %scevgep3, %while.body.preheader ], [ %scevgep5, %while.body ]
30 %lsr.iv = phi i16* [ %scevgep, %while.body.preheader ], [ %scevgep1, %while.body ]
31 %1 = phi i32 [ %3, %while.body ], [ %N, %while.body.preheader ]
32 %scevgep2 = getelementptr i16, i16* %lsr.iv, i32 1
33 %scevgep6 = getelementptr i16, i16* %lsr.iv4, i32 1
34 %2 = load i16, i16* %scevgep6, align 2, !tbaa !2
35 store i16 %2, i16* %scevgep2, align 2, !tbaa !2
36 %3 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %1, i32 1)
37 %4 = icmp ne i32 %3, 0
38 %scevgep1 = getelementptr i16, i16* %lsr.iv, i32 1
39 %scevgep5 = getelementptr i16, i16* %lsr.iv4, i32 1
40 br i1 %4, label %while.body, label %while.end
42 while.end: ; preds = %while.body, %entry
46 declare i1 @llvm.test.set.loop.iterations.i32(i32) #0
47 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #0
49 attributes #0 = { noduplicate nounwind }
50 attributes #1 = { nounwind }
52 !llvm.module.flags = !{!0, !1}
54 !0 = !{i32 1, !"wchar_size", i32 4}
55 !1 = !{i32 1, !"min_enum_size", i32 4}
57 !3 = !{!"short", !4, i64 0}
58 !4 = !{!"omnipotent char", !5, i64 0}
59 !5 = !{!"Simple C/C++ TBAA"}
65 exposesReturnsTwice: false
67 regBankSelected: false
70 tracksRegLiveness: false
74 - { reg: '$r0', virtual-reg: '' }
75 - { reg: '$r1', virtual-reg: '' }
76 - { reg: '$r2', 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: '$r7', callee-saved-restored: true,
103 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
106 machineFunctionInfo: {}
109 successors: %bb.1(0x40000000), %bb.3(0x40000000)
111 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
112 frame-setup CFI_INSTRUCTION def_cfa_offset 8
113 frame-setup CFI_INSTRUCTION offset $lr, -4
114 frame-setup CFI_INSTRUCTION offset $r7, -8
115 t2WhileLoopStart $r2, %bb.3, implicit-def dead $cpsr
118 bb.1.while.body.preheader:
119 successors: %bb.2(0x80000000)
121 renamable $r1, dead $cpsr = tSUBi8 killed renamable $r1, 2, 14, $noreg
122 renamable $r0, dead $cpsr = tSUBi8 killed renamable $r0, 2, 14, $noreg
123 $lr = tMOVr killed $r2, 14, $noreg
126 successors: %bb.2(0x7c000000), %bb.3(0x04000000)
128 renamable $r2, renamable $r1 = t2LDRH_PRE killed renamable $r1, 2, 14, $noreg :: (load 2 from %ir.scevgep6, !tbaa !2)
129 early-clobber renamable $r0 = t2STRH_PRE killed renamable $r2, killed renamable $r0, 2, 14, $noreg :: (store 2 into %ir.scevgep2, !tbaa !2)
130 renamable $lr = t2LoopDec killed renamable $lr, 1
131 t2LoopEnd renamable $lr, %bb.2, implicit-def dead $cpsr
135 tPOP_RET 14, $noreg, def $r7, def $pc