llvm/llvm/test/CodeGen/AArch64/GlobalISel/legalize-saddo.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_saddo_s128
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: narrow_scalar_saddo_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: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[COPY]], [[COPY2]]
    ; CHECK-NEXT: [[SADDE:%[0-9]+]]:_(s64), [[SADDE1:%[0-9]+]]:_(s32) = G_SADDE [[COPY1]], [[COPY3]], [[UADDO1]]
    ; CHECK-NEXT: %carry_out_ext:_(s64) = G_ANYEXT [[SADDE1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[UADDO]](s64)
    ; CHECK-NEXT: $x1 = COPY [[SADDE]](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
    %lhs:_(s128) = G_MERGE_VALUES %0, %1
    %rhs:_(s128) = G_MERGE_VALUES %2, %3
    %add:_(s128), %carry_out:_(s1) = G_SADDO %lhs, %rhs
    %add0:_(s64), %add1:_(s64) = G_UNMERGE_VALUES %add
    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
    $x0 = COPY %add0
    $x1 = COPY %add1
    $x2 = COPY %carry_out_ext

...
---
name:            narrow_scalar_saddo_big_nonpow2
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: narrow_scalar_saddo_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: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[COPY]], [[COPY1]]
    ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE [[COPY1]], [[COPY2]], [[UADDO1]]
    ; CHECK-NEXT: [[SADDE:%[0-9]+]]:_(s64), [[SADDE1:%[0-9]+]]:_(s32) = G_SADDE [[COPY2]], [[COPY3]], [[UADDE1]]
    ; CHECK-NEXT: %carry_out_ext:_(s64) = G_ANYEXT [[SADDE1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[UADDO]](s64)
    ; CHECK-NEXT: $x1 = COPY [[UADDE]](s64)
    ; CHECK-NEXT: $x2 = COPY [[SADDE]](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
    %lhs:_(s192) = G_MERGE_VALUES %0, %1, %2
    %rhs:_(s192) = G_MERGE_VALUES %1, %2, %3
    %add:_(s192), %carry_out:_(s1) = G_SADDO %lhs, %rhs
    %add0:_(s64), %add1:_(s64), %add2:_(s64) = G_UNMERGE_VALUES %add
    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
    $x0 = COPY %add0
    $x1 = COPY %add1
    $x2 = COPY %add2
    $x3 = COPY %carry_out_ext

...
---
name:            test_scalar_saddo_small
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_scalar_saddo_small
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
    ; 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: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[SEXT_INREG]], [[SEXT_INREG1]]
    ; CHECK-NEXT: [[SEXT_INREG2:%[0-9]+]]:_(s32) = G_SEXT_INREG [[ADD]], 8
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ne), [[ADD]](s32), [[SEXT_INREG2]]
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ADD]](s32)
    ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[ICMP]](s32)
    ; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: $x1 = COPY [[ANYEXT1]](s64)
    %0:_(s64) = COPY $x0
    %1:_(s64) = COPY $x1
    %2:_(s8) = G_TRUNC %0(s64)
    %3:_(s8) = G_TRUNC %1(s64)
    %4:_(s8), %5:_(s1) = G_SADDO %2, %3
    %6:_(s64) = G_ANYEXT %4(s8)
    %7:_(s64) = G_ANYEXT %5(s1)
    $x0 = COPY %6(s64)
    $x1 = COPY %7(s64)

...
---
name:            test_scalar_saddo_32
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_scalar_saddo_32
    ; CHECK: %lhs:_(s32) = COPY $w0
    ; CHECK-NEXT: %rhs:_(s32) = COPY $w1
    ; CHECK-NEXT: %add:_(s32), %5:_(s32) = G_SADDO %lhs, %rhs
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: $w1 = COPY %5(s32)
    %lhs:_(s32) = COPY $w0
    %rhs:_(s32) = COPY $w1
    %add:_(s32), %carry_out:_(s1) = G_SADDO %lhs, %rhs
    %carry_out_ext:_(s32) = G_ANYEXT %carry_out
    $w0 = COPY %add
    $w1 = COPY %carry_out_ext

...