1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve %s -run-pass=arm-low-overhead-loops -o - | FileCheck %s
5 define dso_local void @variant_max_use(i16* nocapture readonly %a, i16* %c, i32 %N) #0 {
7 %cmp9 = icmp eq i32 %N, 0
9 %tmp1 = lshr i32 %tmp, 2
10 %tmp2 = shl nuw i32 %tmp1, 2
11 %tmp3 = add i32 %tmp2, -4
12 %tmp4 = lshr i32 %tmp3, 2
13 %tmp5 = add nuw nsw i32 %tmp4, 1
14 br i1 %cmp9, label %exit, label %vector.ph
16 vector.ph: ; preds = %entry
17 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp5)
20 vector.body: ; preds = %vector.body, %vector.ph
21 %lsr.iv1 = phi i32 [ %lsr.iv.next, %vector.body ], [ %start, %vector.ph ]
22 %lsr.iv = phi i16* [ %scevgep, %vector.body ], [ %a, %vector.ph ]
23 %lsr.iv.2 = phi i16* [ %scevgep.2, %vector.body ], [ %c, %vector.ph ]
24 %tmp7 = phi i32 [ %N, %vector.ph ], [ %tmp9, %vector.body ]
25 %lsr.iv17 = bitcast i16* %lsr.iv to <8 x i16>*
26 %tmp8 = call <8 x i1> @llvm.arm.mve.vctp16(i32 %tmp7)
27 %tmp9 = sub i32 %tmp7, 8
28 %wide.masked.load = call <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>* %lsr.iv17, i32 2, <8 x i1> %tmp8, <8 x i16> undef)
29 %min = tail call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> %wide.masked.load)
30 store i16 %min, i16* %lsr.iv.2
31 %scevgep = getelementptr i16, i16* %lsr.iv, i32 8
32 %scevgep.2 = getelementptr i16, i16* %lsr.iv.2, i32 1
33 %tmp10 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %lsr.iv1, i32 1)
34 %tmp11 = icmp ne i32 %tmp10, 0
35 %lsr.iv.next = add nsw i32 %lsr.iv1, -1
36 br i1 %tmp11, label %vector.body, label %exit
38 exit: ; preds = %vector.body, %entry
42 declare <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>*, i32 immarg, <8 x i1>, <8 x i16>)
43 declare i32 @llvm.start.loop.iterations.i32(i32)
44 declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32)
45 declare <8 x i1> @llvm.arm.mve.vctp16(i32)
46 declare i16 @llvm.vector.reduce.smax.v8i16(<8 x i16>)
52 tracksRegLiveness: true
55 - { reg: '$r0', virtual-reg: '' }
56 - { reg: '$r1', virtual-reg: '' }
57 - { reg: '$r2', virtual-reg: '' }
64 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
65 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
66 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
67 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
68 stack-id: default, callee-saved-register: '$r5', callee-saved-restored: true,
69 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
72 machineFunctionInfo: {}
74 ; CHECK-LABEL: name: variant_max_use
76 ; CHECK: successors: %bb.1(0x80000000)
77 ; CHECK: liveins: $lr, $r0, $r1, $r2, $r5
78 ; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r5, killed $lr, implicit-def $sp, implicit $sp
79 ; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 8
80 ; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
81 ; CHECK: frame-setup CFI_INSTRUCTION offset $r5, -8
82 ; CHECK: tCMPi8 renamable $r2, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
83 ; CHECK: t2IT 0, 8, implicit-def $itstate
84 ; CHECK: tPOP_RET 0 /* CC::eq */, killed $cpsr, def $r5, def $pc, implicit killed $itstate
85 ; CHECK: bb.1.vector.ph:
86 ; CHECK: successors: %bb.2(0x80000000)
87 ; CHECK: liveins: $r0, $r1, $r2
88 ; CHECK: renamable $r3, dead $cpsr = tADDi3 renamable $r2, 3, 14 /* CC::al */, $noreg
89 ; CHECK: renamable $r3 = t2BICri killed renamable $r3, 3, 14 /* CC::al */, $noreg, $noreg
90 ; CHECK: renamable $r12 = t2SUBri killed renamable $r3, 4, 14 /* CC::al */, $noreg, $noreg
91 ; CHECK: renamable $r3, dead $cpsr = tMOVi8 1, 14 /* CC::al */, $noreg
92 ; CHECK: renamable $r3 = nuw nsw t2ADDrs killed renamable $r3, killed renamable $r12, 19, 14 /* CC::al */, $noreg, $noreg
93 ; CHECK: $r12 = t2MOVi16 32768, 14 /* CC::al */, $noreg
94 ; CHECK: $r12 = t2MOVTi16 killed $r12, 65535, 14 /* CC::al */, $noreg
95 ; CHECK: dead $lr = t2DLS renamable $r3
96 ; CHECK: $r5 = tMOVr killed $r3, 14 /* CC::al */, $noreg
97 ; CHECK: bb.2.vector.body:
98 ; CHECK: successors: %bb.2(0x7c000000), %bb.3(0x04000000)
99 ; CHECK: liveins: $r0, $r1, $r2, $r5, $r12
100 ; CHECK: $r3 = tMOVr $r12, 14 /* CC::al */, $noreg
101 ; CHECK: renamable $vpr = MVE_VCTP16 renamable $r2, 0, $noreg
102 ; CHECK: MVE_VPST 8, implicit $vpr
103 ; CHECK: renamable $r0, renamable $q0 = MVE_VLDRHU16_post killed renamable $r0, 16, 1, killed renamable $vpr :: (load (s128) from %ir.lsr.iv17, align 2)
104 ; CHECK: renamable $r3 = MVE_VMAXVs16 killed renamable $r3, killed renamable $q0, 0, $noreg
105 ; CHECK: $lr = tMOVr $r5, 14 /* CC::al */, $noreg
106 ; CHECK: early-clobber renamable $r1 = t2STRH_POST killed renamable $r3, killed renamable $r1, 2, 14 /* CC::al */, $noreg :: (store (s16) into %ir.lsr.iv.2)
107 ; CHECK: renamable $r5, dead $cpsr = nsw tSUBi8 killed $r5, 1, 14 /* CC::al */, $noreg
108 ; CHECK: renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 8, 14 /* CC::al */, $noreg
109 ; CHECK: dead $lr = t2LEUpdate killed renamable $lr, %bb.2
111 ; CHECK: tPOP_RET 14 /* CC::al */, $noreg, def $r5, def $pc
113 successors: %bb.1(0x80000000)
114 liveins: $r0, $r1, $r2, $r5, $lr
116 frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r5, killed $lr, implicit-def $sp, implicit $sp
117 frame-setup CFI_INSTRUCTION def_cfa_offset 8
118 frame-setup CFI_INSTRUCTION offset $lr, -4
119 frame-setup CFI_INSTRUCTION offset $r5, -8
120 tCMPi8 renamable $r2, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
121 t2IT 0, 8, implicit-def $itstate
122 tPOP_RET 0 /* CC::eq */, killed $cpsr, def $r5, def $pc, implicit killed $itstate
125 successors: %bb.2(0x80000000)
126 liveins: $r0, $r1, $r2, $r5, $lr
128 renamable $r3, dead $cpsr = tADDi3 renamable $r2, 3, 14 /* CC::al */, $noreg
129 renamable $r3 = t2BICri killed renamable $r3, 3, 14 /* CC::al */, $noreg, $noreg
130 renamable $r12 = t2SUBri killed renamable $r3, 4, 14 /* CC::al */, $noreg, $noreg
131 renamable $r3, dead $cpsr = tMOVi8 1, 14 /* CC::al */, $noreg
132 renamable $r3 = nuw nsw t2ADDrs killed renamable $r3, killed renamable $r12, 19, 14 /* CC::al */, $noreg, $noreg
133 $r12 = t2MOVi16 32768, 14 /* CC::al */, $noreg
134 $r12 = t2MOVTi16 killed $r12, 65535, 14 /* CC::al */, $noreg
135 $lr = t2DoLoopStart renamable $r3
136 $r5 = tMOVr killed $r3, 14 /* CC::al */, $noreg
139 successors: %bb.2(0x7c000000), %bb.3(0x04000000)
140 liveins: $r0, $r1, $r2, $r5, $r12
142 $r3 = tMOVr $r12, 14 /* CC::al */, $noreg
143 renamable $vpr = MVE_VCTP16 renamable $r2, 0, $noreg
144 MVE_VPST 8, implicit $vpr
145 renamable $r0, renamable $q0 = MVE_VLDRHU16_post killed renamable $r0, 16, 1, killed renamable $vpr :: (load (s128) from %ir.lsr.iv17, align 2)
146 renamable $r3 = MVE_VMAXVs16 killed renamable $r3, killed renamable $q0, 0, $noreg
147 $lr = tMOVr $r5, 14 /* CC::al */, $noreg
148 early-clobber renamable $r1 = t2STRH_POST killed renamable $r3, killed renamable $r1, 2, 14 /* CC::al */, $noreg :: (store (s16) into %ir.lsr.iv.2)
149 renamable $r5, dead $cpsr = nsw tSUBi8 killed $r5, 1, 14 /* CC::al */, $noreg
150 renamable $r2, dead $cpsr = tSUBi8 killed renamable $r2, 8, 14 /* CC::al */, $noreg
151 renamable $lr = t2LoopDec killed renamable $lr, 1
152 t2LoopEnd killed renamable $lr, %bb.2, implicit-def dead $cpsr
153 tB %bb.3, 14 /* CC::al */, $noreg
156 tPOP_RET 14 /* CC::al */, $noreg, def $r5, def $pc