585 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s3 4name: right_ident_sub5tracksRegLiveness: true6body: |7 bb.1.entry:8 liveins: $w09 ; Fold (x - 0) -> x10 ;11 ; CHECK-LABEL: name: right_ident_sub12 ; CHECK: liveins: $w013 ; CHECK: %x:_(s32) = COPY $w014 ; CHECK: $w0 = COPY %x(s32)15 ; CHECK: RET_ReallyLR implicit $w016 %x:_(s32) = COPY $w017 %cst:_(s32) = G_CONSTANT i32 018 %op:_(s32) = G_SUB %x(s32), %cst19 $w0 = COPY %op(s32)20 RET_ReallyLR implicit $w021 22...23---24name: right_ident_add25tracksRegLiveness: true26body: |27 bb.1.entry:28 liveins: $w029 ; Fold (x + 0) -> x30 ; CHECK-LABEL: name: right_ident_add31 ; CHECK: liveins: $w032 ; CHECK-NEXT: {{ $}}33 ; CHECK-NEXT: %x:_(s32) = COPY $w034 ; CHECK-NEXT: $w0 = COPY %x(s32)35 ; CHECK-NEXT: RET_ReallyLR implicit $w036 %x:_(s32) = COPY $w037 %cst:_(s32) = G_CONSTANT i32 038 %op:_(s32) = G_ADD %x(s32), %cst39 $w0 = COPY %op(s32)40 RET_ReallyLR implicit $w041 42...43---44name: mul_045tracksRegLiveness: true46body: |47 bb.1.entry:48 liveins: $w049 ; Fold (x * 0) -> 050 ; CHECK-LABEL: name: mul_051 ; CHECK: liveins: $w052 ; CHECK-NEXT: {{ $}}53 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 054 ; CHECK-NEXT: $w0 = COPY %cst(s32)55 ; CHECK-NEXT: RET_ReallyLR implicit $w056 %x:_(s32) = COPY $w057 %cst:_(s32) = G_CONSTANT i32 058 %op:_(s32) = G_MUL %x(s32), %cst59 $w0 = COPY %op(s32)60 RET_ReallyLR implicit $w061 62...63 64---65name: mul_0_cant_replace66tracksRegLiveness: true67body: |68 bb.1.entry:69 liveins: $w070 ; Fold (x * 0) -> 071 ; CHECK-LABEL: name: mul_0_cant_replace72 ; CHECK: liveins: $w073 ; CHECK-NEXT: {{ $}}74 ; CHECK-NEXT: %x:_(s32) = COPY $w075 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 076 ; CHECK-NEXT: %op:gpr(s32) = G_MUL %x, %cst77 ; CHECK-NEXT: $w0 = COPY %op(s32)78 ; CHECK-NEXT: RET_ReallyLR implicit $w079 %x:_(s32) = COPY $w080 %cst:_(s32) = G_CONSTANT i32 081 %op:gpr(s32) = G_MUL %x(s32), %cst82 $w0 = COPY %op(s32)83 RET_ReallyLR implicit $w084 85...86 87---88name: sdiv_089tracksRegLiveness: true90body: |91 bb.1.entry:92 liveins: $w093 ; Fold (0 / x) -> 094 ; CHECK-LABEL: name: sdiv_095 ; CHECK: liveins: $w096 ; CHECK-NEXT: {{ $}}97 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 098 ; CHECK-NEXT: $w0 = COPY %cst(s32)99 ; CHECK-NEXT: RET_ReallyLR implicit $w0100 %x:_(s32) = COPY $w0101 %cst:_(s32) = G_CONSTANT i32 0102 %op:_(s32) = G_SDIV %cst, %x103 $w0 = COPY %op(s32)104 RET_ReallyLR implicit $w0105 106...107---108name: udiv_0109tracksRegLiveness: true110body: |111 bb.1.entry:112 liveins: $w0113 ; Fold (0 / x) -> 0114 ; CHECK-LABEL: name: udiv_0115 ; CHECK: liveins: $w0116 ; CHECK-NEXT: {{ $}}117 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0118 ; CHECK-NEXT: $w0 = COPY %cst(s32)119 ; CHECK-NEXT: RET_ReallyLR implicit $w0120 %x:_(s32) = COPY $w0121 %cst:_(s32) = G_CONSTANT i32 0122 %op:_(s32) = G_UDIV %cst, %x123 $w0 = COPY %op(s32)124 RET_ReallyLR implicit $w0125 126...127---128name: srem_0129tracksRegLiveness: true130body: |131 bb.1.entry:132 liveins: $w0133 ; Fold (0 % x) -> 0134 ; CHECK-LABEL: name: srem_0135 ; CHECK: liveins: $w0136 ; CHECK-NEXT: {{ $}}137 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0138 ; CHECK-NEXT: $w0 = COPY %cst(s32)139 ; CHECK-NEXT: RET_ReallyLR implicit $w0140 %x:_(s32) = COPY $w0141 %cst:_(s32) = G_CONSTANT i32 0142 %op:_(s32) = G_SREM %cst, %x143 $w0 = COPY %op(s32)144 RET_ReallyLR implicit $w0145 146...147---148name: urem_0149tracksRegLiveness: true150body: |151 bb.1.entry:152 liveins: $w0153 ; Fold (0 % x) -> 0154 ; CHECK-LABEL: name: urem_0155 ; CHECK: liveins: $w0156 ; CHECK-NEXT: {{ $}}157 ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 0158 ; CHECK-NEXT: $w0 = COPY %cst(s32)159 ; CHECK-NEXT: RET_ReallyLR implicit $w0160 %x:_(s32) = COPY $w0161 %cst:_(s32) = G_CONSTANT i32 0162 %op:_(s32) = G_UREM %cst, %x163 $w0 = COPY %op(s32)164 RET_ReallyLR implicit $w0165 166...167 168---169name: right_ident_or170tracksRegLiveness: true171body: |172 bb.1.entry:173 liveins: $w0174 ; Fold (x || 0) -> x175 ; CHECK-LABEL: name: right_ident_or176 ; CHECK: liveins: $w0177 ; CHECK-NEXT: {{ $}}178 ; CHECK-NEXT: %x:_(s32) = COPY $w0179 ; CHECK-NEXT: $w0 = COPY %x(s32)180 ; CHECK-NEXT: RET_ReallyLR implicit $w0181 %x:_(s32) = COPY $w0182 %cst:_(s32) = G_CONSTANT i32 0183 %op:_(s32) = G_OR %x(s32), %cst184 $w0 = COPY %op(s32)185 RET_ReallyLR implicit $w0186 187...188---189name: right_ident_xor190tracksRegLiveness: true191body: |192 bb.1.entry:193 liveins: $w0194 ; Fold (x | 0) -> x195 ; CHECK-LABEL: name: right_ident_xor196 ; CHECK: liveins: $w0197 ; CHECK-NEXT: {{ $}}198 ; CHECK-NEXT: %x:_(s32) = COPY $w0199 ; CHECK-NEXT: $w0 = COPY %x(s32)200 ; CHECK-NEXT: RET_ReallyLR implicit $w0201 %x:_(s32) = COPY $w0202 %cst:_(s32) = G_CONSTANT i32 0203 %op:_(s32) = G_XOR %x(s32), %cst204 $w0 = COPY %op(s32)205 RET_ReallyLR implicit $w0206 207...208---209name: right_ident_shl210tracksRegLiveness: true211body: |212 bb.1.entry:213 liveins: $w0214 ; Fold (x << 0) -> x215 ; CHECK-LABEL: name: right_ident_shl216 ; CHECK: liveins: $w0217 ; CHECK-NEXT: {{ $}}218 ; CHECK-NEXT: %x:_(s32) = COPY $w0219 ; CHECK-NEXT: $w0 = COPY %x(s32)220 ; CHECK-NEXT: RET_ReallyLR implicit $w0221 %x:_(s32) = COPY $w0222 %cst:_(s32) = G_CONSTANT i32 0223 %op:_(s32) = G_SHL %x(s32), %cst224 $w0 = COPY %op(s32)225 RET_ReallyLR implicit $w0226 227...228---229name: right_ident_ashr230tracksRegLiveness: true231body: |232 bb.1.entry:233 liveins: $w0234 ; Fold (x ashr 0) -> x235 ; CHECK-LABEL: name: right_ident_ashr236 ; CHECK: liveins: $w0237 ; CHECK-NEXT: {{ $}}238 ; CHECK-NEXT: %x:_(s32) = COPY $w0239 ; CHECK-NEXT: $w0 = COPY %x(s32)240 ; CHECK-NEXT: RET_ReallyLR implicit $w0241 %x:_(s32) = COPY $w0242 %cst:_(s32) = G_CONSTANT i32 0243 %op:_(s32) = G_ASHR %x(s32), %cst244 $w0 = COPY %op(s32)245 RET_ReallyLR implicit $w0246 247...248---249name: right_ident_lshr250tracksRegLiveness: true251body: |252 bb.1.entry:253 liveins: $w0254 ; Fold (x lshr 0) -> x255 ; CHECK-LABEL: name: right_ident_lshr256 ; CHECK: liveins: $w0257 ; CHECK-NEXT: {{ $}}258 ; CHECK-NEXT: %x:_(s32) = COPY $w0259 ; CHECK-NEXT: $w0 = COPY %x(s32)260 ; CHECK-NEXT: RET_ReallyLR implicit $w0261 %x:_(s32) = COPY $w0262 %cst:_(s32) = G_CONSTANT i32 0263 %op:_(s32) = G_LSHR %x(s32), %cst264 $w0 = COPY %op(s32)265 RET_ReallyLR implicit $w0266 267...268---269name: dont_fold_sub270tracksRegLiveness: true271body: |272 bb.1.entry:273 liveins: $w0274 ; Not an identity, no folding.275 ; CHECK-LABEL: name: dont_fold_sub276 ; CHECK: liveins: $w0277 ; CHECK-NEXT: {{ $}}278 ; CHECK-NEXT: %x:_(s32) = COPY $w0279 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1280 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]]281 ; CHECK-NEXT: $w0 = COPY %op(s32)282 ; CHECK-NEXT: RET_ReallyLR implicit $w0283 %x:_(s32) = COPY $w0284 %cst:_(s32) = G_CONSTANT i32 1285 %op:_(s32) = G_SUB %x(s32), %cst286 $w0 = COPY %op(s32)287 RET_ReallyLR implicit $w0288 289...290---291name: look_through_zext292tracksRegLiveness: true293body: |294 bb.0:295 liveins: $x0296 ; CHECK-LABEL: name: look_through_zext297 ; CHECK: liveins: $x0298 ; CHECK-NEXT: {{ $}}299 ; CHECK-NEXT: %zext_zero:_(s64) = G_CONSTANT i64 0300 ; CHECK-NEXT: $x0 = COPY %zext_zero(s64)301 ; CHECK-NEXT: RET_ReallyLR implicit $x0302 %zero:_(s8) = G_CONSTANT i8 0303 %zext_zero:_(s64) = G_ZEXT %zero(s8)304 %c:_(s64) = G_CONSTANT i64 72340172838076673305 %mul:_(s64) = G_MUL %c, %zext_zero306 $x0 = COPY %mul(s64)307 RET_ReallyLR implicit $x0308...309---310name: right_ident_ptr_add311tracksRegLiveness: true312body: |313 bb.1.entry:314 liveins: $x0315 ; Fold (x + 0) -> x316 ; CHECK-LABEL: name: right_ident_ptr_add317 ; CHECK: liveins: $x0318 ; CHECK-NEXT: {{ $}}319 ; CHECK-NEXT: %x:_(p0) = COPY $x0320 ; CHECK-NEXT: $x0 = COPY %x(p0)321 ; CHECK-NEXT: RET_ReallyLR implicit $x0322 %x:_(p0) = COPY $x0323 %cst:_(s64) = G_CONSTANT i64 0324 %op:_(p0) = G_PTR_ADD %x(p0), %cst325 $x0 = COPY %op(p0)326 RET_ReallyLR implicit $x0327...328---329name: right_identity_rotl330tracksRegLiveness: true331body: |332 bb.0:333 liveins: $w0, $w1334 ; CHECK-LABEL: name: right_identity_rotl335 ; CHECK: liveins: $w0, $w1336 ; CHECK-NEXT: {{ $}}337 ; CHECK-NEXT: %copy:_(s32) = COPY $w0338 ; CHECK-NEXT: $w0 = COPY %copy(s32)339 ; CHECK-NEXT: RET_ReallyLR implicit $w0340 %copy:_(s32) = COPY $w0341 %zero:_(s32) = G_CONSTANT i32 0342 %rot:_(s32) = G_ROTL %copy(s32), %zero(s32)343 $w0 = COPY %rot(s32)344 RET_ReallyLR implicit $w0345...346...347---348name: right_identity_rotr349tracksRegLiveness: true350body: |351 bb.0:352 liveins: $w0, $w1353 ; CHECK-LABEL: name: right_identity_rotr354 ; CHECK: liveins: $w0, $w1355 ; CHECK-NEXT: {{ $}}356 ; CHECK-NEXT: %copy:_(s32) = COPY $w0357 ; CHECK-NEXT: $w0 = COPY %copy(s32)358 ; CHECK-NEXT: RET_ReallyLR implicit $w0359 %copy:_(s32) = COPY $w0360 %zero:_(s32) = G_CONSTANT i32 0361 %rot:_(s32) = G_ROTR %copy(s32), %zero(s32)362 $w0 = COPY %rot(s32)363 RET_ReallyLR implicit $w0364...365---366name: lshr_of_vec_zero367body: |368 bb.1:369 liveins: $q0370 ; CHECK-LABEL: name: lshr_of_vec_zero371 ; CHECK: liveins: $q0372 ; CHECK-NEXT: {{ $}}373 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q0374 ; CHECK-NEXT: $q0 = COPY [[COPY]](<8 x s16>)375 ; CHECK-NEXT: RET_ReallyLR implicit $q0376 %0:_(<8 x s16>) = COPY $q0377 %5:_(s16) = G_CONSTANT i16 0378 %zero_vec:_(<8 x s16>) = G_BUILD_VECTOR %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16), %5(s16)379 %shift:_(<8 x s16>) = G_LSHR %0, %zero_vec(<8 x s16>)380 $q0 = COPY %shift(<8 x s16>)381 RET_ReallyLR implicit $q0382...383---384name: ptradd_of_vec_zero385body: |386 bb.1:387 liveins: $q0388 ; CHECK-LABEL: name: ptradd_of_vec_zero389 ; CHECK: liveins: $q0390 ; CHECK-NEXT: {{ $}}391 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x p0>) = COPY $q0392 ; CHECK-NEXT: $q0 = COPY [[COPY]](<2 x p0>)393 ; CHECK-NEXT: RET_ReallyLR implicit $q0394 %0:_(<2 x p0>) = COPY $q0395 %5:_(s64) = G_CONSTANT i64 0396 %zero_vec:_(<2 x s64>) = G_BUILD_VECTOR %5(s64), %5(s64)397 %ptr:_(<2 x p0>) = G_PTR_ADD %0, %zero_vec(<2 x s64>)398 $q0 = COPY %ptr(<2 x p0>)399 RET_ReallyLR implicit $q0400...401---402name: i128_or_cst403liveins:404 - { reg: '$x0' }405body: |406 bb.1:407 liveins: $x0408 409 ; CHECK-LABEL: name: i128_or_cst410 ; CHECK: liveins: $x0411 ; CHECK-NEXT: {{ $}}412 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0413 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s128) = G_LOAD [[COPY]](p0) :: (load (s128))414 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s128) = G_CONSTANT i128 9223372036854775808415 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s128) = G_OR [[LOAD]], [[C]]416 ; CHECK-NEXT: G_STORE [[OR]](s128), [[COPY]](p0) :: (store (s128), align 4)417 ; CHECK-NEXT: RET_ReallyLR418 %0:_(p0) = COPY $x0419 %2:_(s128) = G_LOAD %0(p0) :: (load (s128))420 %4:_(s128) = G_CONSTANT i128 9223372036854775808421 %5:_(s128) = G_OR %2, %4422 G_STORE %5(s128), %0(p0) :: (store (s128), align 4)423 RET_ReallyLR424 425...426---427name: mul_1_shift_of_shift428liveins:429 - { reg: '$x0' }430body: |431 bb.1:432 liveins: $x0433 434 ; CHECK-LABEL: name: mul_1_shift_of_shift435 ; CHECK: liveins: $x0436 ; CHECK-NEXT: {{ $}}437 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0438 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1439 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY]], [[C]](s64)440 ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[SHL]], [[C]]441 ; CHECK-NEXT: $x0 = COPY [[OR]](s64)442 ; CHECK-NEXT: RET_ReallyLR implicit $x0443 %0:_(s64) = COPY $x0444 %1:_(s64) = G_CONSTANT i64 1445 %2:_(s64) = G_SHL %0, %1(s64)446 %3:_(s64) = G_OR %2, %1447 %4:_(s64) = G_MUL %3, %1448 $x0 = COPY %4(s64)449 RET_ReallyLR implicit $x0450 451...452---453name: udiv_of_sext454alignment: 4455tracksRegLiveness: true456liveins:457 - { reg: '$w0' }458body: |459 bb.1:460 liveins: $w0461 462 ; CHECK-LABEL: name: udiv_of_sext463 ; CHECK: liveins: $w0464 ; CHECK-NEXT: {{ $}}465 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0466 ; CHECK-NEXT: $w0 = COPY [[C]](s32)467 ; CHECK-NEXT: RET_ReallyLR implicit $w0468 %2:_(s1) = G_CONSTANT i1 true469 %4:_(s2) = G_CONSTANT i2 1470 %3:_(s2) = G_SEXT %2:_(s1)471 %5:_(s2) = G_UDIV %4:_, %3:_472 %6:_(s32) = G_ANYEXT %5:_(s2)473 $w0 = COPY %6:_(s32)474 RET_ReallyLR implicit $w0475 476...477---478name: sub_to_add479tracksRegLiveness: true480body: |481 bb.1.entry:482 liveins: $w0483 ; CHECK-LABEL: name: sub_to_add484 ; CHECK: liveins: $w0485 ; CHECK-NEXT: {{ $}}486 ; CHECK-NEXT: %x:_(s32) = COPY $w0487 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1488 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]]489 ; CHECK-NEXT: $w0 = COPY %op(s32)490 ; CHECK-NEXT: RET_ReallyLR implicit $w0491 %x:_(s32) = COPY $w0492 %cst:_(s32) = G_CONSTANT i32 1493 %op:_(s32) = G_SUB %x(s32), %cst494 $w0 = COPY %op(s32)495 RET_ReallyLR implicit $w0496 497...498---499name: sub_to_add_nuw500tracksRegLiveness: true501body: |502 bb.1.entry:503 liveins: $w0504 ; CHECK-LABEL: name: sub_to_add_nuw505 ; CHECK: liveins: $w0506 ; CHECK-NEXT: {{ $}}507 ; CHECK-NEXT: %x:_(s32) = COPY $w0508 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1509 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]]510 ; CHECK-NEXT: $w0 = COPY %op(s32)511 ; CHECK-NEXT: RET_ReallyLR implicit $w0512 %x:_(s32) = COPY $w0513 %cst:_(s32) = G_CONSTANT i32 1514 %op:_(s32) = nuw G_SUB %x(s32), %cst515 $w0 = COPY %op(s32)516 RET_ReallyLR implicit $w0517 518...519---520name: sub_to_add_nsw521tracksRegLiveness: true522body: |523 bb.1.entry:524 liveins: $w0525 ; CHECK-LABEL: name: sub_to_add_nsw526 ; CHECK: liveins: $w0527 ; CHECK-NEXT: {{ $}}528 ; CHECK-NEXT: %x:_(s32) = COPY $w0529 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1530 ; CHECK-NEXT: %op:_(s32) = nsw G_ADD %x, [[C]]531 ; CHECK-NEXT: $w0 = COPY %op(s32)532 ; CHECK-NEXT: RET_ReallyLR implicit $w0533 %x:_(s32) = COPY $w0534 %cst:_(s32) = G_CONSTANT i32 1535 %op:_(s32) = nsw G_SUB %x(s32), %cst536 $w0 = COPY %op(s32)537 RET_ReallyLR implicit $w0538 539...540---541name: sub_to_add_nsw_128542body: |543 bb.0:544 liveins: $w0, $w1545 546 ; CHECK-LABEL: name: sub_to_add_nsw_128547 ; CHECK: liveins: $w0, $w1548 ; CHECK-NEXT: {{ $}}549 ; CHECK-NEXT: %a:_(s32) = COPY $w0550 ; CHECK-NEXT: %b:_(s8) = G_TRUNC %a(s32)551 ; CHECK-NEXT: %c:_(s8) = G_CONSTANT i8 -128552 ; CHECK-NEXT: %add:_(s8) = G_ADD %b, %c553 ; CHECK-NEXT: %d:_(s32) = G_ZEXT %add(s8)554 ; CHECK-NEXT: $w0 = COPY %d(s32)555 ; CHECK-NEXT: RET_ReallyLR implicit $x0556 %a:_(s32) = COPY $w0557 %b:_(s8) = G_TRUNC %a558 %c:_(s8) = G_CONSTANT i8 -128559 %add:_(s8) = nsw nuw G_SUB %b, %c560 %d:_(s32) = G_ZEXT %add561 $w0 = COPY %d562 RET_ReallyLR implicit $x0563 564...565---566name: sub_to_add_nsw_intmin567body: |568 bb.0:569 liveins: $w0, $w1570 571 ; CHECK-LABEL: name: sub_to_add_nsw_intmin572 ; CHECK: liveins: $w0, $w1573 ; CHECK-NEXT: {{ $}}574 ; CHECK-NEXT: %a:_(s32) = COPY $w0575 ; CHECK-NEXT: %c:_(s32) = G_CONSTANT i32 -2147483648576 ; CHECK-NEXT: %add:_(s32) = G_ADD %a, %c577 ; CHECK-NEXT: $w0 = COPY %add(s32)578 ; CHECK-NEXT: RET_ReallyLR implicit $x0579 %a:_(s32) = COPY $w0580 %c:_(s32) = G_CONSTANT i32 -2147483648581 %add:_(s32) = nsw nuw G_SUB %a, %c582 $w0 = COPY %add583 RET_ReallyLR implicit $x0584...585