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 # Test that the scalar register that aliases a Q reg prevents the tail
8 define dso_local i32 @no_vpsel_liveout(i16* nocapture readonly %a, i16* nocapture readonly %b, i32 %N) local_unnamed_addr #0 {
10 %cmp9 = icmp eq i32 %N, 0
12 %tmp1 = lshr i32 %tmp, 2
13 %tmp2 = shl nuw i32 %tmp1, 2
14 %tmp3 = add i32 %tmp2, -4
15 %tmp4 = lshr i32 %tmp3, 2
16 %tmp5 = add nuw nsw i32 %tmp4, 1
17 br i1 %cmp9, label %for.cond.cleanup, label %vector.ph
19 vector.ph: ; preds = %entry
20 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp5)
23 vector.body: ; preds = %vector.body, %vector.ph
24 %lsr.iv1 = phi i32 [ %lsr.iv.next, %vector.body ], [ %start, %vector.ph ]
25 %lsr.iv18 = phi i16* [ %scevgep19, %vector.body ], [ %b, %vector.ph ]
26 %lsr.iv = phi i16* [ %scevgep, %vector.body ], [ %a, %vector.ph ]
27 %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %tmp13, %vector.body ]
28 %tmp7 = phi i32 [ %N, %vector.ph ], [ %tmp9, %vector.body ]
29 %lsr.iv17 = bitcast i16* %lsr.iv to <4 x i16>*
30 %lsr.iv1820 = bitcast i16* %lsr.iv18 to <4 x i16>*
31 %tmp8 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %tmp7)
32 %tmp9 = sub i32 %tmp7, 4
33 %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)
34 %tmp10 = sext <4 x i16> %wide.masked.load to <4 x i32>
35 %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)
36 %tmp11 = sext <4 x i16> %wide.masked.load14 to <4 x i32>
37 %tmp12 = mul nsw <4 x i32> %tmp11, %tmp10
38 %tmp13 = add <4 x i32> %tmp12, %vec.phi
39 %scevgep = getelementptr i16, i16* %lsr.iv, i32 4
40 %scevgep19 = getelementptr i16, i16* %lsr.iv18, i32 4
41 %tmp14 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %lsr.iv1, i32 1)
42 %tmp15 = icmp ne i32 %tmp14, 0
43 %lsr.iv.next = add nsw i32 %lsr.iv1, -1
44 br i1 %tmp15, label %vector.body, label %middle.block
46 middle.block: ; preds = %vector.body
47 %tmp16 = extractelement <4 x i32> %tmp13, i32 3
48 br label %for.cond.cleanup
50 for.cond.cleanup: ; preds = %middle.block, %entry
51 %res.0.lcssa = phi i32 [ 0, %entry ], [ %tmp16, %middle.block ]
54 declare <4 x i16> @llvm.masked.load.v4i16.p0v4i16(<4 x i16>*, i32 immarg, <4 x i1>, <4 x i16>)
55 declare i32 @llvm.start.loop.iterations.i32(i32)
56 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32)
57 declare <4 x i1> @llvm.arm.mve.vctp32(i32)
61 name: no_vpsel_liveout
63 exposesReturnsTwice: false
65 regBankSelected: false
68 tracksRegLiveness: true
72 - { reg: '$r0', virtual-reg: '' }
73 - { reg: '$r1', virtual-reg: '' }
74 - { reg: '$r2', 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: '' }
104 machineFunctionInfo: {}
106 ; CHECK-LABEL: name: no_vpsel_liveout
108 ; CHECK: successors: %bb.1(0x80000000)
109 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r7
110 ; CHECK: tCMPi8 renamable $r2, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
111 ; CHECK: t2IT 0, 4, implicit-def $itstate
112 ; CHECK: renamable $r0 = tMOVi8 $noreg, 0, 0 /* CC::eq */, $cpsr, implicit killed $r0, implicit $itstate
113 ; CHECK: tBX_RET 0 /* CC::eq */, killed $cpsr, implicit $r0, implicit killed $itstate
114 ; CHECK: bb.1.vector.ph:
115 ; CHECK: successors: %bb.2(0x80000000)
116 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r7
117 ; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
118 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 8
119 ; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
120 ; CHECK: frame-setup CFI_INSTRUCTION offset $r7, -8
121 ; CHECK: renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, undef renamable $q0
122 ; CHECK: $lr = MVE_DLSTP_32 killed renamable $r2
123 ; CHECK: bb.2.vector.body:
124 ; CHECK: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
125 ; CHECK: liveins: $lr, $q0, $r0, $r1
126 ; CHECK: renamable $r0, renamable $q1 = MVE_VLDRHS32_post killed renamable $r0, 8, 0, $noreg :: (load (s64) from %ir.lsr.iv17, align 2)
127 ; CHECK: renamable $r1, renamable $q2 = MVE_VLDRHS32_post killed renamable $r1, 8, 0, killed $noreg :: (load (s64) from %ir.lsr.iv1820, align 2)
128 ; CHECK: renamable $q1 = nsw MVE_VMULi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
129 ; CHECK: renamable $q0 = MVE_VADDi32 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
130 ; CHECK: $lr = MVE_LETP killed renamable $lr, %bb.2
131 ; CHECK: bb.3.middle.block:
132 ; CHECK: liveins: $q0
133 ; CHECK: $r0 = VMOVRS killed $s3, 14 /* CC::al */, $noreg, implicit killed $q0
134 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r7, def $pc, implicit killed $r0
136 successors: %bb.1(0x80000000)
137 liveins: $r0, $r1, $r2, $lr, $r7
139 tCMPi8 renamable $r2, 0, 14, $noreg, implicit-def $cpsr
140 t2IT 0, 4, implicit-def $itstate
141 renamable $r0 = tMOVi8 $noreg, 0, 0, $cpsr, implicit killed $r0, implicit $itstate
142 tBX_RET 0, killed $cpsr, implicit $r0, implicit killed $itstate
145 successors: %bb.2(0x80000000)
146 liveins: $r0, $r1, $r2, $lr, $r7
148 frame-setup tPUSH 14, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
149 frame-setup CFI_INSTRUCTION def_cfa_offset 8
150 frame-setup CFI_INSTRUCTION offset $lr, -4
151 frame-setup CFI_INSTRUCTION offset $r7, -8
152 renamable $r3, dead $cpsr = tADDi3 renamable $r2, 3, 14, $noreg
153 renamable $q0 = MVE_VMOVimmi32 0, 0, $noreg, undef renamable $q0
154 renamable $r3 = t2BICri killed renamable $r3, 3, 14, $noreg, $noreg
155 renamable $r12 = t2SUBri killed renamable $r3, 4, 14, $noreg, $noreg
156 renamable $r3, dead $cpsr = tMOVi8 1, 14, $noreg
157 renamable $r12 = nuw nsw t2ADDrs killed renamable $r3, killed renamable $r12, 19, 14, $noreg, $noreg
158 $lr = t2DoLoopStart renamable $r12
159 $r3 = tMOVr killed $r12, 14, $noreg
162 successors: %bb.2(0x7c000000), %bb.3(0x04000000)
163 liveins: $q0, $r0, $r1, $r2, $r3
165 renamable $vpr = MVE_VCTP32 renamable $r2, 0, $noreg
166 MVE_VPST 4, implicit $vpr
167 renamable $r0, renamable $q1 = MVE_VLDRHS32_post killed renamable $r0, 8, 1, renamable $vpr :: (load (s64) from %ir.lsr.iv17, align 2)
168 renamable $r1, renamable $q2 = MVE_VLDRHS32_post killed renamable $r1, 8, 1, killed renamable $vpr :: (load (s64) from %ir.lsr.iv1820, align 2)
169 $lr = tMOVr $r3, 14, $noreg
170 renamable $q1 = nsw MVE_VMULi32 killed renamable $q2, killed renamable $q1, 0, $noreg, undef renamable $q1
171 renamable $r3, dead $cpsr = nsw tSUBi8 killed $r3, 1, 14, $noreg
172 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 4, 14, $noreg
173 renamable $q0 = MVE_VADDi32 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
174 renamable $lr = t2LoopDec killed renamable $lr, 1
175 t2LoopEnd killed renamable $lr, %bb.2, implicit-def dead $cpsr
181 $r0 = VMOVRS killed $s3, 14, $noreg, implicit $q0
182 tPOP_RET 14, $noreg, def $r7, def $pc, implicit killed $r0