llvm/llvm/test/CodeGen/AArch64/GlobalISel/combine-shufflevector.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s

---
name:            shuffle_concat_1
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1, $x2, $x3

    ; CHECK-LABEL: name: shuffle_concat_1
    ; CHECK: liveins: $x0, $x1, $x2, $x3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p2:_(p0) = COPY $x1
    ; CHECK-NEXT: %p3:_(p0) = COPY $x2
    ; CHECK-NEXT: %p4:_(p0) = COPY $x3
    ; CHECK-NEXT: %a:_(<4 x s8>) = G_LOAD %p4(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %b:_(<4 x s8>) = G_LOAD %p3(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %c:_(<4 x s8>) = G_LOAD %p2(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s8>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: %z:_(<16 x s8>) = G_CONCAT_VECTORS %a(<4 x s8>), %b(<4 x s8>), %c(<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: $q0 = COPY %z(<16 x s8>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(p0) = COPY $x0
    %p2:_(p0) = COPY $x1
    %p3:_(p0) = COPY $x2
    %p4:_(p0) = COPY $x3

    %ImpDef:_(<4 x s8>) = G_IMPLICIT_DEF
    %a:_(<4 x s8>) = G_LOAD %p4:_(p0) :: (load (<4 x s8>))
    %b:_(<4 x s8>) = G_LOAD %p3:_(p0) :: (load (<4 x s8>))
    %c:_(<4 x s8>) = G_LOAD %p2:_(p0) :: (load (<4 x s8>))
    %d:_(<4 x s8>) = G_LOAD %p1:_(p0) :: (load (<4 x s8>))

    %x:_(<16 x s8>) = G_SHUFFLE_VECTOR %a:_(<4 x s8>), %b:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, undef, undef, undef, undef, undef, undef, undef, undef)
    %y:_(<16 x s8>) = G_SHUFFLE_VECTOR %c:_(<4 x s8>), %d:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %z:_(<16 x s8>) = G_SHUFFLE_VECTOR %x:_(<16 x s8>), %y:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, -1, -1, -1, -1)

    $q0 = COPY %z(<16 x s8>)
    RET_ReallyLR implicit $q0
...

---
name:            shuffle_concat_2
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1, $x2, $x3

    ; CHECK-LABEL: name: shuffle_concat_2
    ; CHECK: liveins: $x0, $x1, $x2, $x3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p1:_(p0) = COPY $x0
    ; CHECK-NEXT: %p2:_(p0) = COPY $x1
    ; CHECK-NEXT: %p3:_(p0) = COPY $x2
    ; CHECK-NEXT: %p4:_(p0) = COPY $x3
    ; CHECK-NEXT: %a:_(<4 x s8>) = G_LOAD %p4(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %b:_(<4 x s8>) = G_LOAD %p3(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %c:_(<4 x s8>) = G_LOAD %p2(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %d:_(<4 x s8>) = G_LOAD %p1(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %z:_(<16 x s8>) = G_CONCAT_VECTORS %a(<4 x s8>), %b(<4 x s8>), %c(<4 x s8>), %d(<4 x s8>)
    ; CHECK-NEXT: $q0 = COPY %z(<16 x s8>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(p0) = COPY $x0
    %p2:_(p0) = COPY $x1
    %p3:_(p0) = COPY $x2
    %p4:_(p0) = COPY $x3

    %ImpDef:_(<4 x s8>) = G_IMPLICIT_DEF
    %a:_(<4 x s8>) = G_LOAD %p4:_(p0) :: (load (<4 x s8>))
    %b:_(<4 x s8>) = G_LOAD %p3:_(p0) :: (load (<4 x s8>))
    %c:_(<4 x s8>) = G_LOAD %p2:_(p0) :: (load (<4 x s8>))
    %d:_(<4 x s8>) = G_LOAD %p1:_(p0) :: (load (<4 x s8>))

    %v:_(<16 x s8>) = G_SHUFFLE_VECTOR %a:_(<4 x s8>), %b:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, undef, undef, undef, undef, undef, undef, undef, undef)
    %w:_(<16 x s8>) = G_SHUFFLE_VECTOR %c:_(<4 x s8>), %ImpDef:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %x:_(<16 x s8>) = G_SHUFFLE_VECTOR %v:_(<16 x s8>), %w:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, undef, undef, undef, undef)
    %y:_(<16 x s8>) = G_SHUFFLE_VECTOR %d:_(<4 x s8>), %ImpDef:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %z:_(<16 x s8>) = G_SHUFFLE_VECTOR %x:_(<16 x s8>), %y:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19)

    $q0 = COPY %z(<16 x s8>)
    RET_ReallyLR implicit $q0
...

---
name:            shuffle_concat_3
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1, $x2, $x3

    ; CHECK-LABEL: name: shuffle_concat_3
    ; CHECK: liveins: $x0, $x1, $x2, $x3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p2:_(p0) = COPY $x1
    ; CHECK-NEXT: %p3:_(p0) = COPY $x2
    ; CHECK-NEXT: %p4:_(p0) = COPY $x3
    ; CHECK-NEXT: %a:_(<4 x s8>) = G_LOAD %p4(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %b:_(<4 x s8>) = G_LOAD %p3(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %c:_(<4 x s8>) = G_LOAD %p2(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s8>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<16 x s8>) = G_CONCAT_VECTORS %a(<4 x s8>), %b(<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: [[CONCAT_VECTORS1:%[0-9]+]]:_(<16 x s8>) = G_CONCAT_VECTORS %c(<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: %z:_(<16 x s8>) = G_SHUFFLE_VECTOR [[CONCAT_VECTORS]](<16 x s8>), [[CONCAT_VECTORS1]], shufflemask(0, undef, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, undef, undef, undef, undef)
    ; CHECK-NEXT: $q0 = COPY %z(<16 x s8>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(p0) = COPY $x0
    %p2:_(p0) = COPY $x1
    %p3:_(p0) = COPY $x2
    %p4:_(p0) = COPY $x3

    %ImpDef:_(<4 x s8>) = G_IMPLICIT_DEF
    %a:_(<4 x s8>) = G_LOAD %p4:_(p0) :: (load (<4 x s8>))
    %b:_(<4 x s8>) = G_LOAD %p3:_(p0) :: (load (<4 x s8>))
    %c:_(<4 x s8>) = G_LOAD %p2:_(p0) :: (load (<4 x s8>))
    %d:_(<4 x s8>) = G_LOAD %p1:_(p0) :: (load (<4 x s8>))

    %x:_(<16 x s8>) = G_SHUFFLE_VECTOR %a:_(<4 x s8>), %b:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, undef, undef, undef, undef, undef, undef, undef, undef)
    %y:_(<16 x s8>) = G_SHUFFLE_VECTOR %c:_(<4 x s8>), %d:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %z:_(<16 x s8>) = G_SHUFFLE_VECTOR %x:_(<16 x s8>), %y:_, shufflemask(0, -1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, -1, -1, -1, -1)

    $q0 = COPY %z(<16 x s8>)
    RET_ReallyLR implicit $q0
...

---
name:            shuffle_concat_4
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1, $x2, $x3

    ; CHECK-LABEL: name: shuffle_concat_4
    ; CHECK: liveins: $x0, $x1, $x2, $x3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p2:_(p0) = COPY $x1
    ; CHECK-NEXT: %p4:_(p0) = COPY $x3
    ; CHECK-NEXT: %a:_(<4 x s8>) = G_LOAD %p4(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %c:_(<4 x s8>) = G_LOAD %p2(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s8>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: %z:_(<16 x s8>) = G_CONCAT_VECTORS %a(<4 x s8>), [[DEF]](<4 x s8>), %c(<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: $q0 = COPY %z(<16 x s8>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(p0) = COPY $x0
    %p2:_(p0) = COPY $x1
    %p3:_(p0) = COPY $x2
    %p4:_(p0) = COPY $x3

    %ImpDef:_(<4 x s8>) = G_IMPLICIT_DEF
    %a:_(<4 x s8>) = G_LOAD %p4:_(p0) :: (load (<4 x s8>))
    %b:_(<4 x s8>) = G_LOAD %p3:_(p0) :: (load (<4 x s8>))
    %c:_(<4 x s8>) = G_LOAD %p2:_(p0) :: (load (<4 x s8>))
    %d:_(<4 x s8>) = G_LOAD %p1:_(p0) :: (load (<4 x s8>))

    %x:_(<16 x s8>) = G_SHUFFLE_VECTOR %a:_(<4 x s8>), %b:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, undef, undef, undef, undef, undef, undef, undef, undef)
    %y:_(<16 x s8>) = G_SHUFFLE_VECTOR %c:_(<4 x s8>), %d:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %z:_(<16 x s8>) = G_SHUFFLE_VECTOR %x:_(<16 x s8>), %y:_, shufflemask(0, 1, 2, 3, -1, -1, -1, -1, 16, 17, 18, 19, -1, -1, -1, -1)

    $q0 = COPY %z(<16 x s8>)
    RET_ReallyLR implicit $q0
...

---
name:            shuffle_concat_5
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0, $x1, $x2, $x3

    ; CHECK-LABEL: name: shuffle_concat_5
    ; CHECK: liveins: $x0, $x1, $x2, $x3
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p2:_(p0) = COPY $x1
    ; CHECK-NEXT: %p3:_(p0) = COPY $x2
    ; CHECK-NEXT: %p4:_(p0) = COPY $x3
    ; CHECK-NEXT: %a:_(<4 x s8>) = G_LOAD %p4(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %b:_(<4 x s8>) = G_LOAD %p3(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: %c:_(<4 x s8>) = G_LOAD %p2(p0) :: (load (<4 x s8>))
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s8>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<16 x s8>) = G_CONCAT_VECTORS %a(<4 x s8>), %b(<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: [[CONCAT_VECTORS1:%[0-9]+]]:_(<16 x s8>) = G_CONCAT_VECTORS %c(<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>), [[DEF]](<4 x s8>)
    ; CHECK-NEXT: %z:_(<16 x s8>) = G_SHUFFLE_VECTOR [[CONCAT_VECTORS]](<16 x s8>), [[CONCAT_VECTORS1]], shufflemask(undef, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, undef, undef, undef, undef)
    ; CHECK-NEXT: $q0 = COPY %z(<16 x s8>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(p0) = COPY $x0
    %p2:_(p0) = COPY $x1
    %p3:_(p0) = COPY $x2
    %p4:_(p0) = COPY $x3

    %ImpDef:_(<4 x s8>) = G_IMPLICIT_DEF
    %a:_(<4 x s8>) = G_LOAD %p4:_(p0) :: (load (<4 x s8>))
    %b:_(<4 x s8>) = G_LOAD %p3:_(p0) :: (load (<4 x s8>))
    %c:_(<4 x s8>) = G_LOAD %p2:_(p0) :: (load (<4 x s8>))
    %d:_(<4 x s8>) = G_LOAD %p1:_(p0) :: (load (<4 x s8>))

    %x:_(<16 x s8>) = G_SHUFFLE_VECTOR %a:_(<4 x s8>), %b:_, shufflemask(0, 1, 2, 3, 4, 5, 6, 7, undef, undef, undef, undef, undef, undef, undef, undef)
    %y:_(<16 x s8>) = G_SHUFFLE_VECTOR %c:_(<4 x s8>), %d:_, shufflemask(0, 1, 2, 3, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
    %z:_(<16 x s8>) = G_SHUFFLE_VECTOR %x:_(<16 x s8>), %y:_, shufflemask(-1, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, -1, -1, -1, -1)

    $q0 = COPY %z(<16 x s8>)
    RET_ReallyLR implicit $q0
...

---
name:            single_vector_to_copy
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $q0, $q1

    ; CHECK-LABEL: name: single_vector_to_copy
    ; CHECK: liveins: $q0, $q1
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %p1:_(<4 x s32>) = COPY $q0
    ; CHECK-NEXT: %p2:_(<4 x s32>) = COPY $q1
    ; CHECK-NEXT: $q0 = COPY %p1(<4 x s32>)
    ; CHECK-NEXT: $q1 = COPY %p2(<4 x s32>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %p1:_(<4 x s32>) = COPY $q0
    %p2:_(<4 x s32>) = COPY $q1

    %a:_(<8 x s32>) = G_CONCAT_VECTORS %p1:_(<4 x s32>), %p2:_(<4 x s32>)

    %x:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(0, 1, 2, 3)
    %y:_(<4 x s32>) = G_SHUFFLE_VECTOR %a:_(<8 x s32>), %a:_, shufflemask(4, 5, 6, 7)

    $q0 = COPY %x(<4 x s32>)
    $q1 = COPY %y(<4 x s32>)
    RET_ReallyLR implicit $q0
...