llvm/llvm/test/CodeGen/AArch64/GlobalISel/legalize-ssube.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64 -verify-machineinstrs -run-pass=legalizer -debugify-and-strip-all-safe %s -o - | FileCheck %s

---
name:            narrow_scalar_ssube_s128
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: narrow_scalar_ssube_s128
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
    ; CHECK-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY $x4
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY4]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
    ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE [[COPY]], [[COPY2]], [[AND]]
    ; CHECK-NEXT: [[SSUBE:%[0-9]+]]:_(s64), [[SSUBE1:%[0-9]+]]:_(s32) = G_SSUBE [[COPY1]], [[COPY3]], [[USUBE1]]
    ; CHECK-NEXT: %carry_out_ext:_(s64) = G_ANYEXT [[SSUBE1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[USUBE]](s64)
    ; CHECK-NEXT: $x1 = COPY [[SSUBE]](s64)
    ; CHECK-NEXT: $x2 = COPY %carry_out_ext(s64)
    %0:_(s64) = COPY $x0
    %1:_(s64) = COPY $x1
    %2:_(s64) = COPY $x2
    %3:_(s64) = COPY $x3
    %4:_(s64) = COPY $x4
    %lhs:_(s128) = G_MERGE_VALUES %0, %1
    %rhs:_(s128) = G_MERGE_VALUES %2, %3
    %carry_in:_(s1) = G_TRUNC %4
    %sub:_(s128), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
    %sub0:_(s64), %sub1:_(s64) = G_UNMERGE_VALUES %sub
    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
    $x0 = COPY %sub0
    $x1 = COPY %sub1
    $x2 = COPY %carry_out_ext

...
---
name:            narrow_scalar_ssube_big_nonpow2
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: narrow_scalar_ssube_big_nonpow2
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
    ; CHECK-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY $x4
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY4]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
    ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE [[COPY]], [[COPY1]], [[AND]]
    ; CHECK-NEXT: [[USUBE2:%[0-9]+]]:_(s64), [[USUBE3:%[0-9]+]]:_(s32) = G_USUBE [[COPY1]], [[COPY2]], [[USUBE1]]
    ; CHECK-NEXT: [[SSUBE:%[0-9]+]]:_(s64), [[SSUBE1:%[0-9]+]]:_(s32) = G_SSUBE [[COPY2]], [[COPY3]], [[USUBE3]]
    ; CHECK-NEXT: %carry_out_ext:_(s64) = G_ANYEXT [[SSUBE1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[USUBE]](s64)
    ; CHECK-NEXT: $x1 = COPY [[USUBE2]](s64)
    ; CHECK-NEXT: $x2 = COPY [[SSUBE]](s64)
    ; CHECK-NEXT: $x3 = COPY %carry_out_ext(s64)
    %0:_(s64) = COPY $x0
    %1:_(s64) = COPY $x1
    %2:_(s64) = COPY $x2
    %3:_(s64) = COPY $x3
    %4:_(s64) = COPY $x4
    %lhs:_(s192) = G_MERGE_VALUES %0, %1, %2
    %rhs:_(s192) = G_MERGE_VALUES %1, %2, %3
    %carry_in:_(s1) = G_TRUNC %4
    %sub:_(s192), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
    %sub0:_(s64), %sub1:_(s64), %sub2:_(s64) = G_UNMERGE_VALUES %sub
    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
    $x0 = COPY %sub0
    $x1 = COPY %sub1
    $x2 = COPY %sub2
    $x3 = COPY %carry_out_ext

...
---
name:            widen_scalar_ssube_s8
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: widen_scalar_ssube_s8
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
    ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
    ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC]], 8
    ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
    ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC1]], 8
    ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY2]](s64)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC2]], [[C]]
    ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s32), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE [[SEXT_INREG]], [[SEXT_INREG1]], [[AND]]
    ; CHECK-NEXT: [[SEXT_INREG2:%[0-9]+]]:_(s32) = G_SEXT_INREG [[USUBE]], 8
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ne), [[USUBE]](s32), [[SEXT_INREG2]]
    ; CHECK-NEXT: %sub_ext:_(s64) = G_ANYEXT [[USUBE]](s32)
    ; CHECK-NEXT: %carry_out_ext:_(s64) = G_ANYEXT [[ICMP]](s32)
    ; CHECK-NEXT: $x0 = COPY %sub_ext(s64)
    ; CHECK-NEXT: $x1 = COPY %carry_out_ext(s64)
    %0:_(s64) = COPY $x0
    %1:_(s64) = COPY $x1
    %2:_(s64) = COPY $x2
    %lhs:_(s8) = G_TRUNC %0
    %rhs:_(s8) = G_TRUNC %1
    %carry_in:_(s1) = G_TRUNC %2
    %sub:_(s8), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
    %sub_ext:_(s64) = G_ANYEXT %sub
    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
    $x0 = COPY %sub_ext
    $x1 = COPY %carry_out_ext

...
---
name:            test_scalar_ssube_32
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_scalar_ssube_32
    ; CHECK: %lhs:_(s32) = COPY $w0
    ; CHECK-NEXT: %rhs:_(s32) = COPY $w1
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w2
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
    ; CHECK-NEXT: %sub:_(s32), %8:_(s32) = G_SSUBE %lhs, %rhs, [[AND]]
    ; CHECK-NEXT: $w0 = COPY %sub(s32)
    ; CHECK-NEXT: $w1 = COPY %8(s32)
    %lhs:_(s32) = COPY $w0
    %rhs:_(s32) = COPY $w1
    %2:_(s32) = COPY $w2
    %carry_in:_(s1) = G_TRUNC %2
    %sub:_(s32), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
    %carry_out_ext:_(s32) = G_ANYEXT %carry_out
    $w0 = COPY %sub
    $w1 = COPY %carry_out_ext

...