llvm/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/store-rv64.mir

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

--- |
  define void @store_i8_i64(i8 %val, ptr %addr) { ret void }
  define void @store_i16_i64(i16 %val, ptr %addr) { ret void }
  define void @store_i32_i64(i32 %val, ptr %addr) { ret void }
  define void @store_i64_i64(i32 %val, ptr %addr) { ret void }
  define void @store_p0(ptr %val, ptr %addr) { ret void }
  define void @truncstore_i8_i32(i8 %val, ptr %addr) { ret void }
  define void @truncstore_i16_i32(i8 %val, ptr %addr) { ret void }
  define void @store_i32_i32(i8 %val, ptr %addr) { ret void }
  define void @store_fi_i64_i64(ptr %val) {
    %ptr0 = alloca i64
    ret void
  }
  define void @store_fi_gep_i64_i64(ptr %val) {
    %ptr0 = alloca [2 x i64]
    ret void
  }
  define void @store_gep_i64_i64(i32 %val, ptr %addr) { ret void }
...
---
name:            store_i8_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_i8_i64
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SB [[COPY]], [[COPY1]], 0 :: (store (s8))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = COPY $x11
    G_STORE %0(s64), %1(p0) :: (store (s8))
    PseudoRET

...
---
name:            store_i16_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_i16_i64
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SH [[COPY]], [[COPY1]], 0 :: (store (s16))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = COPY $x11
    G_STORE %0(s64), %1(p0) :: (store (s16))
    PseudoRET

...
---
name:            store_i32_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_i32_i64
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SW [[COPY]], [[COPY1]], 0 :: (store (s32))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = COPY $x11
    G_STORE %0(s64), %1(p0) :: (store (s32))
    PseudoRET

...
---
name:            store_i64_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_i64_i64
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SD [[COPY]], [[COPY1]], 0 :: (store (s64))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = COPY $x11
    G_STORE %0(s64), %1(p0) :: (store (s64))
    PseudoRET

...
---
name:            store_p0
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_p0
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SD [[COPY]], [[COPY1]], 0 :: (store (p0))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(p0) = COPY $x10
    %1:gprb(p0) = COPY $x11
    G_STORE %0(p0), %1(p0) :: (store (p0))
    PseudoRET

...
---
name:            truncstore_i8_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x10, $x11, $x12

    ; CHECK-LABEL: name: truncstore_i8_i32
    ; CHECK: liveins: $x10, $x11, $x12
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
    ; CHECK-NEXT: [[ADDW:%[0-9]+]]:gpr = ADDW [[COPY1]], [[COPY2]]
    ; CHECK-NEXT: SB [[ADDW]], [[COPY]], 0 :: (store (s8))
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x0
    ; CHECK-NEXT: $x10 = COPY [[COPY3]]
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:gprb(p0) = COPY $x10
    %3:gprb(s64) = COPY $x11
    %4:gprb(s64) = COPY $x12
    %9:gprb(s32) = G_TRUNC %3(s64)
    %10:gprb(s32) = G_TRUNC %4(s64)
    %11:gprb(s32) = G_ADD %9, %10
    G_STORE %11(s32), %0(p0) :: (store (s8))
    %7:gprb(s64) = G_CONSTANT i64 0
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            truncstore_i16_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x10, $x11, $x12

    ; CHECK-LABEL: name: truncstore_i16_i32
    ; CHECK: liveins: $x10, $x11, $x12
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
    ; CHECK-NEXT: [[ADDW:%[0-9]+]]:gpr = ADDW [[COPY1]], [[COPY2]]
    ; CHECK-NEXT: SH [[ADDW]], [[COPY]], 0 :: (store (s16))
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x0
    ; CHECK-NEXT: $x10 = COPY [[COPY3]]
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:gprb(p0) = COPY $x10
    %3:gprb(s64) = COPY $x11
    %4:gprb(s64) = COPY $x12
    %9:gprb(s32) = G_TRUNC %3(s64)
    %10:gprb(s32) = G_TRUNC %4(s64)
    %11:gprb(s32) = G_ADD %9, %10
    G_STORE %11(s32), %0(p0) :: (store (s16))
    %7:gprb(s64) = G_CONSTANT i64 0
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            store_i32_i32
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x10, $x11, $x12

    ; CHECK-LABEL: name: store_i32_i32
    ; CHECK: liveins: $x10, $x11, $x12
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x12
    ; CHECK-NEXT: [[ADDW:%[0-9]+]]:gpr = ADDW [[COPY1]], [[COPY2]]
    ; CHECK-NEXT: SW [[ADDW]], [[COPY]], 0 :: (store (s32))
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr = COPY $x0
    ; CHECK-NEXT: $x10 = COPY [[COPY3]]
    ; CHECK-NEXT: PseudoRET implicit $x10
    %0:gprb(p0) = COPY $x10
    %3:gprb(s64) = COPY $x11
    %4:gprb(s64) = COPY $x12
    %9:gprb(s32) = G_TRUNC %3(s64)
    %10:gprb(s32) = G_TRUNC %4(s64)
    %11:gprb(s32) = G_ADD %9, %10
    G_STORE %11(s32), %0(p0) :: (store (s32))
    %7:gprb(s64) = G_CONSTANT i64 0
    $x10 = COPY %7(s64)
    PseudoRET implicit $x10

...
---
name:            store_fi_i64_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true

stack:
  - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }

body:            |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: store_fi_i64_i64
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: SD [[COPY]], %stack.0.ptr0, 0 :: (store (s64))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = G_FRAME_INDEX %stack.0.ptr0
    G_STORE %0(s64), %1(p0) :: (store (s64))
    PseudoRET

...
---
name:            store_fi_gep_i64_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true

stack:
  - { id: 0, name: ptr0, offset: 0, size: 16, alignment: 8 }

body:            |
  bb.0:
    liveins: $x10

    ; CHECK-LABEL: name: store_fi_gep_i64_i64
    ; CHECK: liveins: $x10
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: SD [[COPY]], %stack.0.ptr0, 8 :: (store (s64))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = G_FRAME_INDEX %stack.0.ptr0
    %2:gprb(s64) = G_CONSTANT i64 8
    %3:gprb(p0) = G_PTR_ADD %1(p0), %2(s64)
    G_STORE %0(s64), %3(p0) :: (store (s64))
    PseudoRET

...
---
name:            store_gep_i64_i64
legalized:       true
regBankSelected: true
tracksRegLiveness: true
body:            |
  bb.0:
    liveins: $x10, $x11

    ; CHECK-LABEL: name: store_gep_i64_i64
    ; CHECK: liveins: $x10, $x11
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; CHECK-NEXT: SD [[COPY]], [[COPY1]], 8 :: (store (s64))
    ; CHECK-NEXT: PseudoRET
    %0:gprb(s64) = COPY $x10
    %1:gprb(p0) = COPY $x11
    %2:gprb(s64) = G_CONSTANT i64 8
    %3:gprb(p0) = G_PTR_ADD %1(p0), %2(s64)
    G_STORE %0(s64), %3(p0) :: (store (s64))
    PseudoRET

...