Compiler projects using llvm
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=aarch64-linux-gnu -O0 -run-pass=legalizer -global-isel-abort=0 -verify-machineinstrs %s -o - | FileCheck %s

---
name:            test_eve_1
body: |
  bb.0:
    liveins: $q0
    ; CHECK-LABEL: name: test_eve_1
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s64) = G_EXTRACT_VECTOR_ELT [[COPY]](<2 x s64>), [[C]](s64)
    ; CHECK-NEXT: $x0 = COPY [[EVEC]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<2 x s64>) = COPY $q0
    %1:_(s32) = G_CONSTANT i32 1
    %2:_(s64) = G_EXTRACT_VECTOR_ELT %0(<2 x s64>), %1(s32)
    $x0 = COPY %2(s64)
    RET_ReallyLR
...
---
name:            test_eve_v2s1
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v2s1
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<2 x s64>) = G_ICMP intpred(eq), [[COPY]](<2 x s64>), [[COPY1]]
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s64) = G_EXTRACT_VECTOR_ELT [[ICMP]](<2 x s64>), [[COPY2]](s64)
    ; CHECK-NEXT: $x0 = COPY [[EVEC]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<2 x s64>) = COPY $q0
    %1:_(<2 x s64>) = COPY $q1
    %2:_(s64) = COPY $x0
    %3:_(<2 x s1>) = G_ICMP intpred(eq), %0(<2 x s64>), %1
    %4:_(s1) = G_EXTRACT_VECTOR_ELT %3:_(<2 x s1>), %2:_(s64)
    %5:_(s64) = G_ANYEXT %4(s1)
    $x0 = COPY %5(s64)
    RET_ReallyLR
...
---
name:            test_eve_v4s1
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v4s1
    ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<4 x s32>) = G_ICMP intpred(eq), [[COPY]](<4 x s32>), [[COPY1]]
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[ICMP]](<4 x s32>), [[COPY2]](s64)
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[EVEC]](s32)
    ; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<4 x s32>) = COPY $q0
    %1:_(<4 x s32>) = COPY $q1
    %2:_(s64) = COPY $x0
    %3:_(<4 x s1>) = G_ICMP intpred(eq), %0(<4 x s32>), %1
    %4:_(s1) = G_EXTRACT_VECTOR_ELT %3:_(<4 x s1>), %2:_(s64)
    %5:_(s64) = G_ANYEXT %4(s1)
    $x0 = COPY %5(s64)
    RET_ReallyLR
...
---
name:            test_eve_v8s1
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v8s1
    ; CHECK: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<8 x s16>) = COPY $q1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<8 x s16>) = G_ICMP intpred(eq), [[COPY]](<8 x s16>), [[COPY1]]
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s16) = G_EXTRACT_VECTOR_ELT [[ICMP]](<8 x s16>), [[COPY2]](s64)
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[EVEC]](s16)
    ; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<8 x s16>) = COPY $q0
    %1:_(<8 x s16>) = COPY $q1
    %2:_(s64) = COPY $x0
    %3:_(<8 x s1>) = G_ICMP intpred(eq), %0(<8 x s16>), %1
    %4:_(s1) = G_EXTRACT_VECTOR_ELT %3:_(<8 x s1>), %2:_(s64)
    %5:_(s64) = G_ANYEXT %4(s1)
    $x0 = COPY %5(s64)
    RET_ReallyLR
...
---
name:            test_eve_v16s1
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v16s1
    ; CHECK: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<16 x s8>) = COPY $q1
    ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<16 x s8>) = G_ICMP intpred(eq), [[COPY]](<16 x s8>), [[COPY1]]
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s8) = G_EXTRACT_VECTOR_ELT [[ICMP]](<16 x s8>), [[COPY2]](s64)
    ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[EVEC]](s8)
    ; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<16 x s8>) = COPY $q0
    %1:_(<16 x s8>) = COPY $q1
    %2:_(s64) = COPY $x0
    %3:_(<16 x s1>) = G_ICMP intpred(eq), %0(<16 x s8>), %1
    %4:_(s1) = G_EXTRACT_VECTOR_ELT %3:_(<16 x s1>), %2:_(s64)
    %5:_(s64) = G_ANYEXT %4(s1)
    $x0 = COPY %5(s64)
    RET_ReallyLR
...
---
name:            test_eve_v2p0
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v2p0
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x p0>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x0
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(p0) = G_EXTRACT_VECTOR_ELT [[COPY]](<2 x p0>), [[COPY1]](s64)
    ; CHECK-NEXT: $x0 = COPY [[EVEC]](p0)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<2 x p0>) = COPY $q0
    %2:_(s64) = COPY $x0
    %3:_(p0) = G_EXTRACT_VECTOR_ELT %0:_(<2 x p0>), %2:_(s64)
    $x0 = COPY %3(p0)
    RET_ReallyLR
...
---
name:            test_eve_v4s64
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v4s64
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s64) = G_EXTRACT_VECTOR_ELT [[COPY]](<2 x s64>), [[C]](s64)
    ; CHECK-NEXT: $x0 = COPY [[EVEC]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<2 x s64>) = COPY $q0
    %1:_(<2 x s64>) = COPY $q1
    %concat:_(<4 x s64>) = G_CONCAT_VECTORS %0(<2 x s64>), %1(<2 x s64>)
    %idx:_(s32) = G_CONSTANT i32 1
    %idxprom:_(s64) = G_SEXT %idx(s32)
    %3:_(s64) = G_EXTRACT_VECTOR_ELT %concat:_(<4 x s64>), %idxprom:_(s64)
    $x0 = COPY %3(s64)
    RET_ReallyLR
...
---
name:            test_eve_v4s64_unknown_idx
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v4s64_unknown_idx
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
    ; CHECK-NEXT: %idx:_(s64) = COPY $x0
    ; CHECK-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
    ; CHECK-NEXT: G_STORE [[COPY]](<2 x s64>), [[FRAME_INDEX]](p0) :: (store (<2 x s64>) into %stack.0, align 32)
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
    ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[FRAME_INDEX]], [[C]](s64)
    ; CHECK-NEXT: G_STORE [[COPY1]](<2 x s64>), [[PTR_ADD]](p0) :: (store (<2 x s64>) into %stack.0 + 16, basealign 32)
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 3
    ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND %idx, [[C1]]
    ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
    ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[AND]], [[C2]]
    ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[FRAME_INDEX]], [[MUL]](s64)
    ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[PTR_ADD1]](p0) :: (load (s64))
    ; CHECK-NEXT: $x0 = COPY [[LOAD]](s64)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<2 x s64>) = COPY $q0
    %1:_(<2 x s64>) = COPY $q1
    %concat:_(<4 x s64>) = G_CONCAT_VECTORS %0(<2 x s64>), %1(<2 x s64>)
    %idx:_(s64) = COPY $x0
    %3:_(s64) = G_EXTRACT_VECTOR_ELT %concat:_(<4 x s64>), %idx:_(s64)
    $x0 = COPY %3(s64)
    RET_ReallyLR
...
---
name:            test_eve_v8s32
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v8s32
    ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[COPY]](<4 x s32>), [[C]](s64)
    ; CHECK-NEXT: $w0 = COPY [[EVEC]](s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<4 x s32>) = COPY $q0
    %1:_(<4 x s32>) = COPY $q1
    %concat:_(<8 x s32>) = G_CONCAT_VECTORS %0(<4 x s32>), %1(<4 x s32>)
    %idx:_(s32) = G_CONSTANT i32 1
    %idxprom:_(s64) = G_SEXT %idx(s32)
    %3:_(s32) = G_EXTRACT_VECTOR_ELT %concat:_(<8 x s32>), %idxprom:_(s64)
    $w0 = COPY %3(s32)
    RET_ReallyLR
...
---
name:            test_eve_v16s16
body: |
  bb.0:
    liveins: $q0, $q1, $x0
    ; CHECK-LABEL: name: test_eve_v16s16
    ; CHECK: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q1
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s16) = G_EXTRACT_VECTOR_ELT [[COPY]](<8 x s16>), [[C]](s64)
    ; CHECK-NEXT: %ext:_(s32) = G_ANYEXT [[EVEC]](s16)
    ; CHECK-NEXT: $w0 = COPY %ext(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(<8 x s16>) = COPY $q0
    %1:_(<8 x s16>) = COPY $q1
    %concat:_(<16 x s16>) = G_CONCAT_VECTORS %0(<8 x s16>), %1(<8 x s16>)
    %idx:_(s32) = G_CONSTANT i32 9
    %idxprom:_(s64) = G_SEXT %idx(s32)
    %3:_(s16) = G_EXTRACT_VECTOR_ELT %concat:_(<16 x s16>), %idxprom:_(s64)
    %ext:_(s32) = G_ANYEXT %3
    $w0 = COPY %ext(s32)
    RET_ReallyLR
...
---
name:            test_eve_v4p0
body: |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: test_eve_v4p0
    ; CHECK: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x p0>) = G_BUILD_VECTOR [[DEF]](p0), [[DEF]](p0)
    ; CHECK-NEXT: %idx:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: %eve:_(p0) = G_EXTRACT_VECTOR_ELT [[BUILD_VECTOR]](<2 x p0>), %idx(s64)
    ; CHECK-NEXT: $x0 = COPY %eve(p0)
    ; CHECK-NEXT: RET_ReallyLR
    %vec:_(<4 x p0>) = G_IMPLICIT_DEF
    %idx:_(s64) = G_CONSTANT i64 1
    %eve:_(p0) = G_EXTRACT_VECTOR_ELT %vec:_(<4 x p0>), %idx:_(s64)
    $x0 = COPY %eve(p0)
    RET_ReallyLR
...
---
name:            cant_legalize_different_address_spaces
body: |
  bb.0:
    liveins: $x0
    ; Make sure that the pointer legalization rules don't apply when we have
    ; different address spaces.

    ; CHECK-LABEL: name: cant_legalize_different_address_spaces
    ; CHECK: %vec:_(<4 x p1>) = G_IMPLICIT_DEF
    ; CHECK-NEXT: %idx:_(s64) = G_CONSTANT i64 1
    ; CHECK-NEXT: %eve:_(p0) = G_EXTRACT_VECTOR_ELT %vec(<4 x p1>), %idx(s64)
    ; CHECK-NEXT: $x0 = COPY %eve(p0)
    ; CHECK-NEXT: RET_ReallyLR
    %vec:_(<4 x p1>) = G_IMPLICIT_DEF
    %idx:_(s64) = G_CONSTANT i64 1
    %eve:_(p0) = G_EXTRACT_VECTOR_ELT %vec:_(<4 x p1>), %idx:_(s64)
    $x0 = COPY %eve(p0)
    RET_ReallyLR