1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s -check-prefix=NO_SCALAR_INC
3 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -mattr=+use-scalar-inc-vl < %s | FileCheck %s
4 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
8 define i32 @incb(i32 %a) {
9 ; NO_SCALAR_INC-LABEL: incb:
10 ; NO_SCALAR_INC: // %bb.0:
11 ; NO_SCALAR_INC-NEXT: cntb x8, vl5
12 ; NO_SCALAR_INC-NEXT: add w0, w8, w0
13 ; NO_SCALAR_INC-NEXT: ret
17 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
18 ; CHECK-NEXT: incb x0, vl5
19 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
21 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 5)
22 %conv = trunc i64 %cnt to i32
23 %out = add i32 %conv, %a
27 define i32 @incb_mul(i32 %a) {
28 ; NO_SCALAR_INC-LABEL: incb_mul:
29 ; NO_SCALAR_INC: // %bb.0:
30 ; NO_SCALAR_INC-NEXT: cntb x8, vl8
31 ; NO_SCALAR_INC-NEXT: add w0, w0, w8, lsl #2
32 ; NO_SCALAR_INC-NEXT: ret
34 ; CHECK-LABEL: incb_mul:
36 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
37 ; CHECK-NEXT: incb x0, vl8, mul #4
38 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
40 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 8)
41 %conv = trunc i64 %cnt to i32
42 %mul = mul i32 %conv, 4
43 %out = add i32 %mul, %a
51 define i32 @decb(i32 %a) {
52 ; NO_SCALAR_INC-LABEL: decb:
53 ; NO_SCALAR_INC: // %bb.0:
54 ; NO_SCALAR_INC-NEXT: cntb x8, vl6
55 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8
56 ; NO_SCALAR_INC-NEXT: ret
60 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
61 ; CHECK-NEXT: decb x0, vl6
62 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
64 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 6)
65 %conv = trunc i64 %cnt to i32
66 %out = sub i32 %a, %conv
70 define i32 @decb_mul(i32 %a) {
71 ; NO_SCALAR_INC-LABEL: decb_mul:
72 ; NO_SCALAR_INC: // %bb.0:
73 ; NO_SCALAR_INC-NEXT: cntb x8, vl6
74 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8, lsl #3
75 ; NO_SCALAR_INC-NEXT: ret
77 ; CHECK-LABEL: decb_mul:
79 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
80 ; CHECK-NEXT: decb x0, vl6, mul #8
81 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
83 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 6)
84 %conv = trunc i64 %cnt to i32
85 %mul = mul i32 %conv, 8
86 %out = sub i32 %a, %mul
92 define i32 @inch(i32 %a) {
93 ; NO_SCALAR_INC-LABEL: inch:
94 ; NO_SCALAR_INC: // %bb.0:
95 ; NO_SCALAR_INC-NEXT: cnth x8, #16
96 ; NO_SCALAR_INC-NEXT: add w0, w8, w0
97 ; NO_SCALAR_INC-NEXT: ret
101 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
102 ; CHECK-NEXT: inch x0, #16
103 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
105 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 16)
106 %conv = trunc i64 %cnt to i32
107 %out = add i32 %conv, %a
111 define i32 @inch_mul(i32 %a) {
112 ; NO_SCALAR_INC-LABEL: inch_mul:
113 ; NO_SCALAR_INC: // %bb.0:
114 ; NO_SCALAR_INC-NEXT: cnth x8, vl8
115 ; NO_SCALAR_INC-NEXT: mov w9, #5 // =0x5
116 ; NO_SCALAR_INC-NEXT: madd w0, w8, w9, w0
117 ; NO_SCALAR_INC-NEXT: ret
119 ; CHECK-LABEL: inch_mul:
121 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
122 ; CHECK-NEXT: inch x0, vl8, mul #5
123 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
125 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 8)
126 %conv = trunc i64 %cnt to i32
127 %mul = mul i32 %conv, 5
128 %out = add i32 %mul, %a
136 define i32 @dech(i32 %a) {
137 ; NO_SCALAR_INC-LABEL: dech:
138 ; NO_SCALAR_INC: // %bb.0:
139 ; NO_SCALAR_INC-NEXT: cnth x8, vl1
140 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8
141 ; NO_SCALAR_INC-NEXT: ret
145 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
146 ; CHECK-NEXT: dech x0, vl1
147 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
149 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 1)
150 %conv = trunc i64 %cnt to i32
151 %out = sub i32 %a, %conv
155 define i32 @dech_mul(i32 %a) {
156 ; NO_SCALAR_INC-LABEL: dech_mul:
157 ; NO_SCALAR_INC: // %bb.0:
158 ; NO_SCALAR_INC-NEXT: cnth x8, vl16
159 ; NO_SCALAR_INC-NEXT: mov w9, #7 // =0x7
160 ; NO_SCALAR_INC-NEXT: msub w0, w8, w9, w0
161 ; NO_SCALAR_INC-NEXT: ret
163 ; CHECK-LABEL: dech_mul:
165 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
166 ; CHECK-NEXT: dech x0, vl16, mul #7
167 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
169 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 9)
170 %conv = trunc i64 %cnt to i32
171 %mul = mul i32 %conv, 7
172 %out = sub i32 %a, %mul
180 define i32 @incw(i32 %a) {
181 ; NO_SCALAR_INC-LABEL: incw:
182 ; NO_SCALAR_INC: // %bb.0:
183 ; NO_SCALAR_INC-NEXT: cntw x8, #16
184 ; NO_SCALAR_INC-NEXT: add w0, w8, w0
185 ; NO_SCALAR_INC-NEXT: ret
189 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
190 ; CHECK-NEXT: incw x0, #16
191 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
193 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 16)
194 %conv = trunc i64 %cnt to i32
195 %out = add i32 %conv, %a
199 define i32 @incw_mul(i32 %a) {
200 ; NO_SCALAR_INC-LABEL: incw_mul:
201 ; NO_SCALAR_INC: // %bb.0:
202 ; NO_SCALAR_INC-NEXT: cntw x8, vl32
203 ; NO_SCALAR_INC-NEXT: mov w9, #12 // =0xc
204 ; NO_SCALAR_INC-NEXT: madd w0, w8, w9, w0
205 ; NO_SCALAR_INC-NEXT: ret
207 ; CHECK-LABEL: incw_mul:
209 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
210 ; CHECK-NEXT: incw x0, vl32, mul #12
211 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
213 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 10)
214 %conv = trunc i64 %cnt to i32
215 %mul = mul i32 %conv, 12
216 %out = add i32 %mul, %a
224 define i32 @decw(i32 %a) {
225 ; NO_SCALAR_INC-LABEL: decw:
226 ; NO_SCALAR_INC: // %bb.0:
227 ; NO_SCALAR_INC-NEXT: cntw x8, vl64
228 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8
229 ; NO_SCALAR_INC-NEXT: ret
233 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
234 ; CHECK-NEXT: decw x0, vl64
235 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
237 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 11)
238 %conv = trunc i64 %cnt to i32
239 %out = sub i32 %a, %conv
243 define i32 @decw_mul(i32 %a) {
244 ; NO_SCALAR_INC-LABEL: decw_mul:
245 ; NO_SCALAR_INC: // %bb.0:
246 ; NO_SCALAR_INC-NEXT: cntw x8, vl128
247 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8, lsl #4
248 ; NO_SCALAR_INC-NEXT: ret
250 ; CHECK-LABEL: decw_mul:
252 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
253 ; CHECK-NEXT: decw x0, vl128, mul #16
254 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
256 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 12)
257 %conv = trunc i64 %cnt to i32
258 %mul = mul i32 %conv, 16
259 %out = sub i32 %a, %mul
265 define i32 @incd(i32 %base) {
266 ; NO_SCALAR_INC-LABEL: incd:
267 ; NO_SCALAR_INC: // %bb.0:
268 ; NO_SCALAR_INC-NEXT: cntd x8, vl64
269 ; NO_SCALAR_INC-NEXT: add w0, w0, w8
270 ; NO_SCALAR_INC-NEXT: ret
274 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
275 ; CHECK-NEXT: incd x0, vl64
276 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
278 %cnt = tail call i64 @llvm.aarch64.sve.cntd(i32 11)
279 %conv = trunc i64 %cnt to i32
280 %add = add i32 %base, %conv
284 define i32 @incd_mul(i32 %base) {
285 ; NO_SCALAR_INC-LABEL: incd_mul:
286 ; NO_SCALAR_INC: // %bb.0:
287 ; NO_SCALAR_INC-NEXT: cntd x8, vl64
288 ; NO_SCALAR_INC-NEXT: mov w9, #15 // =0xf
289 ; NO_SCALAR_INC-NEXT: madd w0, w8, w9, w0
290 ; NO_SCALAR_INC-NEXT: ret
292 ; CHECK-LABEL: incd_mul:
294 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
295 ; CHECK-NEXT: incd x0, vl64, mul #15
296 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
298 %cnt = tail call i64 @llvm.aarch64.sve.cntd(i32 11)
299 %conv = trunc i64 %cnt to i32
300 %mul = mul i32 %conv, 15
301 %add = add i32 %base, %mul
309 define i32 @decd(i32 %a) {
310 ; NO_SCALAR_INC-LABEL: decd:
311 ; NO_SCALAR_INC: // %bb.0:
312 ; NO_SCALAR_INC-NEXT: cntd x8, #16
313 ; NO_SCALAR_INC-NEXT: sub w0, w0, w8
314 ; NO_SCALAR_INC-NEXT: ret
318 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
319 ; CHECK-NEXT: decd x0, #16
320 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
322 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 16)
323 %conv = trunc i64 %cnt to i32
324 %out = sub i32 %a, %conv
328 define i32 @decd_mul(i32 %a) {
329 ; NO_SCALAR_INC-LABEL: decd_mul:
330 ; NO_SCALAR_INC: // %bb.0:
331 ; NO_SCALAR_INC-NEXT: cntd x8, vl2
332 ; NO_SCALAR_INC-NEXT: mov w9, #9 // =0x9
333 ; NO_SCALAR_INC-NEXT: msub w0, w8, w9, w0
334 ; NO_SCALAR_INC-NEXT: ret
336 ; CHECK-LABEL: decd_mul:
338 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
339 ; CHECK-NEXT: decd x0, vl2, mul #9
340 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
342 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 2)
343 %conv = trunc i64 %cnt to i32
344 %mul = mul i32 %conv, 9
345 %out = sub i32 %a, %mul
349 declare i64 @llvm.aarch64.sve.cntb(i32 %pattern)
350 declare i64 @llvm.aarch64.sve.cnth(i32 %pattern)
351 declare i64 @llvm.aarch64.sve.cntw(i32 %pattern)
352 declare i64 @llvm.aarch64.sve.cntd(i32 %pattern)