llvm/llvm/test/CodeGen/AArch64/GlobalISel/combine-insert-vec-elt.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - -mtriple=aarch64 -run-pass=aarch64-prelegalizer-combiner %s | FileCheck %s
---
name:            test_combine_consecutive
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: test_combine_consecutive
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[COPY]](s32), [[COPY1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(<2 x s32>) = G_IMPLICIT_DEF
    %7:_(s64) = G_CONSTANT i64 0
    %8:_(s64) = G_CONSTANT i64 1
    %3:_(<2 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %7(s64)
    %4:_(<2 x s32>) = G_INSERT_VECTOR_ELT %3, %1(s32), %8(s64)
    $x0 = COPY %4
...
---
name:            test_combine_diff_order
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: test_combine_diff_order
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[COPY1]](s32), [[COPY]](s32)
    ; CHECK-NEXT: $x0 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(<2 x s32>) = G_IMPLICIT_DEF
    %7:_(s64) = G_CONSTANT i64 1
    %8:_(s64) = G_CONSTANT i64 0
    %3:_(<2 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %7(s64)
    %4:_(<2 x s32>) = G_INSERT_VECTOR_ELT %3, %1(s32), %8(s64)
    $x0 = COPY %4
...
---
name:            test_combine_insert_vec_build_vec_idx_1
body:             |
  bb.1:
    liveins: $w0, $w1, $w2, $w3

    ; CHECK-LABEL: name: test_combine_insert_vec_build_vec_idx_1
    ; CHECK: liveins: $w0, $w1, $w2, $w3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w2
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w3
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[COPY]](s32), [[COPY]](s32), [[COPY1]](s32), [[COPY2]](s32)
    ; CHECK-NEXT: $q0 = COPY [[BUILD_VECTOR]](<4 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %6:_(s32) = COPY $w2
    %7:_(s32) = COPY $w3
    %2:_(<4 x s32>) = G_BUILD_VECTOR %0, %1, %6, %7
    %3:_(s64) = G_CONSTANT i64 1
    %4:_(<4 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %3(s64)
    $q0 = COPY %4
...
---
name:            test_combine_insert_vec_build_vec_idx_oob
body:             |
  bb.1:
    liveins: $w0, $w1, $w2, $w3

    ; CHECK-LABEL: name: test_combine_insert_vec_build_vec_idx_oob
    ; CHECK: liveins: $w0, $w1, $w2, $w3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s32>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: $q0 = COPY [[DEF]](<4 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %6:_(s32) = COPY $w2
    %7:_(s32) = COPY $w3
    %2:_(<4 x s32>) = G_BUILD_VECTOR %0, %1, %6, %7
    %3:_(s64) = G_CONSTANT i64 4
    %4:_(<4 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %3(s64)
    $q0 = COPY %4
...
---
name:            test_combine_insert_vec_build_vec_variable
body:             |
  bb.1:
    liveins: $x0, $w1, $w2, $w3

    ; CHECK-LABEL: name: test_combine_insert_vec_build_vec_variable
    ; CHECK: liveins: $x0, $w1, $w2, $w3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
    ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $w3
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[COPY1]](s32), [[COPY1]](s32), [[COPY2]](s32), [[COPY3]](s32)
    ; CHECK-NEXT: [[IVEC:%[0-9]+]]:_(<4 x s32>) = G_INSERT_VECTOR_ELT [[BUILD_VECTOR]], [[COPY1]](s32), [[COPY]](s64)
    ; CHECK-NEXT: $q0 = COPY [[IVEC]](<4 x s32>)
    %0:_(s64) = COPY $x0
    %1:_(s32) = COPY $w1
    %6:_(s32) = COPY $w2
    %7:_(s32) = COPY $w3
    %2:_(<4 x s32>) = G_BUILD_VECTOR %1, %1, %6, %7
    %3:_(s64) = COPY %0
    %4:_(<4 x s32>) = G_INSERT_VECTOR_ELT %2, %1(s32), %3(s64)
    $q0 = COPY %4
...
---
name:            test_combine_multiple_same_idx_1
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: test_combine_multiple_same_idx_1
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[COPY]](s32), [[COPY1]](s32)
    ; CHECK-NEXT: $x0 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(<2 x s32>) = G_IMPLICIT_DEF
    %7:_(s64) = G_CONSTANT i64 0
    %8:_(s64) = G_CONSTANT i64 1
    %3:_(<2 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %7(s64)
    %4:_(<2 x s32>) = G_INSERT_VECTOR_ELT %3, %1(s32), %8(s64)
    %5:_(<2 x s32>) = G_INSERT_VECTOR_ELT %4, %1(s32), %8(s64)
    $x0 = COPY %5
...
---
name:            test_combine_multiple_same_idx_2
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: test_combine_multiple_same_idx_2
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[COPY]](s32), [[COPY]](s32)
    ; CHECK-NEXT: $x0 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(<2 x s32>) = G_IMPLICIT_DEF
    %7:_(s64) = G_CONSTANT i64 0
    %8:_(s64) = G_CONSTANT i64 1
    %3:_(<2 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %7(s64)
    %4:_(<2 x s32>) = G_INSERT_VECTOR_ELT %3, %1(s32), %7(s64)
    %5:_(<2 x s32>) = G_INSERT_VECTOR_ELT %4, %1(s32), %8(s64)
    $x0 = COPY %5
...
---
name:            test_combine_missing_idx
body:             |
  bb.1:
    liveins: $w0, $w1

    ; CHECK-LABEL: name: test_combine_missing_idx
    ; CHECK: liveins: $w0, $w1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[COPY]](s32), [[DEF]](s32), [[COPY1]](s32), [[COPY]](s32)
    ; CHECK-NEXT: $q0 = COPY [[BUILD_VECTOR]](<4 x s32>)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(<4 x s32>) = G_IMPLICIT_DEF
    %7:_(s64) = G_CONSTANT i64 0
    %8:_(s64) = G_CONSTANT i64 2
    %9:_(s64) = G_CONSTANT i64 3
    %10:_(<4 x s32>) = G_INSERT_VECTOR_ELT %2, %0(s32), %7(s64)
    %11:_(<4 x s32>) = G_INSERT_VECTOR_ELT %10, %1(s32), %8(s64)
    %12:_(<4 x s32>) = G_INSERT_VECTOR_ELT %11, %0(s32), %9(s64)
    $q0 = COPY %12
...
---
name:            test_combine_negative_idx
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_combine_negative_idx
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %4:_(s8) = G_CONSTANT i8 -128
    %5:_(s64) = G_CONSTANT i64 -1
    %0:_(p0) = COPY $x0
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %2, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...
---
name:            test_idx_undef
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_idx_undef
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %4:_(s8) = G_CONSTANT i8 -128
    %5:_(s64) = G_IMPLICIT_DEF
    %0:_(p0) = COPY $x0
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %2, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...
---
name:            test_elt_undef
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_elt_undef
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 127
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s8) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<32 x s8>) = G_BUILD_VECTOR [[C]](s8), [[C]](s8), [[C]](s8), [[DEF]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8)
    ; CHECK-NEXT: G_STORE [[BUILD_VECTOR]](<32 x s8>), [[COPY]](p0) :: (store (<32 x s8>))
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %4:_(s8) = G_IMPLICIT_DEF
    %5:_(s64) = G_CONSTANT i64 3
    %0:_(p0) = COPY $x0
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %2, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...
---
name:            test_elt_undef_with_freeze
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_elt_undef_with_freeze
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 127
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s8) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<32 x s8>) = G_BUILD_VECTOR [[C]](s8), [[C]](s8), [[C]](s8), [[DEF]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8)
    ; CHECK-NEXT: G_STORE [[BUILD_VECTOR]](<32 x s8>), [[COPY]](p0) :: (store (<32 x s8>))
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %4:_(s8) = G_IMPLICIT_DEF
    %5:_(s64) = G_CONSTANT i64 3
    %0:_(p0) = COPY $x0
    %9:_(<32 x s8>) = G_FREEZE %2
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %9, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...
---
name:            test_insert_extract
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_insert_extract
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 127
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<32 x s8>) = G_BUILD_VECTOR [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8)
    ; CHECK-NEXT: G_STORE [[BUILD_VECTOR]](<32 x s8>), [[COPY]](p0) :: (store (<32 x s8>))
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %5:_(s64) = G_CONSTANT i64 3
    %4:_(s8) = G_EXTRACT_VECTOR_ELT %2, %5
    %0:_(p0) = COPY $x0
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %2, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...
---
name:            test_idx_oob
body:             |
  bb.1:
    liveins: $x0
    ; CHECK-LABEL: name: test_idx_oob
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: RET_ReallyLR
    %3:_(s8) = G_CONSTANT i8 127
    %2:_(<32 x s8>) = G_BUILD_VECTOR %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8), %3(s8)
    %4:_(s8) = G_CONSTANT i8 -128
    %5:_(s64) = G_CONSTANT i64 1024
    %0:_(p0) = COPY $x0
    %1:_(<32 x s8>) = G_INSERT_VECTOR_ELT %2, %4(s8), %5(s64)
    G_STORE %1(<32 x s8>), %0(p0) :: (store (<32 x s8>))
    RET_ReallyLR

...