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

---
name: extract_vector_elt_0_v2i32

body: |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; CHECK-LABEL: name: extract_vector_elt_0_v2i32
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<2 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
    %1:_(s32) = G_CONSTANT i32 0
    %2:_(s32) = G_EXTRACT_VECTOR_ELT %0, %1
    $vgpr0 = COPY %2
...
---
name: extract_vector_elt_0_v3i32

body: |
  bb.0:
    liveins: $vgpr0_vgpr1_vgpr2
    ; CHECK-LABEL: name: extract_vector_elt_0_v3i32
    ; CHECK: [[COPY:%[0-9]+]]:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<3 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2
    %1:_(s32) = G_CONSTANT i32 0
    %2:_(s32) = G_EXTRACT_VECTOR_ELT %0, %1
    $vgpr0 = COPY %2
...
---
name: extract_vector_elt_0_v4i32

body: |
  bb.0:
    liveins: $vgpr0_vgpr1_vgpr2_vgpr3
    ; CHECK-LABEL: name: extract_vector_elt_0_v4i32
    ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<4 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    %1:_(s32) = G_CONSTANT i32 0
    %2:_(s32) = G_EXTRACT_VECTOR_ELT %0, %1
    $vgpr0 = COPY %2
...

---
name: extract_vector_elt_0_v5i32

body: |
  bb.0:
    liveins: $vgpr0
    ; CHECK-LABEL: name: extract_vector_elt_0_v5i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[MV:%[0-9]+]]:_(<5 x s32>) = G_MERGE_VALUES [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32)
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[MV]](<5 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(<5 x s32>) = G_MERGE_VALUES %0, %0, %0, %0, %0
    %2:_(s32) = G_CONSTANT i32 0
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %1, %2
    $vgpr0 = COPY %3
...

---
name: extract_vector_elt_0_v6i32

body: |
  bb.0:
    liveins: $vgpr0
    ; CHECK-LABEL: name: extract_vector_elt_0_v6i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[MV:%[0-9]+]]:_(<6 x s32>) = G_MERGE_VALUES [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32)
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[MV]](<6 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(<6 x s32>) = G_MERGE_VALUES %0, %0, %0, %0, %0, %0
    %2:_(s32) = G_CONSTANT i32 0
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %1, %2
    $vgpr0 = COPY %3
...

---
name: extract_vector_elt_0_v7i32

body: |
  bb.0:
    liveins: $vgpr0
    ; CHECK-LABEL: name: extract_vector_elt_0_v7i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[MV:%[0-9]+]]:_(<7 x s32>) = G_MERGE_VALUES [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32)
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[MV]](<7 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(<7 x s32>) = G_MERGE_VALUES %0, %0, %0, %0, %0, %0, %0
    %2:_(s32) = G_CONSTANT i32 0
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %1, %2
    $vgpr0 = COPY %3
...

---
name: extract_vector_elt_0_v8i32

body: |
  bb.0:
    liveins: $vgpr0
    ; CHECK-LABEL: name: extract_vector_elt_0_v8i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[MV:%[0-9]+]]:_(<8 x s32>) = G_MERGE_VALUES [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32)
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[MV]](<8 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(<8 x s32>) = G_MERGE_VALUES %0, %0, %0, %0, %0, %0, %0, %0
    %2:_(s32) = G_CONSTANT i32 0
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %1, %2
    $vgpr0 = COPY %3
...

---
name: extract_vector_elt_0_v16i32

body: |
  bb.0:
    liveins: $vgpr0
    ; CHECK-LABEL: name: extract_vector_elt_0_v16i32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[MV:%[0-9]+]]:_(<16 x s32>) = G_MERGE_VALUES [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32), [[COPY]](s32)
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[MV]](<16 x s32>), [[C]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(<16 x s32>) = G_MERGE_VALUES %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0
    %2:_(s32) = G_CONSTANT i32 0
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %1, %2
    $vgpr0 = COPY %3
...

---
name: extract_vector_elt_var_v2i32

body: |
  bb.0:
    liveins: $vgpr0_vgpr1, $vgpr2
    ; CHECK-LABEL: name: extract_vector_elt_var_v2i32
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<2 x s32>), [[COPY1]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
    %1:_(s32) = COPY $vgpr2
    %2:_(s32) = G_EXTRACT_VECTOR_ELT %0, %1
    $vgpr0 = COPY %2
...

---
name: extract_vector_elt_var_v8i32

body: |
  bb.0:
    liveins: $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
    ; CHECK-LABEL: name: extract_vector_elt_var_v8i32
    ; CHECK: [[COPY:%[0-9]+]]:_(<8 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<8 x s32>), [[COPY1]](s32)
    ; CHECK: $vgpr0 = COPY [[EVEC]](s32)
    %0:_(<8 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
    %1:_(s32) = COPY $vgpr2
    %2:_(s32) = G_EXTRACT_VECTOR_ELT %0, %1
    $vgpr0 = COPY %2
...
