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: gpr64 }
10 - { id: 1, class: gpr64 }
11 - { id: 2, class: ppr }
12 - { id: 3, class: ppr }
13 - { id: 4, class: gpr32 }
14 - { id: 5, class: gpr32 }
16 - { reg: '$x0', virtual-reg: '%0' }
17 - { reg: '$x1', 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: whilerw_b8_s64
28 ; CHECK: %3:ppr = WHILERW_PXX_B %0, %1, implicit-def $nzcv
29 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
30 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
34 %3:ppr = WHILERW_PXX_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: ppr }
52 - { id: 5, class: ppr }
53 - { id: 6, class: gpr32 }
54 - { id: 7, class: gpr32 }
56 - { reg: '$x0', virtual-reg: '%0' }
57 - { reg: '$x1', virtual-reg: '%1' }
64 ; CHECK-LABEL: name: whilerw_b16_s64
69 %4:ppr = WHILERW_PXX_H %0, %1, implicit-def dead $nzcv
70 PTEST_PP %2, %4, implicit-def $nzcv
72 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
74 RET_ReallyLR implicit $w0
80 tracksRegLiveness: true
82 - { id: 0, class: gpr64 }
83 - { id: 1, class: gpr64 }
84 - { id: 2, class: ppr }
85 - { id: 3, class: ppr }
86 - { id: 4, class: ppr }
87 - { id: 5, class: ppr }
88 - { id: 6, class: gpr32 }
89 - { id: 7, class: gpr32 }
91 - { reg: '$x0', virtual-reg: '%0' }
92 - { reg: '$x1', virtual-reg: '%1' }
99 ; CHECK-LABEL: name: whilerw_b32_s64
104 %4:ppr = WHILERW_PXX_S %0, %1, implicit-def dead $nzcv
105 PTEST_PP %2, %4, implicit-def $nzcv
107 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
109 RET_ReallyLR implicit $w0
113 name: whilerw_b64_s64
115 tracksRegLiveness: true
117 - { id: 0, class: gpr64 }
118 - { id: 1, class: gpr64 }
119 - { id: 2, class: ppr }
120 - { id: 3, class: ppr }
121 - { id: 4, class: ppr }
122 - { id: 5, class: ppr }
123 - { id: 6, class: gpr32 }
124 - { id: 7, class: gpr32 }
126 - { reg: '$x0', virtual-reg: '%0' }
127 - { reg: '$x1', virtual-reg: '%1' }
134 ; CHECK-LABEL: name: whilerw_b64_s64
139 %4:ppr = WHILERW_PXX_D %0, %1, implicit-def dead $nzcv
140 PTEST_PP %2, %4, implicit-def $nzcv
142 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
144 RET_ReallyLR implicit $w0
148 name: whilerw_b8_s64_keep_ptest_not_all_active
150 tracksRegLiveness: true
152 - { id: 0, class: gpr64 }
153 - { id: 1, class: gpr64 }
154 - { id: 2, class: ppr }
155 - { id: 3, class: ppr }
156 - { id: 4, class: gpr32 }
157 - { id: 5, class: gpr32 }
159 - { reg: '$x0', virtual-reg: '%0' }
160 - { reg: '$x1', virtual-reg: '%1' }
167 ; PTEST is not redundant when it's Pg operand is not an all active predicate
168 ; of element size matching the WHILEGE, which is the implicitly predicate
169 ; used by WHILE when calculating the condition codes.
171 ; CHECK-LABEL: name: whilerw_b8_s64_keep_ptest_not_all_active
172 ; CHECK: %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
173 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
174 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
175 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
179 %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
180 PTEST_PP killed %2, killed %3, implicit-def $nzcv
182 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
184 RET_ReallyLR implicit $w0
188 name: whilerw_b8_s64_keep_ptest_of_halfs
190 tracksRegLiveness: true
192 - { id: 0, class: gpr64 }
193 - { id: 1, class: gpr64 }
194 - { id: 2, class: ppr }
195 - { id: 3, class: ppr }
196 - { id: 4, class: gpr32 }
197 - { id: 5, class: gpr32 }
199 - { reg: '$x0', virtual-reg: '%0' }
200 - { reg: '$x1', virtual-reg: '%1' }
207 ; PTEST is not redundant when it's Pg operand is not an all active predicate
208 ; of element size matching the WHILEGE, which is the implicitly predicate
209 ; used by WHILE when calculating the condition codes.
211 ; CHECK-LABEL: name: whilerw_b8_s64_keep_ptest_of_halfs
212 ; CHECK: %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
213 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
214 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
215 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
219 %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
220 PTEST_PP killed %2, killed %3, implicit-def $nzcv
222 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
224 RET_ReallyLR implicit $w0
228 name: whilerw_b8_s64_keep_ptest_of_words
230 tracksRegLiveness: true
232 - { id: 0, class: gpr64 }
233 - { id: 1, class: gpr64 }
234 - { id: 2, class: ppr }
235 - { id: 3, class: ppr }
236 - { id: 4, class: gpr32 }
237 - { id: 5, class: gpr32 }
239 - { reg: '$x0', virtual-reg: '%0' }
240 - { reg: '$x1', virtual-reg: '%1' }
247 ; PTEST is not redundant when it's Pg operand is not an all active predicate
248 ; of element size matching the WHILEGE, which is the implicitly predicate
249 ; used by WHILE when calculating the condition codes.
251 ; CHECK-LABEL: name: whilerw_b8_s64_keep_ptest_of_words
252 ; CHECK: %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
253 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
254 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
255 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
259 %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
260 PTEST_PP killed %2, killed %3, implicit-def $nzcv
262 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
264 RET_ReallyLR implicit $w0
268 name: whilerw_b8_s64_keep_ptest_of_doublewords
270 tracksRegLiveness: true
272 - { id: 0, class: gpr64 }
273 - { id: 1, class: gpr64 }
274 - { id: 2, class: ppr }
275 - { id: 3, class: ppr }
276 - { id: 4, class: gpr32 }
277 - { id: 5, class: gpr32 }
279 - { reg: '$x0', virtual-reg: '%0' }
280 - { reg: '$x1', virtual-reg: '%1' }
287 ; PTEST is not redundant when it's Pg operand is not an all active predicate
288 ; of element size matching the WHILEGE, which is the implicitly predicate
289 ; used by WHILE when calculating the condition codes.
291 ; CHECK-LABEL: name: whilerw_b8_s64_keep_ptest_of_doublewords
292 ; CHECK: %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
293 ; CHECK-NEXT: PTEST_PP killed %2, killed %3, implicit-def $nzcv
294 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
295 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
299 %3:ppr = WHILERW_PXX_B %0, %1, implicit-def dead $nzcv
300 PTEST_PP killed %2, killed %3, implicit-def $nzcv
302 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
304 RET_ReallyLR implicit $w0