1 # RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2 -run-pass=peephole-opt -verify-machineinstrs %s -o - | FileCheck %s
3 # Test instruction sequences where PTEST is redundant and thus gets removed.
7 tracksRegLiveness: true
9 - { id: 0, class: gpr32 }
10 - { id: 1, class: gpr32 }
11 - { id: 2, class: ppr }
12 - { id: 3, class: ppr }
13 - { id: 4, class: gpr32 }
14 - { id: 5, class: gpr32 }
16 - { reg: '$w0', virtual-reg: '%0' }
17 - { reg: '$w1', virtual-reg: '%1' }
24 ; Here we check the expected sequence with subsequent tests
25 ; just asserting there is no PTEST instruction.
27 ; CHECK-LABEL: name: whilehs_b8_s32
28 ; CHECK: %3:ppr = WHILEHS_PWW_B %0, %1, implicit-def $nzcv
29 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
30 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
33 %2:ppr = PTRUE_B 31, implicit $vg
34 %3:ppr = WHILEHS_PWW_B %0, %1, implicit-def dead $nzcv
35 PTEST_PP killed %2, killed %3, implicit-def $nzcv
37 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
39 RET_ReallyLR implicit $w0
45 tracksRegLiveness: true
47 - { id: 0, class: gpr64 }
48 - { id: 1, class: gpr64 }
49 - { id: 2, class: ppr }
50 - { id: 3, class: ppr }
51 - { id: 4, class: gpr32 }
52 - { id: 5, class: gpr32 }
54 - { reg: '$x0', virtual-reg: '%0' }
55 - { reg: '$x1', virtual-reg: '%1' }
62 ; CHECK-LABEL: name: whilehs_b8_s64
66 %2:ppr = PTRUE_B 31, implicit $vg
67 %3:ppr = WHILEHS_PXX_B %0, %1, implicit-def dead $nzcv
68 PTEST_PP killed %2, killed %3, implicit-def $nzcv
70 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
72 RET_ReallyLR implicit $w0
78 tracksRegLiveness: true
80 - { id: 0, class: gpr32 }
81 - { id: 1, class: gpr32 }
82 - { id: 2, class: ppr }
83 - { id: 3, class: ppr }
84 - { id: 4, class: ppr }
85 - { id: 5, class: ppr }
86 - { id: 6, class: gpr32 }
87 - { id: 7, class: gpr32 }
89 - { reg: '$w0', virtual-reg: '%0' }
90 - { reg: '$w1', virtual-reg: '%1' }
97 ; CHECK-LABEL: name: whilehs_b16_s32
101 %2:ppr = PTRUE_H 31, implicit $vg
102 %4:ppr = WHILEHS_PWW_H %0, %1, implicit-def dead $nzcv
103 PTEST_PP %2, %4, implicit-def $nzcv
105 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
107 RET_ReallyLR implicit $w0
111 name: whilehs_b16_s64
113 tracksRegLiveness: true
115 - { id: 0, class: gpr64 }
116 - { id: 1, class: gpr64 }
117 - { id: 2, class: ppr }
118 - { id: 3, class: ppr }
119 - { id: 4, class: ppr }
120 - { id: 5, class: ppr }
121 - { id: 6, class: gpr32 }
122 - { id: 7, class: gpr32 }
124 - { reg: '$x0', virtual-reg: '%0' }
125 - { reg: '$x1', virtual-reg: '%1' }
132 ; CHECK-LABEL: name: whilehs_b16_s64
136 %2:ppr = PTRUE_H 31, implicit $vg
137 %4:ppr = WHILEHS_PXX_H %0, %1, implicit-def dead $nzcv
138 PTEST_PP %2, %4, implicit-def $nzcv
140 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
142 RET_ReallyLR implicit $w0
146 name: whilehs_b32_s32
148 tracksRegLiveness: true
150 - { id: 0, class: gpr32 }
151 - { id: 1, class: gpr32 }
152 - { id: 2, class: ppr }
153 - { id: 3, class: ppr }
154 - { id: 4, class: ppr }
155 - { id: 5, class: ppr }
156 - { id: 6, class: gpr32 }
157 - { id: 7, class: gpr32 }
159 - { reg: '$w0', virtual-reg: '%0' }
160 - { reg: '$w1', virtual-reg: '%1' }
167 ; CHECK-LABEL: name: whilehs_b32_s32
171 %2:ppr = PTRUE_S 31, implicit $vg
172 %4:ppr = WHILEHS_PWW_S %0, %1, implicit-def dead $nzcv
173 PTEST_PP %2, %4, implicit-def $nzcv
175 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
177 RET_ReallyLR implicit $w0
181 name: whilehs_b32_s64
183 tracksRegLiveness: true
185 - { id: 0, class: gpr64 }
186 - { id: 1, class: gpr64 }
187 - { id: 2, class: ppr }
188 - { id: 3, class: ppr }
189 - { id: 4, class: ppr }
190 - { id: 5, class: ppr }
191 - { id: 6, class: gpr32 }
192 - { id: 7, class: gpr32 }
194 - { reg: '$x0', virtual-reg: '%0' }
195 - { reg: '$x1', virtual-reg: '%1' }
202 ; CHECK-LABEL: name: whilehs_b32_s64
206 %2:ppr = PTRUE_S 31, implicit $vg
207 %4:ppr = WHILEHS_PXX_S %0, %1, implicit-def dead $nzcv
208 PTEST_PP %2, %4, implicit-def $nzcv
210 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
212 RET_ReallyLR implicit $w0
216 name: whilehs_b64_s32
218 tracksRegLiveness: true
220 - { id: 0, class: gpr32 }
221 - { id: 1, class: gpr32 }
222 - { id: 2, class: ppr }
223 - { id: 3, class: ppr }
224 - { id: 4, class: ppr }
225 - { id: 5, class: ppr }
226 - { id: 6, class: gpr32 }
227 - { id: 7, class: gpr32 }
229 - { reg: '$w0', virtual-reg: '%0' }
230 - { reg: '$w1', virtual-reg: '%1' }
237 ; CHECK-LABEL: name: whilehs_b64_s32
241 %2:ppr = PTRUE_D 31, implicit $vg
242 %4:ppr = WHILEHS_PWW_D %0, %1, implicit-def dead $nzcv
243 PTEST_PP %2, %4, implicit-def $nzcv
245 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
247 RET_ReallyLR implicit $w0
251 name: whilehs_b64_s64
253 tracksRegLiveness: true
255 - { id: 0, class: gpr64 }
256 - { id: 1, class: gpr64 }
257 - { id: 2, class: ppr }
258 - { id: 3, class: ppr }
259 - { id: 4, class: ppr }
260 - { id: 5, class: ppr }
261 - { id: 6, class: gpr32 }
262 - { id: 7, class: gpr32 }
264 - { reg: '$x0', virtual-reg: '%0' }
265 - { reg: '$x1', virtual-reg: '%1' }
272 ; CHECK-LABEL: name: whilehs_b64_s64
276 %2:ppr = PTRUE_D 31, implicit $vg
277 %4:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
278 PTEST_PP %2, %4, implicit-def $nzcv
280 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
282 RET_ReallyLR implicit $w0
286 name: whilehs_b64_s64_keep_ptest_not_all_active
288 tracksRegLiveness: true
290 - { id: 0, class: gpr64 }
291 - { id: 1, class: gpr64 }
292 - { id: 2, class: ppr }
293 - { id: 3, class: ppr }
294 - { id: 4, class: gpr32 }
295 - { id: 5, class: gpr32 }
297 - { reg: '$x0', virtual-reg: '%0' }
298 - { reg: '$x1', virtual-reg: '%1' }
305 ; PTEST is not redundant when it's Pg operand is not an all active predicate
306 ; of element size matching the WHILEHS, which is the implicitly predicate
307 ; used by WHILE when calculating the condition codes.
309 ; CHECK-LABEL: name: whilehs_b64_s64_keep_ptest_not_all_active
310 ; CHECK: %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
311 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
312 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
313 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
316 %2:ppr = PTRUE_D 30, implicit $vg
317 %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
318 PTEST_PP killed %2, killed %3, implicit-def $nzcv
320 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
322 RET_ReallyLR implicit $w0
326 name: whilehs_b64_s64_keep_ptest_of_bytes
328 tracksRegLiveness: true
330 - { id: 0, class: gpr64 }
331 - { id: 1, class: gpr64 }
332 - { id: 2, class: ppr }
333 - { id: 3, class: ppr }
334 - { id: 4, class: gpr32 }
335 - { id: 5, class: gpr32 }
337 - { reg: '$x0', virtual-reg: '%0' }
338 - { reg: '$x1', virtual-reg: '%1' }
345 ; PTEST is not redundant when it's Pg operand is not an all active predicate
346 ; of element size matching the WHILEHS, which is the implicitly predicate
347 ; used by WHILE when calculating the condition codes.
349 ; CHECK-LABEL: name: whilehs_b64_s64_keep_ptest_of_bytes
350 ; CHECK: %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
351 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
352 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
353 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
356 %2:ppr = PTRUE_B 31, implicit $vg
357 %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
358 PTEST_PP killed %2, killed %3, implicit-def $nzcv
360 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
362 RET_ReallyLR implicit $w0
366 name: whilehs_b64_s64_keep_ptest_of_halfs
368 tracksRegLiveness: true
370 - { id: 0, class: gpr64 }
371 - { id: 1, class: gpr64 }
372 - { id: 2, class: ppr }
373 - { id: 3, class: ppr }
374 - { id: 4, class: gpr32 }
375 - { id: 5, class: gpr32 }
377 - { reg: '$x0', virtual-reg: '%0' }
378 - { reg: '$x1', virtual-reg: '%1' }
385 ; PTEST is not redundant when it's Pg operand is not an all active predicate
386 ; of element size matching the WHILEHS, which is the implicitly predicate
387 ; used by WHILE when calculating the condition codes.
389 ; CHECK-LABEL: name: whilehs_b64_s64_keep_ptest_of_halfs
390 ; CHECK: %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
391 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
392 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
393 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
396 %2:ppr = PTRUE_H 31, implicit $vg
397 %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
398 PTEST_PP killed %2, killed %3, implicit-def $nzcv
400 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
402 RET_ReallyLR implicit $w0
406 name: whilehs_b64_s64_keep_ptest_of_words
408 tracksRegLiveness: true
410 - { id: 0, class: gpr64 }
411 - { id: 1, class: gpr64 }
412 - { id: 2, class: ppr }
413 - { id: 3, class: ppr }
414 - { id: 4, class: gpr32 }
415 - { id: 5, class: gpr32 }
417 - { reg: '$x0', virtual-reg: '%0' }
418 - { reg: '$x1', virtual-reg: '%1' }
425 ; PTEST is not redundant when it's Pg operand is not an all active predicate
426 ; of element size matching the WHILEHS, which is the implicitly predicate
427 ; used by WHILE when calculating the condition codes.
429 ; CHECK-LABEL: name: whilehs_b64_s64_keep_ptest_of_words
430 ; CHECK: %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
431 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
432 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
433 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
436 %2:ppr = PTRUE_S 31, implicit $vg
437 %3:ppr = WHILEHS_PXX_D %0, %1, implicit-def dead $nzcv
438 PTEST_PP killed %2, killed %3, implicit-def $nzcv
440 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
442 RET_ReallyLR implicit $w0