1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 target triple = "aarch64-unknown-linux-gnu"
8 define i32 @cntp_add_all_active_nxv16i1(i32 %x, <vscale x 16 x i1> %pg) #0 {
9 ; CHECK-LABEL: cntp_add_all_active_nxv16i1:
11 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
12 ; CHECK-NEXT: incp x0, p0.b
13 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
15 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
16 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %1, <vscale x 16 x i1> %pg)
17 %3 = trunc i64 %2 to i32
22 define i32 @cntp_add_all_active_nxv8i1(i32 %x, <vscale x 8 x i1> %pg) #0 {
23 ; CHECK-LABEL: cntp_add_all_active_nxv8i1:
25 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
26 ; CHECK-NEXT: incp x0, p0.h
27 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
29 %1 = tail call <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
30 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %1, <vscale x 8 x i1> %pg)
31 %3 = trunc i64 %2 to i32
36 define i32 @cntp_add_all_active_nxv4i1(i32 %x, <vscale x 4 x i1> %pg) #0 {
37 ; CHECK-LABEL: cntp_add_all_active_nxv4i1:
39 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
40 ; CHECK-NEXT: incp x0, p0.s
41 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
43 %1 = tail call <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
44 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %1, <vscale x 4 x i1> %pg)
45 %3 = trunc i64 %2 to i32
50 define i32 @cntp_add_all_active_nxv2i1(i32 %x, <vscale x 2 x i1> %pg) #0 {
51 ; CHECK-LABEL: cntp_add_all_active_nxv2i1:
53 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
54 ; CHECK-NEXT: incp x0, p0.d
55 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
57 %1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
58 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %1, <vscale x 2 x i1> %pg)
59 %3 = trunc i64 %2 to i32
64 define i32 @cntp_add_all_active_nxv8i1_via_cast(i32 %x, <vscale x 8 x i1> %pg) #0 {
65 ; CHECK-LABEL: cntp_add_all_active_nxv8i1_via_cast:
67 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
68 ; CHECK-NEXT: incp x0, p0.h
69 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
71 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
72 %2 = tail call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %1)
73 %3 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %2, <vscale x 8 x i1> %pg)
74 %4 = trunc i64 %3 to i32
79 define i64 @cntp_add_all_active_nxv2i1_multiuse(i32 %x, i64 %y, <vscale x 2 x i1> %pg) #0 {
80 ; CHECK-LABEL: cntp_add_all_active_nxv2i1_multiuse:
82 ; CHECK-NEXT: ptrue p1.d
83 ; CHECK-NEXT: cntp x8, p1, p0.d
84 ; CHECK-NEXT: add w9, w8, w0
85 ; CHECK-NEXT: madd x0, x8, x1, x9
87 %1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
88 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %1, <vscale x 2 x i1> %pg)
89 %3 = trunc i64 %2 to i32
91 %add.ext = zext i32 %add to i64
93 %res = add i64 %add.ext, %mul
97 define i32 @cntp_add_same_active_nxv16i1(i32 %x, <vscale x 16 x i1> %pg) #0 {
98 ; CHECK-LABEL: cntp_add_same_active_nxv16i1:
100 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
101 ; CHECK-NEXT: incp x0, p0.b
102 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
104 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %pg)
105 %2 = trunc i64 %1 to i32
106 %add = add i32 %2, %x
110 define i32 @cntp_add_same_active_nxv8i1(i32 %x, <vscale x 8 x i1> %pg) #0 {
111 ; CHECK-LABEL: cntp_add_same_active_nxv8i1:
113 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
114 ; CHECK-NEXT: incp x0, p0.h
115 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
117 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %pg, <vscale x 8 x i1> %pg)
118 %2 = trunc i64 %1 to i32
119 %add = add i32 %2, %x
123 define i32 @cntp_add_same_active_nxv4i1(i32 %x, <vscale x 4 x i1> %pg) #0 {
124 ; CHECK-LABEL: cntp_add_same_active_nxv4i1:
126 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
127 ; CHECK-NEXT: incp x0, p0.s
128 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
130 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %pg, <vscale x 4 x i1> %pg)
131 %2 = trunc i64 %1 to i32
132 %add = add i32 %2, %x
136 define i32 @cntp_add_same_active_nxv2i1(i32 %x, <vscale x 2 x i1> %pg) #0 {
137 ; CHECK-LABEL: cntp_add_same_active_nxv2i1:
139 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
140 ; CHECK-NEXT: incp x0, p0.d
141 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
143 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %pg, <vscale x 2 x i1> %pg)
144 %2 = trunc i64 %1 to i32
145 %add = add i32 %2, %x
149 define i64 @cntp_add_same_active_nxv2i1_multiuse(i32 %x, i64 %y, <vscale x 2 x i1> %pg) #0 {
150 ; CHECK-LABEL: cntp_add_same_active_nxv2i1_multiuse:
152 ; CHECK-NEXT: cntp x8, p0, p0.d
153 ; CHECK-NEXT: add w9, w8, w0
154 ; CHECK-NEXT: madd x0, x8, x1, x9
156 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %pg, <vscale x 2 x i1> %pg)
157 %2 = trunc i64 %1 to i32
158 %add = add i32 %2, %x
159 %add.ext = zext i32 %add to i64
160 %mul = mul i64 %1, %y
161 %res = add i64 %add.ext, %mul
167 define i32 @cntp_sub_all_active_nxv16i1(i32 %x, <vscale x 16 x i1> %pg) #0 {
168 ; CHECK-LABEL: cntp_sub_all_active_nxv16i1:
170 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
171 ; CHECK-NEXT: decp x0, p0.b
172 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
174 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
175 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %1, <vscale x 16 x i1> %pg)
176 %3 = trunc i64 %2 to i32
177 %sub = sub i32 %x, %3
181 define i32 @cntp_sub_all_active_nxv8i1(i32 %x, <vscale x 8 x i1> %pg) #0 {
182 ; CHECK-LABEL: cntp_sub_all_active_nxv8i1:
184 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
185 ; CHECK-NEXT: decp x0, p0.h
186 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
188 %1 = tail call <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
189 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %1, <vscale x 8 x i1> %pg)
190 %3 = trunc i64 %2 to i32
191 %sub = sub i32 %x, %3
195 define i32 @cntp_sub_all_active_nxv4i1(i32 %x, <vscale x 4 x i1> %pg) #0 {
196 ; CHECK-LABEL: cntp_sub_all_active_nxv4i1:
198 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
199 ; CHECK-NEXT: decp x0, p0.s
200 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
202 %1 = tail call <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
203 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %1, <vscale x 4 x i1> %pg)
204 %3 = trunc i64 %2 to i32
205 %sub = sub i32 %x, %3
209 define i32 @cntp_sub_all_active_nxv2i1(i32 %x, <vscale x 2 x i1> %pg) #0 {
210 ; CHECK-LABEL: cntp_sub_all_active_nxv2i1:
212 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
213 ; CHECK-NEXT: decp x0, p0.d
214 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
216 %1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
217 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %1, <vscale x 2 x i1> %pg)
218 %3 = trunc i64 %2 to i32
219 %sub = sub i32 %x, %3
223 define i32 @cntp_sub_all_active_nxv8i1_via_cast(i32 %x, <vscale x 8 x i1> %pg) #0 {
224 ; CHECK-LABEL: cntp_sub_all_active_nxv8i1_via_cast:
226 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
227 ; CHECK-NEXT: decp x0, p0.h
228 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
230 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
231 %2 = tail call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %1)
232 %3 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %2, <vscale x 8 x i1> %pg)
233 %4 = trunc i64 %3 to i32
234 %sub = sub i32 %x, %4
238 define i64 @cntp_sub_all_active_nxv2i1_multiuse(i32 %x, i64 %y, <vscale x 2 x i1> %pg) #0 {
239 ; CHECK-LABEL: cntp_sub_all_active_nxv2i1_multiuse:
241 ; CHECK-NEXT: ptrue p1.d
242 ; CHECK-NEXT: cntp x8, p1, p0.d
243 ; CHECK-NEXT: sub w9, w8, w0
244 ; CHECK-NEXT: madd x0, x8, x1, x9
246 %1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
247 %2 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %1, <vscale x 2 x i1> %pg)
248 %3 = trunc i64 %2 to i32
249 %sub = sub i32 %3, %x
250 %sub.ext = zext i32 %sub to i64
251 %mul = mul i64 %2, %y
252 %res = add i64 %sub.ext, %mul
256 define i32 @cntp_sub_same_active_nxv16i1(i32 %x, <vscale x 16 x i1> %pg) #0 {
257 ; CHECK-LABEL: cntp_sub_same_active_nxv16i1:
259 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
260 ; CHECK-NEXT: decp x0, p0.b
261 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
263 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %pg)
264 %2 = trunc i64 %1 to i32
265 %sub = sub i32 %x, %2
269 define i32 @cntp_sub_same_active_nxv8i1(i32 %x, <vscale x 8 x i1> %pg) #0 {
270 ; CHECK-LABEL: cntp_sub_same_active_nxv8i1:
272 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
273 ; CHECK-NEXT: decp x0, p0.h
274 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
276 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %pg, <vscale x 8 x i1> %pg)
277 %2 = trunc i64 %1 to i32
278 %sub = sub i32 %x, %2
282 define i32 @cntp_sub_same_active_nxv4i1(i32 %x, <vscale x 4 x i1> %pg) #0 {
283 ; CHECK-LABEL: cntp_sub_same_active_nxv4i1:
285 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
286 ; CHECK-NEXT: decp x0, p0.s
287 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
289 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %pg, <vscale x 4 x i1> %pg)
290 %2 = trunc i64 %1 to i32
291 %sub = sub i32 %x, %2
295 define i32 @cntp_sub_same_active_nxv2i1(i32 %x, <vscale x 2 x i1> %pg) #0 {
296 ; CHECK-LABEL: cntp_sub_same_active_nxv2i1:
298 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
299 ; CHECK-NEXT: decp x0, p0.d
300 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
302 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %pg, <vscale x 2 x i1> %pg)
303 %2 = trunc i64 %1 to i32
304 %sub = sub i32 %x, %2
308 define i64 @cntp_sub_same_active_nxv2i1_multiuse(i32 %x, i64 %y, <vscale x 2 x i1> %pg) #0 {
309 ; CHECK-LABEL: cntp_sub_same_active_nxv2i1_multiuse:
311 ; CHECK-NEXT: cntp x8, p0, p0.d
312 ; CHECK-NEXT: sub w9, w8, w0
313 ; CHECK-NEXT: madd x0, x8, x1, x9
315 %1 = tail call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %pg, <vscale x 2 x i1> %pg)
316 %2 = trunc i64 %1 to i32
317 %sub = sub i32 %2, %x
318 %sub.ext = zext i32 %sub to i64
319 %mul = mul i64 %1, %y
320 %res = add i64 %sub.ext, %mul
324 declare <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1>)
325 declare <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1>)
326 declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
328 declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32)
329 declare <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32)
330 declare <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32)
331 declare <vscale x 2 x i1> @llvm.aarch64.sve.ptrue.nxv2i1(i32)
333 declare i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
334 declare i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1>, <vscale x 8 x i1>)
335 declare i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1>, <vscale x 4 x i1>)
336 declare i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1>, <vscale x 2 x i1>)
338 attributes #0 = { "target-features"="+sve" }