1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
5 tracksRegLiveness: true
11 ; CHECK-LABEL: name: right_ident_sub
13 ; CHECK: %x:_(s32) = COPY $w0
14 ; CHECK: $w0 = COPY %x(s32)
15 ; CHECK: RET_ReallyLR implicit $w0
17 %cst:_(s32) = G_CONSTANT i32 0
18 %op:_(s32) = G_SUB %x(s32), %cst
20 RET_ReallyLR implicit $w0
25 tracksRegLiveness: true
31 ; CHECK-LABEL: name: right_ident_add
34 ; CHECK-NEXT: %x:_(s32) = COPY $w0
35 ; CHECK-NEXT: $w0 = COPY %x(s32)
36 ; CHECK-NEXT: RET_ReallyLR implicit $w0
38 %cst:_(s32) = G_CONSTANT i32 0
39 %op:_(s32) = G_ADD %x(s32), %cst
41 RET_ReallyLR implicit $w0
46 tracksRegLiveness: true
52 ; CHECK-LABEL: name: mul_0
55 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
56 ; CHECK-NEXT: $w0 = COPY %cst(s32)
57 ; CHECK-NEXT: RET_ReallyLR implicit $w0
59 %cst:_(s32) = G_CONSTANT i32 0
60 %op:_(s32) = G_MUL %x(s32), %cst
62 RET_ReallyLR implicit $w0
67 name: mul_0_cant_replace
68 tracksRegLiveness: true
74 ; CHECK-LABEL: name: mul_0_cant_replace
77 ; CHECK-NEXT: %x:_(s32) = COPY $w0
78 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
79 ; CHECK-NEXT: %op:gpr(s32) = G_MUL %x, %cst
80 ; CHECK-NEXT: $w0 = COPY %op(s32)
81 ; CHECK-NEXT: RET_ReallyLR implicit $w0
83 %cst:_(s32) = G_CONSTANT i32 0
84 %op:gpr(s32) = G_MUL %x(s32), %cst
86 RET_ReallyLR implicit $w0
92 tracksRegLiveness: true
98 ; CHECK-LABEL: name: sdiv_0
101 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
102 ; CHECK-NEXT: $w0 = COPY %cst(s32)
103 ; CHECK-NEXT: RET_ReallyLR implicit $w0
105 %cst:_(s32) = G_CONSTANT i32 0
106 %op:_(s32) = G_SDIV %cst, %x
108 RET_ReallyLR implicit $w0
113 tracksRegLiveness: true
119 ; CHECK-LABEL: name: udiv_0
120 ; CHECK: liveins: $w0
122 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
123 ; CHECK-NEXT: $w0 = COPY %cst(s32)
124 ; CHECK-NEXT: RET_ReallyLR implicit $w0
126 %cst:_(s32) = G_CONSTANT i32 0
127 %op:_(s32) = G_UDIV %cst, %x
129 RET_ReallyLR implicit $w0
134 tracksRegLiveness: true
140 ; CHECK-LABEL: name: srem_0
141 ; CHECK: liveins: $w0
143 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
144 ; CHECK-NEXT: $w0 = COPY %cst(s32)
145 ; CHECK-NEXT: RET_ReallyLR implicit $w0
147 %cst:_(s32) = G_CONSTANT i32 0
148 %op:_(s32) = G_SREM %cst, %x
150 RET_ReallyLR implicit $w0
155 tracksRegLiveness: true
161 ; CHECK-LABEL: name: urem_0
162 ; CHECK: liveins: $w0
164 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0
165 ; CHECK-NEXT: $w0 = COPY %cst(s32)
166 ; CHECK-NEXT: RET_ReallyLR implicit $w0
168 %cst:_(s32) = G_CONSTANT i32 0
169 %op:_(s32) = G_UREM %cst, %x
171 RET_ReallyLR implicit $w0
177 tracksRegLiveness: true
183 ; CHECK-LABEL: name: right_ident_or
184 ; CHECK: liveins: $w0
186 ; CHECK-NEXT: %x:_(s32) = COPY $w0
187 ; CHECK-NEXT: $w0 = COPY %x(s32)
188 ; CHECK-NEXT: RET_ReallyLR implicit $w0
190 %cst:_(s32) = G_CONSTANT i32 0
191 %op:_(s32) = G_OR %x(s32), %cst
193 RET_ReallyLR implicit $w0
197 name: right_ident_xor
198 tracksRegLiveness: true
204 ; CHECK-LABEL: name: right_ident_xor
205 ; CHECK: liveins: $w0
207 ; CHECK-NEXT: %x:_(s32) = COPY $w0
208 ; CHECK-NEXT: $w0 = COPY %x(s32)
209 ; CHECK-NEXT: RET_ReallyLR implicit $w0
211 %cst:_(s32) = G_CONSTANT i32 0
212 %op:_(s32) = G_XOR %x(s32), %cst
214 RET_ReallyLR implicit $w0
218 name: right_ident_shl
219 tracksRegLiveness: true
225 ; CHECK-LABEL: name: right_ident_shl
226 ; CHECK: liveins: $w0
228 ; CHECK-NEXT: %x:_(s32) = COPY $w0
229 ; CHECK-NEXT: $w0 = COPY %x(s32)
230 ; CHECK-NEXT: RET_ReallyLR implicit $w0
232 %cst:_(s32) = G_CONSTANT i32 0
233 %op:_(s32) = G_SHL %x(s32), %cst
235 RET_ReallyLR implicit $w0
239 name: right_ident_ashr
240 tracksRegLiveness: true
244 ; Fold (x ashr 0) -> x
246 ; CHECK-LABEL: name: right_ident_ashr
247 ; CHECK: liveins: $w0
249 ; CHECK-NEXT: %x:_(s32) = COPY $w0
250 ; CHECK-NEXT: $w0 = COPY %x(s32)
251 ; CHECK-NEXT: RET_ReallyLR implicit $w0
253 %cst:_(s32) = G_CONSTANT i32 0
254 %op:_(s32) = G_ASHR %x(s32), %cst
256 RET_ReallyLR implicit $w0
260 name: right_ident_lshr
261 tracksRegLiveness: true
265 ; Fold (x lshr 0) -> x
267 ; CHECK-LABEL: name: right_ident_lshr
268 ; CHECK: liveins: $w0
270 ; CHECK-NEXT: %x:_(s32) = COPY $w0
271 ; CHECK-NEXT: $w0 = COPY %x(s32)
272 ; CHECK-NEXT: RET_ReallyLR implicit $w0
274 %cst:_(s32) = G_CONSTANT i32 0
275 %op:_(s32) = G_LSHR %x(s32), %cst
277 RET_ReallyLR implicit $w0
282 tracksRegLiveness: true
286 ; Not an identity, no folding.
288 ; CHECK-LABEL: name: dont_fold_sub
289 ; CHECK: liveins: $w0
291 ; CHECK-NEXT: %x:_(s32) = COPY $w0
292 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
293 ; CHECK-NEXT: %op:_(s32) = G_SUB %x, %cst
294 ; CHECK-NEXT: $w0 = COPY %op(s32)
295 ; CHECK-NEXT: RET_ReallyLR implicit $w0
297 %cst:_(s32) = G_CONSTANT i32 1
298 %op:_(s32) = G_SUB %x(s32), %cst
300 RET_ReallyLR implicit $w0
304 name: look_through_zext
305 tracksRegLiveness: true
309 ; CHECK-LABEL: name: look_through_zext
310 ; CHECK: liveins: $x0
312 ; CHECK-NEXT: %zext_zero:_(s64) = G_CONSTANT i64 0
313 ; CHECK-NEXT: $x0 = COPY %zext_zero(s64)
314 ; CHECK-NEXT: RET_ReallyLR implicit $x0
315 %zero:_(s8) = G_CONSTANT i8 0
316 %zext_zero:_(s64) = G_ZEXT %zero(s8)
317 %c:_(s64) = G_CONSTANT i64 72340172838076673
318 %mul:_(s64) = G_MUL %c, %zext_zero
320 RET_ReallyLR implicit $x0
323 name: right_ident_ptr_add
324 tracksRegLiveness: true
330 ; CHECK-LABEL: name: right_ident_ptr_add
331 ; CHECK: liveins: $x0
333 ; CHECK-NEXT: %x:_(p0) = COPY $x0
334 ; CHECK-NEXT: $x0 = COPY %x(p0)
335 ; CHECK-NEXT: RET_ReallyLR implicit $x0
337 %cst:_(s64) = G_CONSTANT i64 0
338 %op:_(p0) = G_PTR_ADD %x(p0), %cst
340 RET_ReallyLR implicit $x0
343 name: right_identity_rotl
344 tracksRegLiveness: true
348 ; CHECK-LABEL: name: right_identity_rotl
349 ; CHECK: liveins: $w0, $w1
351 ; CHECK-NEXT: %copy:_(s32) = COPY $w0
352 ; CHECK-NEXT: $w0 = COPY %copy(s32)
353 ; CHECK-NEXT: RET_ReallyLR implicit $w0
354 %copy:_(s32) = COPY $w0
355 %zero:_(s32) = G_CONSTANT i32 0
356 %rot:_(s32) = G_ROTL %copy(s32), %zero(s32)
358 RET_ReallyLR implicit $w0
362 name: right_identity_rotr
363 tracksRegLiveness: true
367 ; CHECK-LABEL: name: right_identity_rotr
368 ; CHECK: liveins: $w0, $w1
370 ; CHECK-NEXT: %copy:_(s32) = COPY $w0
371 ; CHECK-NEXT: $w0 = COPY %copy(s32)
372 ; CHECK-NEXT: RET_ReallyLR implicit $w0
373 %copy:_(s32) = COPY $w0
374 %zero:_(s32) = G_CONSTANT i32 0
375 %rot:_(s32) = G_ROTR %copy(s32), %zero(s32)
377 RET_ReallyLR implicit $w0
380 name: lshr_of_vec_zero
384 ; CHECK-LABEL: name: lshr_of_vec_zero
385 ; CHECK: liveins: $q0
387 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q0
388 ; CHECK-NEXT: $q0 = COPY [[COPY]](<8 x s16>)
389 ; CHECK-NEXT: RET_ReallyLR implicit $q0
390 %0:_(<8 x s16>) = COPY $q0
391 %5:_(s16) = G_CONSTANT i16 0
392 %zero_vec:_(<8 x s16>) = G_BUILD_VECTOR %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16)
393 %shift:_(<8 x s16>) = G_LSHR %0, %zero_vec(<8 x s16>)
394 $q0 = COPY %shift(<8 x s16>)
395 RET_ReallyLR implicit $q0
398 name: ptradd_of_vec_zero
402 ; CHECK-LABEL: name: ptradd_of_vec_zero
403 ; CHECK: liveins: $q0
405 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x p0>) = COPY $q0
406 ; CHECK-NEXT: $q0 = COPY [[COPY]](<2 x p0>)
407 ; CHECK-NEXT: RET_ReallyLR implicit $q0
408 %0:_(<2 x p0>) = COPY $q0
409 %5:_(s64) = G_CONSTANT i64 0
410 %zero_vec:_(<2 x s64>) = G_BUILD_VECTOR %5(s64), %5(s64)
411 %ptr:_(<2 x p0>) = G_PTR_ADD %0, %zero_vec(<2 x s64>)
412 $q0 = COPY %ptr(<2 x p0>)
413 RET_ReallyLR implicit $q0
423 ; CHECK-LABEL: name: i128_or_cst
424 ; CHECK: liveins: $x0
426 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
427 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s128) = G_LOAD [[COPY]](p0) :: (load (s128))
428 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s128) = G_CONSTANT i128 9223372036854775808
429 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s128) = G_OR [[LOAD]], [[C]]
430 ; CHECK-NEXT: G_STORE [[OR]](s128), [[COPY]](p0) :: (store (s128), align 4)
431 ; CHECK-NEXT: RET_ReallyLR
433 %2:_(s128) = G_LOAD %0(p0) :: (load (s128))
434 %4:_(s128) = G_CONSTANT i128 9223372036854775808
435 %5:_(s128) = G_OR %2, %4
436 G_STORE %5(s128), %0(p0) :: (store (s128), align 4)
441 name: mul_1_shift_of_shift
448 ; CHECK-LABEL: name: mul_1_shift_of_shift
449 ; CHECK: liveins: $x0
451 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
452 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
453 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64)
454 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SHL]], [[C]]
455 ; CHECK-NEXT: $x0 = COPY [[OR]](s64)
456 ; CHECK-NEXT: RET_ReallyLR implicit $x0
458 %1:_(s64) = G_CONSTANT i64 1
459 %2:_(s64) = G_SHL %0, %1(s64)
460 %3:_(s64) = G_OR %2, %1
461 %4:_(s64) = G_MUL %3, %1
463 RET_ReallyLR implicit $x0