Compiler projects using llvm
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -verify-machineinstrs -mtriple arm64-apple-ios -global-isel -run-pass=aarch64-prelegalizer-combiner -o - %s | FileCheck %s

...
---
name:            can_fold_i8
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i8
  ; CHECK: bb.0.entry:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 8
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 8
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 256
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1.entry:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 8
    %0:_(s8) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 8
    %1:_(s8) = G_TRUNC %5(s32)
    %6:_(s8), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %8:_(s32) = G_ZEXT %6(s8)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

...
---
name:            can_fold_i16_1_result_used_by_zext
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i16_1_result_used_by_zext
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %8:_(s32) = G_ZEXT %6(s16)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

...
---
name:            can_fold_i16_2_result_used_by_multiple_calls
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i16_2_result_used_by_multiple_calls
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1, $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   liveins: $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   BLR killed renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   RET_ReallyLR
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1, $x2

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    liveins: $x2

    ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    %8:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %8(s32)
    BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
    ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    $w0 = COPY %8(s32)
    BLR killed renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
    ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    RET_ReallyLR

...
---
name:            can_fold_i16_3_result_used_by_anyext
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i16_3_result_used_by_anyext
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %8:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

...
---
name:            can_fold_i16_4_cond_dbg_user
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i16_4_cond_dbg_user
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   DBG_VALUE [[ICMP]](s1)
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    DBG_VALUE %7(s1)
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %8:_(s32) = G_ZEXT %6(s16)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

...
---
name:            can_fold_i16_5_result_dbg_user
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: can_fold_i16_5_result_dbg_user
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ASSERT_ZEXT]], [[ASSERT_ZEXT1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65536
  ; CHECK-NEXT:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
  ; CHECK-NEXT:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
  ; CHECK-NEXT:   [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK-NEXT:   DBG_VALUE {{%[0-9]+}}:_(s16)
  ; CHECK-NEXT:   G_BRCOND [[ICMP]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   $w0 = COPY [[ADD]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    DBG_VALUE %6(s16)
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %8:_(s32) = G_ZEXT %6(s16)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_1_result_used_before_branch
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_1_result_used_before_branch
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1, $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ANYEXT]](s32)
  ; CHECK-NEXT:   BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   liveins: $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ANYEXT1]](s32)
  ; CHECK-NEXT:   BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
  ; CHECK-NEXT:   RET_ReallyLR
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1, $x2

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    %8:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %8(s32)
    BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
    ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    liveins: $x2

    ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    %9:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %9(s32)
    BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
    ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    RET_ReallyLR

...
---
name:            cannot_fold_2_result_used_in_fail_block
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_2_result_used_in_fail_block
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 10
  ; CHECK-NEXT:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[C]](s16)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
  ; CHECK-NEXT:   [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   G_BRCOND [[UADDO1]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   [[PHI:%[0-9]+]]:_(s32) = G_PHI [[ANYEXT]](s32), %bb.2, [[ANYEXT1]](s32), %bb.0
  ; CHECK-NEXT:   $w0 = COPY [[PHI]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[ANYEXT2:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ANYEXT2]](s32)
  ; CHECK-NEXT:   G_BR %bb.1
  bb.1:
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %11:_(s16) = G_CONSTANT i16 10
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.3
    G_BR %bb.2

  bb.2:
    %9:_(s16) = G_PHI %11(s16), %bb.3, %6(s16), %bb.1
    %10:_(s32) = G_ANYEXT %9(s16)
    $w0 = COPY %10(s32)
    RET_ReallyLR implicit $w0

  bb.3:
    %8:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %8(s32)
    G_BR %bb.2

...
---
name:            cannot_fold_3_result_used_in_successor_before_fail_block
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_3_result_used_in_successor_before_fail_block
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1, $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
  ; CHECK-NEXT:   liveins: $x2
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ANYEXT]](s32)
  ; CHECK-NEXT:   BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
  ; CHECK-NEXT:   G_BRCOND [[UADDO1]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.3
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.3:
  ; CHECK-NEXT:   [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ZEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1, $x2

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BR %bb.4

  bb.4:
    liveins: $x2
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)

    %8:_(s32) = G_ANYEXT %6(s16)
    $w0 = COPY %8(s32)
    BLR renamable $x2, implicit-def dead $lr, implicit $sp, implicit $w0
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %9:_(s32) = G_ZEXT %6(s16)
    $w0 = COPY %9(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_i8_trunc_i
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_i8_trunc_i
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 8
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC]](s16)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC2]], [[TRUNC1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
  ; CHECK-NEXT:   $w0 = COPY [[ZEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 8
    %1:_(s8) = G_TRUNC %5(s32)
    %6:_(s8) = G_TRUNC %0(s16)
    %7:_(s8), %8:_(s1) = G_UADDO %6, %1
    G_BRCOND %8(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %9:_(s32) = G_ZEXT %7(s8)
    $w0 = COPY %9(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_i8_trunc_b
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_i8_trunc_b
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 8
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC1]](s16)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC2]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
  ; CHECK-NEXT:   $w0 = COPY [[ZEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 8
    %0:_(s8) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s8) = G_TRUNC %1(s16)
    %7:_(s8), %8:_(s1) = G_UADDO %0, %6
    G_BRCOND %8(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %9:_(s32) = G_ZEXT %7(s8)
    $w0 = COPY %9(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_i8_trunc_both
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_i8_trunc_both
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC]](s16)
  ; CHECK-NEXT:   [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[TRUNC1]](s16)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s8), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC2]], [[TRUNC3]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s8)
  ; CHECK-NEXT:   $w0 = COPY [[ZEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s8) = G_TRUNC %0(s16)
    %7:_(s8) = G_TRUNC %1(s16)
    %8:_(s8), %9:_(s1) = G_UADDO %6, %7
    G_BRCOND %9(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %10:_(s32) = G_ZEXT %8(s8)
    $w0 = COPY %10(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_overflow_status_used_in_select
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: cannot_fold_overflow_status_used_in_select
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 10
    ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
    ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s16) = G_SELECT [[UADDO1]](s1), [[C]], [[UADDO]]
    ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[SELECT]](s16)
    ; CHECK-NEXT: $w0 = COPY [[ZEXT]](s32)
    ; CHECK-NEXT: RET_ReallyLR implicit $w0
    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %9:_(s16) = G_CONSTANT i16 10
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    %8:_(s16) = G_SELECT %7(s1), %9, %6
    %10:_(s32) = G_ZEXT %8(s16)
    $w0 = COPY %10(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_i16_inputs_not_assert_zext
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_i16_inputs_not_assert_zext
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x00000800), %bb.2(0x7ffff800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors:{{ $}}
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ANYEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  bb.1:
    successors: %bb.2(0x00000800), %bb.3(0x7ffff800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %0:_(s16) = G_TRUNC %2(s32)
    %3:_(s32) = COPY $w1
    %1:_(s16) = G_TRUNC %3(s32)
    %4:_(s16), %5:_(s1) = G_UADDO %0, %1
    G_BRCOND %5(s1), %bb.2
    G_BR %bb.3

  bb.2:
    successors:

    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

  bb.3:
    %6:_(s32) = G_ANYEXT %4(s16)
    $w0 = COPY %6(s32)
    RET_ReallyLR implicit $w0

...
---
name:            cannot_fold_branch_to_use_on_overflow
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: cannot_fold_branch_to_use_on_overflow
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.1(0x7ffff800), %bb.2(0x00000800)
  ; CHECK-NEXT:   liveins: $w0, $w1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(s32) = COPY $w0
  ; CHECK-NEXT:   [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 16
  ; CHECK-NEXT:   [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT]](s32)
  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
  ; CHECK-NEXT:   [[ASSERT_ZEXT1:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY1]], 16
  ; CHECK-NEXT:   [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ASSERT_ZEXT1]](s32)
  ; CHECK-NEXT:   [[UADDO:%[0-9]+]]:_(s16), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[TRUNC]], [[TRUNC1]]
  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
  ; CHECK-NEXT:   [[XOR:%[0-9]+]]:_(s1) = G_XOR [[UADDO1]], [[C]]
  ; CHECK-NEXT:   G_BRCOND [[XOR]](s1), %bb.2
  ; CHECK-NEXT:   G_BR %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UADDO]](s16)
  ; CHECK-NEXT:   $w0 = COPY [[ZEXT]](s32)
  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
  bb.1:
    successors: %bb.2(0x7ffff800), %bb.3(0x00000800)
    liveins: $w0, $w1

    %2:_(s32) = COPY $w0
    %3:_(s32) = G_ASSERT_ZEXT %2, 16
    %0:_(s16) = G_TRUNC %3(s32)
    %4:_(s32) = COPY $w1
    %5:_(s32) = G_ASSERT_ZEXT %4, 16
    %1:_(s16) = G_TRUNC %5(s32)
    %6:_(s16), %7:_(s1) = G_UADDO %0, %1
    G_BRCOND %7(s1), %bb.2
    G_BR %bb.3

  bb.2:
    %8:_(s32) = G_ZEXT %6(s16)
    $w0 = COPY %8(s32)
    RET_ReallyLR implicit $w0

  bb.3:
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)

...