1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-- -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
7 tracksRegLiveness: true
12 ; CHECK-LABEL: name: cmp_imm_32
14 ; CHECK: [[COPY:%[0-9]+]]:gpr32sp = COPY $w0
15 ; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 42, 0, implicit-def $nzcv
16 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
17 ; CHECK: $w0 = COPY [[CSINCWr]]
18 ; CHECK: RET_ReallyLR implicit $w0
19 %0:gpr(s32) = COPY $w0
20 %1:gpr(s32) = G_CONSTANT i32 42
21 %5:gpr(s32) = G_ICMP intpred(eq), %0(s32), %1
23 RET_ReallyLR implicit $w0
30 tracksRegLiveness: true
35 ; CHECK-LABEL: name: cmp_imm_64
37 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
38 ; CHECK: [[SUBSXri:%[0-9]+]]:gpr64 = SUBSXri [[COPY]], 42, 0, implicit-def $nzcv
39 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
40 ; CHECK: $w0 = COPY [[CSINCWr]]
41 ; CHECK: RET_ReallyLR implicit $w0
42 %0:gpr(s64) = COPY $x0
43 %1:gpr(s64) = G_CONSTANT i64 42
44 %5:gpr(s32) = G_ICMP intpred(eq), %0(s64), %1
46 RET_ReallyLR implicit $w0
50 name: cmp_imm_out_of_range
53 tracksRegLiveness: true
58 ; CHECK-LABEL: name: cmp_imm_out_of_range
60 ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
61 ; CHECK: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 13132
62 ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32
63 ; CHECK: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr [[COPY]], [[SUBREG_TO_REG]], implicit-def $nzcv
64 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
65 ; CHECK: $w0 = COPY [[CSINCWr]]
66 ; CHECK: RET_ReallyLR implicit $w0
67 %0:gpr(s64) = COPY $x0
68 %1:gpr(s64) = G_CONSTANT i64 13132
69 %5:gpr(s32) = G_ICMP intpred(eq), %0(s64), %1
71 RET_ReallyLR implicit $w0
75 name: cmp_imm_lookthrough
78 tracksRegLiveness: true
82 ; CHECK-LABEL: name: cmp_imm_lookthrough
84 ; CHECK: [[COPY:%[0-9]+]]:gpr32sp = COPY $w0
85 ; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 42, 0, implicit-def $nzcv
86 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
87 ; CHECK: $w0 = COPY [[CSINCWr]]
88 ; CHECK: RET_ReallyLR implicit $w0
89 %0:gpr(s32) = COPY $w0
90 %1:gpr(s64) = G_CONSTANT i64 42
91 %2:gpr(s32) = G_TRUNC %1(s64)
92 %5:gpr(s32) = G_ICMP intpred(eq), %0(s32), %2
94 RET_ReallyLR implicit $w0
98 name: cmp_imm_lookthrough_bad_trunc
100 regBankSelected: true
101 tracksRegLiveness: true
105 ; CHECK-LABEL: name: cmp_imm_lookthrough_bad_trunc
106 ; CHECK: liveins: $w0
107 ; CHECK: [[COPY:%[0-9]+]]:gpr32sp = COPY $w0
108 ; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 0, 0, implicit-def $nzcv
109 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
110 ; CHECK: $w0 = COPY [[CSINCWr]]
111 ; CHECK: RET_ReallyLR implicit $w0
112 %0:gpr(s32) = COPY $w0
113 %1:gpr(s64) = G_CONSTANT i64 68719476736 ; 0x1000000000
114 %2:gpr(s32) = G_TRUNC %1(s64) ; Value truncates to 0
115 %5:gpr(s32) = G_ICMP intpred(eq), %0(s32), %2
117 RET_ReallyLR implicit $w0
123 regBankSelected: true
124 tracksRegLiveness: true
128 ; CHECK-LABEL: name: cmp_neg_imm_32
129 ; CHECK: liveins: $w0
130 ; CHECK: %reg0:gpr32sp = COPY $w0
131 ; CHECK: [[ADDSWri:%[0-9]+]]:gpr32 = ADDSWri %reg0, 10, 0, implicit-def $nzcv
132 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
133 ; CHECK: $w0 = COPY %cmp
134 ; CHECK: RET_ReallyLR implicit $w0
135 %reg0:gpr(s32) = COPY $w0
136 %cst:gpr(s32) = G_CONSTANT i32 -10
137 %cmp:gpr(s32) = G_ICMP intpred(eq), %reg0(s32), %cst
139 RET_ReallyLR implicit $w0
145 regBankSelected: true
146 tracksRegLiveness: true
150 ; CHECK-LABEL: name: cmp_neg_imm_64
151 ; CHECK: liveins: $x0
152 ; CHECK: %reg0:gpr64sp = COPY $x0
153 ; CHECK: [[ADDSXri:%[0-9]+]]:gpr64 = ADDSXri %reg0, 10, 0, implicit-def $nzcv
154 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
155 ; CHECK: $w0 = COPY %cmp
156 ; CHECK: RET_ReallyLR implicit $w0
157 %reg0:gpr(s64) = COPY $x0
158 %cst:gpr(s64) = G_CONSTANT i64 -10
159 %cmp:gpr(s32) = G_ICMP intpred(eq), %reg0(s64), %cst
161 RET_ReallyLR implicit $w0
165 name: cmp_neg_imm_invalid
167 regBankSelected: true
168 tracksRegLiveness: true
172 ; CHECK-LABEL: name: cmp_neg_imm_invalid
173 ; CHECK: liveins: $w0
174 ; CHECK: %reg0:gpr32 = COPY $w0
175 ; CHECK: %cst:gpr32 = MOVi32imm -5000
176 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %cst, implicit-def $nzcv
177 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
178 ; CHECK: $w0 = COPY %cmp
179 ; CHECK: RET_ReallyLR implicit $w0
180 %reg0:gpr(s32) = COPY $w0
181 %cst:gpr(s32) = G_CONSTANT i32 -5000
182 %cmp:gpr(s32) = G_ICMP intpred(eq), %reg0(s32), %cst
184 RET_ReallyLR implicit $w0
187 name: cmp_arith_extended_s64
189 regBankSelected: true
190 tracksRegLiveness: true
195 ; CHECK-LABEL: name: cmp_arith_extended_s64
196 ; CHECK: liveins: $w0, $x1
197 ; CHECK: %reg0:gpr32 = COPY $w0
198 ; CHECK: %reg1:gpr64sp = COPY $x1
199 ; CHECK: [[SUBSXrx:%[0-9]+]]:gpr64 = SUBSXrx %reg1, %reg0, 18, implicit-def $nzcv
200 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 9, implicit $nzcv
201 ; CHECK: $w0 = COPY %cmp
202 ; CHECK: RET_ReallyLR implicit $w0
203 %reg0:gpr(s32) = COPY $w0
204 %reg1:gpr(s64) = COPY $x1
205 %ext:gpr(s64) = G_ZEXT %reg0(s32)
206 %cst:gpr(s64) = G_CONSTANT i64 2
207 %shift:gpr(s64) = G_SHL %ext, %cst(s64)
208 %cmp:gpr(s32) = G_ICMP intpred(ugt), %reg1(s64), %shift
210 RET_ReallyLR implicit $w0
214 name: cmp_arith_extended_s32
216 regBankSelected: true
217 tracksRegLiveness: true
220 liveins: $w0, $w1, $h0
222 ; CHECK-LABEL: name: cmp_arith_extended_s32
223 ; CHECK: liveins: $w0, $w1, $h0
224 ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:fpr32 = SUBREG_TO_REG 0, $h0, %subreg.hsub
225 ; CHECK: %reg0:gpr32all = COPY [[SUBREG_TO_REG]]
226 ; CHECK: %reg1:gpr32sp = COPY $w1
227 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY %reg0
228 ; CHECK: [[SUBSWrx:%[0-9]+]]:gpr32 = SUBSWrx %reg1, [[COPY]], 10, implicit-def $nzcv
229 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 9, implicit $nzcv
230 ; CHECK: $w0 = COPY %cmp
231 ; CHECK: RET_ReallyLR implicit $w0
232 %reg0:gpr(s16) = COPY $h0
233 %reg1:gpr(s32) = COPY $w1
234 %ext:gpr(s32) = G_ZEXT %reg0(s16)
235 %cst:gpr(s32) = G_CONSTANT i32 2
236 %shift:gpr(s32) = G_SHL %ext, %cst(s32)
237 %cmp:gpr(s32) = G_ICMP intpred(ugt), %reg1(s32), %shift
239 RET_ReallyLR implicit $w0
243 name: cmp_arith_extended_shl_too_large
245 regBankSelected: true
246 tracksRegLiveness: true
251 ; The constant on the G_SHL is > 4, so we won't sleect SUBSXrx
253 ; CHECK-LABEL: name: cmp_arith_extended_shl_too_large
254 ; CHECK: liveins: $w0, $x1
255 ; CHECK: %reg0:gpr32 = COPY $w0
256 ; CHECK: %reg1:gpr64 = COPY $x1
257 ; CHECK: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, %reg0, 0
258 ; CHECK: %ext:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
259 ; CHECK: [[SUBSXrs:%[0-9]+]]:gpr64 = SUBSXrs %reg1, %ext, 5, implicit-def $nzcv
260 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 9, implicit $nzcv
261 ; CHECK: $w0 = COPY %cmp
262 ; CHECK: RET_ReallyLR implicit $w0
263 %reg0:gpr(s32) = COPY $w0
264 %reg1:gpr(s64) = COPY $x1
265 %ext:gpr(s64) = G_ZEXT %reg0(s32)
266 %cst:gpr(s64) = G_CONSTANT i64 5
267 %shift:gpr(s64) = G_SHL %ext, %cst(s64)
268 %cmp:gpr(s32) = G_ICMP intpred(ugt), %reg1(s64), %shift
270 RET_ReallyLR implicit $w0
276 regBankSelected: true
277 tracksRegLiveness: true
278 machineFunctionInfo: {}
281 liveins: $w0, $w1, $w2
283 ; The CSINC should use the add's RHS.
285 ; CHECK-LABEL: name: cmp_add_rhs
286 ; CHECK: liveins: $w0, $w1, $w2
287 ; CHECK: %cmp_lhs:gpr32 = COPY $w0
288 ; CHECK: %cmp_rhs:gpr32 = COPY $w1
289 ; CHECK: %add_rhs:gpr32 = COPY $w2
290 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %cmp_lhs, %cmp_rhs, implicit-def $nzcv
291 ; CHECK: %add:gpr32 = CSINCWr %add_rhs, %add_rhs, 1, implicit $nzcv
292 ; CHECK: $w0 = COPY %add
293 ; CHECK: RET_ReallyLR implicit $w0
294 %cmp_lhs:gpr(s32) = COPY $w0
295 %cmp_rhs:gpr(s32) = COPY $w1
296 %add_rhs:gpr(s32) = COPY $w2
297 %cmp:gpr(s32) = G_ICMP intpred(eq), %cmp_lhs(s32), %cmp_rhs
298 %add:gpr(s32) = G_ADD %cmp, %add_rhs
300 RET_ReallyLR implicit $w0
306 regBankSelected: true
307 tracksRegLiveness: true
308 machineFunctionInfo: {}
311 liveins: $w0, $w1, $w2
313 ; The CSINC should use the add's LHS.
315 ; CHECK-LABEL: name: cmp_add_lhs
316 ; CHECK: liveins: $w0, $w1, $w2
317 ; CHECK: %cmp_lhs:gpr32 = COPY $w0
318 ; CHECK: %cmp_rhs:gpr32 = COPY $w1
319 ; CHECK: %add_lhs:gpr32 = COPY $w2
320 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %cmp_lhs, %cmp_rhs, implicit-def $nzcv
321 ; CHECK: %add:gpr32 = CSINCWr %add_lhs, %add_lhs, 1, implicit $nzcv
322 ; CHECK: $w0 = COPY %add
323 ; CHECK: RET_ReallyLR implicit $w0
324 %cmp_lhs:gpr(s32) = COPY $w0
325 %cmp_rhs:gpr(s32) = COPY $w1
326 %add_lhs:gpr(s32) = COPY $w2
327 %cmp:gpr(s32) = G_ICMP intpred(eq), %cmp_lhs(s32), %cmp_rhs
328 %add:gpr(s32) = G_ADD %add_lhs, %cmp
330 RET_ReallyLR implicit $w0
334 name: cmp_add_lhs_vector
336 regBankSelected: true
337 tracksRegLiveness: true
338 machineFunctionInfo: {}
341 liveins: $q0, $q1, $q2
343 ; We don't emit CSINC with vectors, so there should be no optimization here.
345 ; CHECK-LABEL: name: cmp_add_lhs_vector
346 ; CHECK: liveins: $q0, $q1, $q2
347 ; CHECK: %cmp_lhs:fpr128 = COPY $q0
348 ; CHECK: %cmp_rhs:fpr128 = COPY $q1
349 ; CHECK: %add_lhs:fpr128 = COPY $q2
350 ; CHECK: [[CMEQv4i32_:%[0-9]+]]:fpr128 = CMEQv4i32 %cmp_lhs, %cmp_rhs
351 ; CHECK: %add:fpr128 = ADDv4i32 %add_lhs, [[CMEQv4i32_]]
352 ; CHECK: $q0 = COPY %add
353 ; CHECK: RET_ReallyLR implicit $q0
354 %cmp_lhs:fpr(<4 x s32>) = COPY $q0
355 %cmp_rhs:fpr(<4 x s32>) = COPY $q1
356 %add_lhs:fpr(<4 x s32>) = COPY $q2
357 %cmp:fpr(<4 x s32>) = G_ICMP intpred(eq), %cmp_lhs(<4 x s32>), %cmp_rhs
358 %add:fpr(<4 x s32>) = G_ADD %add_lhs, %cmp
359 $q0 = COPY %add(<4 x s32>)
360 RET_ReallyLR implicit $q0