llvm/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/merge-unmerge-rv64.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - | FileCheck %s

---
name:            merge_i32
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: merge_i32
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 16
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
    ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ASSERT_ZEXT]], [[C]](s64)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[ASSERT_ZEXT]], [[SHL]]
    ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = G_ASSERT_ZEXT %0, 16
    %2:_(s16) = G_TRUNC %1(s64)
    %3:_(s32) = G_MERGE_VALUES %2(s16), %2(s16)
    %4:_(s64) = G_ZEXT %3(s32)
    $x10 = COPY %4(s64)
    PseudoRET implicit $x10
...
---
name:            merge_i64
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: merge_i64
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s64) = G_ASSERT_ZEXT [[COPY]], 32
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
    ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ASSERT_ZEXT]], [[C]](s64)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[ASSERT_ZEXT]], [[SHL]]
    ; CHECK-NEXT: $x10 = COPY [[OR]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s64) = G_ASSERT_ZEXT %0, 32
    %2:_(s32) = G_TRUNC %1(s64)
    %3:_(s64) = G_MERGE_VALUES %2(s32), %2(s32)
    $x10 = COPY %3(s64)
    PseudoRET implicit $x10
...
---
name:            merge_i128
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: merge_i128
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s128) = G_MERGE_VALUES %0(s64), %0(s64)
    %2:_(s64) = G_TRUNC %1(s128)
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10
...
---
name:            unmerge_i32
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: unmerge_i32
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
    ; CHECK-NEXT: $x10 = COPY [[AND]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(s64)
    %3:_(s64) = G_ZEXT %1(s32)
    $x10 = COPY %3(s64)
    PseudoRET implicit $x10
...
---
name:            unmerge_i64
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: unmerge_i64
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s128) = G_ZEXT %0(s64)
    %2:_(s64), %3:_(s64) = G_UNMERGE_VALUES %1(s128)
    $x10 = COPY %2(s64)
    PseudoRET implicit $x10
...
---
name:            unmerge_i128
body:             |
  bb.0.entry:
    liveins: $x10
    ; CHECK-LABEL: name: unmerge_i128
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(s256) = G_ZEXT %0(s64)
    %2:_(s128), %3:_(s128) = G_UNMERGE_VALUES %1(s256)
    %4:_(s64) = G_TRUNC %2(s128)
    $x10 = COPY %4(s64)
    PseudoRET implicit $x10
...