1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -run-pass=arm-low-overhead-loops %s --verify-machineinstrs -o - | FileCheck %s
5 define i16 @predicated_livout(ptr %input_1_vect, ptr %input_2_vect, i32 %block_size) #0 {
7 %rnd.up = add i32 %block_size, 7
8 %div = lshr i32 %rnd.up, 3
9 %0 = call i1 @llvm.test.set.loop.iterations.i32(i32 %div)
10 br i1 %0, label %for.body.preheader, label %for.cond.cleanup
12 for.body.preheader: ; preds = %entry
15 for.body: ; preds = %for.body.preheader, %for.body
16 %lsr.iv = phi i32 [ 0, %for.body.preheader ], [ %lsr.iv.next, %for.body ]
17 %input_1_vect.addr.052 = phi ptr [ %add.ptr, %for.body ], [ %input_1_vect, %for.body.preheader ]
18 %input_2_vect.addr.051 = phi ptr [ %add.ptr14, %for.body ], [ %input_2_vect, %for.body.preheader ]
19 %num_elements.049 = phi i32 [ %sub, %for.body ], [ %block_size, %for.body.preheader ]
20 %acc = phi <8 x i16> [ %acc.next, %for.body ], [ zeroinitializer, %for.body.preheader ]
21 %input_2_cast = bitcast ptr %input_2_vect.addr.051 to ptr
22 %input_1_cast = bitcast ptr %input_1_vect.addr.052 to ptr
23 %pred = tail call <8 x i1> @llvm.arm.mve.vctp16(i32 %num_elements.049)
24 %load.1 = tail call <8 x i8> @llvm.masked.load.v8i8.p0(ptr %input_1_cast, i32 1, <8 x i1> %pred, <8 x i8> undef)
25 %zext.load.1 = zext <8 x i8> %load.1 to <8 x i16>
26 %load.2 = tail call <8 x i8> @llvm.masked.load.v8i8.p0(ptr %input_2_cast, i32 1, <8 x i1> %pred, <8 x i8> undef)
27 %zext.load.2 = zext <8 x i8> %load.2 to <8 x i16>
28 %add = tail call <8 x i16> @llvm.arm.mve.add.predicated.v8i16.v8i1(<8 x i16> %zext.load.1, <8 x i16> %zext.load.2, <8 x i1> %pred, <8 x i16> undef)
29 %acc.next = tail call <8 x i16> @llvm.arm.mve.add.predicated.v8i16.v8i1(<8 x i16> %add, <8 x i16> %acc, <8 x i1> %pred, <8 x i16> undef)
30 %add.ptr = getelementptr inbounds i8, ptr %input_1_vect.addr.052, i32 8
31 %add.ptr14 = getelementptr inbounds i8, ptr %input_2_vect.addr.051, i32 8
32 %sub = add i32 %num_elements.049, -8
33 %iv.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %lsr.iv, i32 1)
34 %cmp = icmp ne i32 %iv.next, 0
35 %lsr.iv.next = add i32 %lsr.iv, -1
36 br i1 %cmp, label %for.body, label %middle.block
38 middle.block: ; preds = %for.body
39 %reduce = tail call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %acc.next)
42 for.cond.cleanup: ; preds = %entry
46 declare <8 x i1> @llvm.arm.mve.vctp16(i32) #1
47 declare <8 x i8> @llvm.masked.load.v8i8.p0(ptr, i32 immarg, <8 x i1>, <8 x i8>) #2
48 declare i1 @llvm.test.set.loop.iterations.i32(i32) #3
49 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #3
50 declare i16 @llvm.vector.reduce.add.v8i16(<8 x i16>) #4
51 declare <8 x i16> @llvm.arm.mve.add.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #1
55 name: predicated_livout
57 tracksRegLiveness: true
60 - { reg: '$r0', virtual-reg: '' }
61 - { reg: '$r1', virtual-reg: '' }
62 - { reg: '$r2', virtual-reg: '' }
69 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
70 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
71 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
72 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
73 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
74 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
77 machineFunctionInfo: {}
79 ; CHECK-LABEL: name: predicated_livout
81 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
82 ; CHECK-NEXT: liveins: $lr, $r0, $r1, $r2, $r7
84 ; CHECK-NEXT: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
85 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 8
86 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $lr, -4
87 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $r7, -8
88 ; CHECK-NEXT: $lr = MVE_WLSTP_16 killed renamable $r2, %bb.4
90 ; CHECK-NEXT: bb.1.for.body.preheader:
91 ; CHECK-NEXT: successors: %bb.2(0x80000000)
92 ; CHECK-NEXT: liveins: $lr, $r0, $r1
94 ; CHECK-NEXT: renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, $noreg, undef renamable $q0
95 ; CHECK-NEXT: renamable $r3, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
97 ; CHECK-NEXT: bb.2.for.body:
98 ; CHECK-NEXT: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
99 ; CHECK-NEXT: liveins: $lr, $q0, $r0, $r1, $r3
101 ; CHECK-NEXT: renamable $r3, dead $cpsr = tSUBi8 killed $r3, 1, 14 /* CC::al */, $noreg
102 ; CHECK-NEXT: renamable $r1, renamable $q1 = MVE_VLDRBU16_post killed renamable $r1, 8, 0, $noreg, $noreg :: (load (s64) from %ir.input_2_cast, align 1)
103 ; CHECK-NEXT: renamable $r0, renamable $q2 = MVE_VLDRBU16_post killed renamable $r0, 8, 0, $noreg, $noreg :: (load (s64) from %ir.input_1_cast, align 1)
104 ; CHECK-NEXT: renamable $q1 = MVE_VADDi16 killed renamable $q2, killed renamable $q1, 0, $noreg, $noreg, undef renamable $q1
105 ; CHECK-NEXT: renamable $q0 = MVE_VADDi16 killed renamable $q1, killed renamable $q0, 0, killed $noreg, $noreg, undef renamable $q0
106 ; CHECK-NEXT: $lr = MVE_LETP killed renamable $lr, %bb.2
108 ; CHECK-NEXT: bb.3.middle.block:
109 ; CHECK-NEXT: liveins: $q0
111 ; CHECK-NEXT: renamable $r0 = MVE_VADDVu16no_acc killed renamable $q0, 0, $noreg, $noreg
112 ; CHECK-NEXT: tPOP_RET 14 /* CC::al */, $noreg, def $r7, def $pc, implicit killed $r0
114 ; CHECK-NEXT: bb.4.for.cond.cleanup:
115 ; CHECK-NEXT: liveins: $lr
117 ; CHECK-NEXT: $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
118 ; CHECK-NEXT: tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
120 successors: %bb.1(0x40000000), %bb.4(0x40000000)
121 liveins: $r0, $r1, $r2, $lr, $r7
123 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
124 frame-setup CFI_INSTRUCTION def_cfa_offset 8
125 frame-setup CFI_INSTRUCTION offset $lr, -4
126 frame-setup CFI_INSTRUCTION offset $r7, -8
127 renamable $r3, dead $cpsr = tADDi3 renamable $r2, 7, 14, $noreg
128 renamable $lr = t2LSRri killed renamable $r3, 3, 14, $noreg, $noreg
129 $lr = t2WhileLoopStartLR renamable $lr, %bb.4, implicit-def dead $cpsr
132 bb.1.for.body.preheader:
133 successors: %bb.2(0x80000000)
134 liveins: $r0, $r1, $r2, $lr
136 renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, $noreg, undef renamable $q0
137 renamable $r3, dead $cpsr = tMOVi8 0, 14, $noreg
140 successors: %bb.2(0x7c000000), %bb.3(0x04000000)
141 liveins: $q0, $r0, $r1, $r2, $r3, $lr
143 renamable $vpr = MVE_VCTP16 renamable $r2, 0, $noreg, $noreg
144 renamable $r3, dead $cpsr = tSUBi8 killed $r3, 1, 14, $noreg
145 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 8, 14, $noreg
146 renamable $lr = t2LoopDec killed renamable $lr, 1
147 MVE_VPST 1, implicit $vpr
148 renamable $r1, renamable $q1 = MVE_VLDRBU16_post killed renamable $r1, 8, 1, renamable $vpr, $noreg :: (load (s64) from %ir.input_2_cast, align 1)
149 renamable $r0, renamable $q2 = MVE_VLDRBU16_post killed renamable $r0, 8, 1, renamable $vpr, $noreg :: (load (s64) from %ir.input_1_cast, align 1)
150 renamable $q1 = MVE_VADDi16 killed renamable $q2, killed renamable $q1, 1, renamable $vpr, $noreg, undef renamable $q1
151 renamable $q0 = MVE_VADDi16 killed renamable $q1, killed renamable $q0, 1, killed renamable $vpr, $noreg, undef renamable $q0
152 t2LoopEnd renamable $lr, %bb.2, implicit-def dead $cpsr
158 renamable $r0 = MVE_VADDVu16no_acc killed renamable $q0, 0, $noreg, $noreg
159 tPOP_RET 14, $noreg, def $r7, def $pc, implicit killed $r0
161 bb.4.for.cond.cleanup:
164 $r0, dead $cpsr = tMOVi8 0, 14, $noreg
165 tBX_RET 14, $noreg, implicit killed $r0