# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -O0 -run-pass=legalizer %s -o - | FileCheck %s

---
name: test_load_global_i32
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_i32
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
    ; CHECK: $vgpr0 = COPY [[LOAD]](s32)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(s32) = G_LOAD %0 :: (load 4, addrspace 1)

    $vgpr0 = COPY %1
...

---
name: test_load_global_i64
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_i64
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
    ; CHECK: $vgpr0 = COPY [[LOAD]](s32)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(s32) = G_LOAD %0 :: (load 4, addrspace 1)

    $vgpr0 = COPY %1
...

---
name: test_load_global_p1
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_p1
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
    ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](p1)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(p1) = G_LOAD %0 :: (load 8, addrspace 1)

    $vgpr0_vgpr1 = COPY %1
...

---
name: test_load_global_p4
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_p4
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(p4) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
    ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](p4)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(p4) = G_LOAD %0 :: (load 8, addrspace 1)

    $vgpr0_vgpr1 = COPY %1
...


---
name: test_load_global_p3
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_p3
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(p3) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
    ; CHECK: $vgpr0 = COPY [[LOAD]](p3)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(p3) = G_LOAD %0 :: (load 4, addrspace 1)

    $vgpr0 = COPY %1
...

---
name: test_load_global_v2s32
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_v2s32
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s32>) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
    ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](<2 x s32>)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(<2 x s32>) = G_LOAD %0 :: (load 8, addrspace 1)

    $vgpr0_vgpr1 = COPY %1
...

---

name: test_load_global_v2s16
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_v2s16
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s16>) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
    ; CHECK: $vgpr0 = COPY [[LOAD]](<2 x s16>)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(<2 x s16>) = G_LOAD %0 :: (load 4, addrspace 1)
    $vgpr0 = COPY %1
...

---
name: test_load_global_v3i32
body: |
  bb.0:
    liveins: $vgpr0_vgpr1

    ; CHECK-LABEL: name: test_load_global_v3i32
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[LOAD:%[0-9]+]]:_(<3 x s32>) = G_LOAD [[COPY]](p1) :: (load 12, align 4, addrspace 1)
    ; CHECK: $vgpr0_vgpr1_vgpr2 = COPY [[LOAD]](<3 x s32>)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(<3 x s32>) = G_LOAD %0 :: (load 12, align 4, addrspace 1)

    $vgpr0_vgpr1_vgpr2 = COPY %1
...
