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 -o - --verify-machineinstrs | FileCheck %s
4 # General test for vpsel exclusion from tail predication
7 define dso_local i32 @vpsel_after_vpt(i16* nocapture readonly %a, i16* nocapture readonly %b, i16* nocapture readonly %c, i16* nocapture readonly %d, i32 %N) local_unnamed_addr #0 {
9 %cmp9 = icmp eq i32 %N, 0
11 %tmp1 = lshr i32 %tmp, 2
12 %tmp2 = shl nuw i32 %tmp1, 2
13 %tmp3 = add i32 %tmp2, -4
14 %tmp4 = lshr i32 %tmp3, 2
15 %tmp5 = add nuw nsw i32 %tmp4, 1
16 br i1 %cmp9, label %for.cond.cleanup, label %vector.ph
18 vector.ph: ; preds = %entry
19 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp5)
22 vector.body: ; preds = %vector.body, %vector.ph
23 %lsr.iv1 = phi i32 [ %lsr.iv.next, %vector.body ], [ %start, %vector.ph ]
24 %lsr.iv.d = phi i16* [ %scevgep.d, %vector.body ], [ %d, %vector.ph ]
25 %lsr.iv.c = phi i16* [ %scevgep.c, %vector.body ], [ %c, %vector.ph ]
26 %lsr.iv18 = phi i16* [ %scevgep19, %vector.body ], [ %b, %vector.ph ]
27 %lsr.iv = phi i16* [ %scevgep, %vector.body ], [ %a, %vector.ph ]
28 %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %tmp14, %vector.body ]
29 %tmp7 = phi i32 [ %N, %vector.ph ], [ %tmp9, %vector.body ]
30 %lsr.iv17 = bitcast i16* %lsr.iv to <4 x i16>*
31 %lsr.iv1820 = bitcast i16* %lsr.iv18 to <4 x i16>*
32 %lsr.iv1820.c = bitcast i16* %lsr.iv.c to <4 x i16>*
33 %lsr.iv17.d = bitcast i16* %lsr.iv.d to <4 x i16>*
34 %tmp8 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %tmp7)
35 %tmp9 = sub i32 %tmp7, 4
36 %wide.masked.load = call <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>* %lsr.iv17, i32 2, <4 x i1> %tmp8, <4 x i16> undef)
37 %tmp10 = sext <4 x i16> %wide.masked.load to <4 x i32>
38 %wide.masked.load14 = call <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>* %lsr.iv1820, i32 2, <4 x i1> %tmp8, <4 x i16> undef)
39 %tmp11 = sext <4 x i16> %wide.masked.load14 to <4 x i32>
40 %wide.masked.load.c = call <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>* %lsr.iv1820.c, i32 2, <4 x i1> %tmp8, <4 x i16> undef)
41 %sext.load.c = sext <4 x i16> %wide.masked.load.c to <4 x i32>
42 %wide.masked.load.d = call <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>* %lsr.iv17.d, i32 2, <4 x i1> %tmp8, <4 x i16> undef)
43 %sext.load.d = sext <4 x i16> %wide.masked.load.d to <4 x i32>
44 %tmp12 = mul nsw <4 x i32> %tmp11, %tmp10
45 %mul.2 = mul nsw <4 x i32> %sext.load.c, %sext.load.d
46 %tmp13 = add <4 x i32> %tmp12, %mul.2
47 %acc = add <4 x i32> %tmp13, %vec.phi
48 %tmp14 = select <4 x i1> %tmp8, <4 x i32> %acc, <4 x i32> %vec.phi
49 %scevgep = getelementptr i16, i16* %lsr.iv, i32 4
50 %scevgep19 = getelementptr i16, i16* %lsr.iv18, i32 4
51 %scevgep.c = getelementptr i16, i16* %lsr.iv.c, i32 4
52 %scevgep.d = getelementptr i16, i16* %lsr.iv.d, i32 4
53 %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %lsr.iv1, i32 1)
54 %tmp16 = icmp ne i32 %tmp15, 0
55 %lsr.iv.next = add nsw i32 %lsr.iv1, -1
56 br i1 %tmp16, label %vector.body, label %middle.block
58 middle.block: ; preds = %vector.body
59 %tmp17 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %tmp14)
60 br label %for.cond.cleanup
62 for.cond.cleanup: ; preds = %middle.block, %entry
63 %res.0.lcssa = phi i32 [ 0, %entry ], [ %tmp17, %middle.block ]
66 declare <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>*, i32 immarg, <4 x i1>, <4 x i16>) #1
67 declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #2
68 declare i32 @llvm.start.loop.iterations.i32(i32) #3
69 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #3
70 declare <4 x i1> @llvm.arm.mve.vctp32(i32) #4
76 exposesReturnsTwice: false
78 regBankSelected: false
81 tracksRegLiveness: true
85 - { reg: '$r0', virtual-reg: '' }
86 - { reg: '$r1', virtual-reg: '' }
87 - { reg: '$r2', virtual-reg: '' }
88 - { reg: '$r3', virtual-reg: '' }
90 isFrameAddressTaken: false
91 isReturnAddressTaken: false
101 cvBytesOfCalleeSavedRegisters: 0
102 hasOpaqueSPAdjustment: false
104 hasMustTailInVarArgFunc: false
109 - { id: 0, type: default, offset: 0, size: 4, alignment: 8, stack-id: default,
110 isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true,
111 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
113 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
114 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
115 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
116 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
117 stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true,
118 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
119 - { id: 2, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
120 stack-id: default, callee-saved-register: '$r5', callee-saved-restored: true,
121 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
122 - { id: 3, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,
123 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
124 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
127 machineFunctionInfo: {}
129 ; CHECK-LABEL: name: vpsel_after_vpt
131 ; CHECK: successors: %bb.4(0x30000000), %bb.1(0x50000000)
132 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r3, $r4, $r5, $r7
133 ; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r4, killed $r5, killed $r7, killed $lr, implicit-def $sp, implicit $sp
134 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 16
135 ; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
136 ; CHECK: frame-setup CFI_INSTRUCTION offset $r7, -8
137 ; CHECK: frame-setup CFI_INSTRUCTION offset $r5, -12
138 ; CHECK: frame-setup CFI_INSTRUCTION offset $r4, -16
139 ; CHECK: renamable $r12 = t2LDRi12 $sp, 16, 14 /* CC::al */, $noreg :: (load (s32) from %fixed-stack.0, align 8)
140 ; CHECK: t2CMPri renamable $r12, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
141 ; CHECK: tBcc %bb.4, 0 /* CC::eq */, killed $cpsr
142 ; CHECK: bb.1.vector.ph:
143 ; CHECK: successors: %bb.2(0x80000000)
144 ; CHECK: liveins: $r0, $r1, $r2, $r3, $r12
145 ; CHECK: renamable $lr = t2ADDri renamable $r12, 3, 14 /* CC::al */, $noreg, $noreg
146 ; CHECK: renamable $r4, dead $cpsr = tMOVi8 1, 14 /* CC::al */, $noreg
147 ; CHECK: renamable $lr = t2BICri killed renamable $lr, 3, 14 /* CC::al */, $noreg, $noreg
148 ; CHECK: renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, undef renamable $q0
149 ; CHECK: renamable $lr = t2SUBri killed renamable $lr, 4, 14 /* CC::al */, $noreg, $noreg
150 ; CHECK: renamable $r5 = nuw nsw t2ADDrs killed renamable $r4, killed renamable $lr, 19, 14 /* CC::al */, $noreg, $noreg
151 ; CHECK: dead $lr = t2DLS renamable $r5
152 ; CHECK: $r4 = tMOVr killed $r5, 14 /* CC::al */, $noreg
153 ; CHECK: bb.2.vector.body:
154 ; CHECK: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
155 ; CHECK: liveins: $q0, $r0, $r1, $r2, $r3, $r4, $r12
156 ; CHECK: renamable $vpr = MVE_VCTP32 renamable $r12, 0, $noreg
157 ; CHECK: MVE_VPST 4, implicit $vpr
158 ; CHECK: renamable $r3, renamable $q1 = MVE_VLDRHS32_post killed renamable $r3, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv17.d, align 2)
159 ; CHECK: renamable $r2, renamable $q2 = MVE_VLDRHS32_post killed renamable $r2, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv1820.c, align 2)
160 ; CHECK: renamable $q1 = nsw MVE_VMULi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
161 ; CHECK: MVE_VPST 4, implicit $vpr
162 ; CHECK: renamable $r0, renamable $q2 = MVE_VLDRHS32_post killed renamable $r0, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv17, align 2)
163 ; CHECK: renamable $r1, renamable $q3 = MVE_VLDRHS32_post killed renamable $r1, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv1820, align 2)
164 ; CHECK: renamable $q2 = nsw MVE_VMULi32 killed renamable $q3, killed renamable $q2, 0, $noreg, undef renamable $q2
165 ; CHECK: $lr = tMOVr $r4, 14 /* CC::al */, $noreg
166 ; CHECK: renamable $q1 = MVE_VADDi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
167 ; CHECK: renamable $r4, dead $cpsr = nsw tSUBi8 killed $r4, 1, 14 /* CC::al */, $noreg
168 ; CHECK: renamable $q1 = MVE_VADDi32 killed renamable $q1, renamable $q0, 0, $noreg, undef renamable $q1
169 ; CHECK: renamable $r12 = t2SUBri killed renamable $r12, 4, 14 /* CC::al */, $noreg, $noreg
170 ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q1, killed renamable $q0, 0, killed renamable $vpr
171 ; CHECK: dead $lr = t2LEUpdate killed renamable $lr, %bb.2
172 ; CHECK: bb.3.middle.block:
173 ; CHECK: liveins: $q0
174 ; CHECK: renamable $r0 = MVE_VADDVu32no_acc killed renamable $q0, 0, $noreg
175 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r4, def $r5, def $r7, def $pc, implicit killed $r0
177 ; CHECK: renamable $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
178 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r4, def $r5, def $r7, def $pc, implicit killed $r0
180 successors: %bb.4(0x30000000), %bb.1(0x50000000)
181 liveins: $r0, $r1, $r2, $r3, $r4, $r5, $r7, $lr
183 frame-setup tPUSH 14, $noreg, killed $r4, killed $r5, killed $r7, killed $lr, implicit-def $sp, implicit $sp
184 frame-setup CFI_INSTRUCTION def_cfa_offset 16
185 frame-setup CFI_INSTRUCTION offset $lr, -4
186 frame-setup CFI_INSTRUCTION offset $r7, -8
187 frame-setup CFI_INSTRUCTION offset $r5, -12
188 frame-setup CFI_INSTRUCTION offset $r4, -16
189 renamable $r12 = t2LDRi12 $sp, 16, 14, $noreg :: (load (s32) from %fixed-stack.0, align 8)
190 t2CMPri renamable $r12, 0, 14, $noreg, implicit-def $cpsr
191 tBcc %bb.4, 0, killed $cpsr
194 successors: %bb.2(0x80000000)
195 liveins: $r0, $r1, $r2, $r3, $r12
197 renamable $lr = t2ADDri renamable $r12, 3, 14, $noreg, $noreg
198 renamable $r4, dead $cpsr = tMOVi8 1, 14, $noreg
199 renamable $lr = t2BICri killed renamable $lr, 3, 14, $noreg, $noreg
200 renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, undef renamable $q0
201 renamable $lr = t2SUBri killed renamable $lr, 4, 14, $noreg, $noreg
202 renamable $r5 = nuw nsw t2ADDrs killed renamable $r4, killed renamable $lr, 19, 14, $noreg, $noreg
203 $lr = t2DoLoopStart renamable $r5
204 $r4 = tMOVr killed $r5, 14, $noreg
207 successors: %bb.2(0x7c000000), %bb.3(0x04000000)
208 liveins: $q0, $r0, $r1, $r2, $r3, $r4, $r12
210 renamable $vpr = MVE_VCTP32 renamable $r12, 0, $noreg
211 MVE_VPST 4, implicit $vpr
212 renamable $r3, renamable $q1 = MVE_VLDRHS32_post killed renamable $r3, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv17.d, align 2)
213 renamable $r2, renamable $q2 = MVE_VLDRHS32_post killed renamable $r2, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv1820.c, align 2)
214 renamable $q1 = nsw MVE_VMULi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
215 MVE_VPST 4, implicit $vpr
216 renamable $r0, renamable $q2 = MVE_VLDRHS32_post killed renamable $r0, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv17, align 2)
217 renamable $r1, renamable $q3 = MVE_VLDRHS32_post killed renamable $r1, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv1820, align 2)
218 renamable $q2 = nsw MVE_VMULi32 killed renamable $q3, killed renamable $q2, 0, $noreg, undef renamable $q2
219 $lr = tMOVr $r4, 14, $noreg
220 renamable $q1 = MVE_VADDi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
221 renamable $r4, dead $cpsr = nsw tSUBi8 killed $r4, 1, 14, $noreg
222 renamable $q1 = MVE_VADDi32 killed renamable $q1, renamable $q0, 0, $noreg, undef renamable $q1
223 renamable $r12 = t2SUBri killed renamable $r12, 4, 14, $noreg, $noreg
224 renamable $q0 = MVE_VPSEL killed renamable $q1, killed renamable $q0, 0, killed renamable $vpr
225 renamable $lr = t2LoopDec killed renamable $lr, 1
226 t2LoopEnd killed renamable $lr, %bb.2, implicit-def dead $cpsr
232 renamable $r0 = MVE_VADDVu32no_acc killed renamable $q0, 0, $noreg
233 tPOP_RET 14, $noreg, def $r4, def $r5, def $r7, def $pc, implicit killed $r0
236 renamable $r0, dead $cpsr = tMOVi8 0, 14, $noreg
237 tPOP_RET 14, $noreg, def $r4, def $r5, def $r7, def $pc, implicit killed $r0