llvm/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-inttoptr-rv64.mir

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

---
name:            p0_s64
body:             |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: p0_s64
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[COPY]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:_(s64) = COPY $x10
    %1:_(p0) = G_INTTOPTR %0(s64)
    $x10 = COPY %1(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s32
body:             |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: p0_s32
    ; 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: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %0:_(s32) = G_TRUNC %1(s64)
    %2:_(p0) = G_INTTOPTR %0(s32)
    $x10 = COPY %2(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s16
body:             |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: p0_s16
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 65535
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %0:_(s16) = G_TRUNC %1(s64)
    %2:_(p0) = G_INTTOPTR %0(s16)
    $x10 = COPY %2(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s8
body:             |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: p0_s8
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 255
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %0:_(s8) = G_TRUNC %1(s64)
    %2:_(p0) = G_INTTOPTR %0(s8)
    $x10 = COPY %2(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s1
body:             |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: p0_s1
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %0:_(s1) = G_TRUNC %1(s64)
    %2:_(p0) = G_INTTOPTR %0(s1)
    $x10 = COPY %2(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s128
body:             |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: p0_s128
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[COPY]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %2:_(s64) = COPY $x11
    %0:_(s128) = G_MERGE_VALUES %1(s64), %2(s64)
    %3:_(p0) = G_INTTOPTR %0(s128)
    $x10 = COPY %3(p0)
    PseudoRET implicit $x10

...
---
name:            p0_s88
body:             |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: p0_s88
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[COPY]](s64)
    ; CHECK-NEXT: $x10 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: PseudoRET implicit $x10
    %1:_(s64) = COPY $x10
    %2:_(s64) = COPY $x11
    %3:_(s128) = G_MERGE_VALUES %1(s64), %2(s64)
    %0:_(s88) = G_TRUNC %3(s128)
    %4:_(p0) = G_INTTOPTR %0(s88)
    $x10 = COPY %4(p0)
    PseudoRET implicit $x10

...