llvm/llvm/test/CodeGen/AArch64/GlobalISel/legalize-bswap.mir

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

...
---
name:            bswap_s16
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: bswap_s16
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[COPY]]
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
    ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s64)
    ; CHECK-NEXT: $w0 = COPY [[LSHR]](s32)
    ; CHECK-NEXT: RET_ReallyLR implicit $w0
    %1:_(s32) = COPY $w0
    %0:_(s16) = G_TRUNC %1(s32)
    %2:_(s16) = G_BSWAP %0
    %3:_(s32) = G_ANYEXT %2(s16)
    $w0 = COPY %3(s32)
    RET_ReallyLR implicit $w0
...
---
name:            bswap_s32_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $w0
    ; CHECK-LABEL: name: bswap_s32_legal
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(s32) = COPY $w0
    ; CHECK-NEXT: %bswap:_(s32) = G_BSWAP %copy
    ; CHECK-NEXT: $w0 = COPY %bswap(s32)
    ; CHECK-NEXT: RET_ReallyLR implicit $w0
    %copy:_(s32) = COPY $w0
    %bswap:_(s32) = G_BSWAP %copy
    $w0 = COPY %bswap(s32)
    RET_ReallyLR implicit $w0
...
---
name:            bswap_s64_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: bswap_s64_legal
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(s64) = COPY $x0
    ; CHECK-NEXT: %bswap:_(s64) = G_BSWAP %copy
    ; CHECK-NEXT: $x0 = COPY %bswap(s64)
    ; CHECK-NEXT: RET_ReallyLR implicit $x0
    %copy:_(s64) = COPY $x0
    %bswap:_(s64) = G_BSWAP %copy
    $x0 = COPY %bswap(s64)
    RET_ReallyLR implicit $x0
...
---
name:            bswap_v4s16_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $d0
    ; CHECK-LABEL: name: bswap_v4s16_legal
    ; CHECK: liveins: $d0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(<4 x s16>) = COPY $d0
    ; CHECK-NEXT: %bswap:_(<4 x s16>) = G_BSWAP %copy
    ; CHECK-NEXT: $d0 = COPY %bswap(<4 x s16>)
    ; CHECK-NEXT: RET_ReallyLR implicit $d0
    %copy:_(<4 x s16>) = COPY $d0
    %bswap:_(<4 x s16>) = G_BSWAP %copy
    $d0 = COPY %bswap(<4 x s16>)
    RET_ReallyLR implicit $d0
...
---
name:            bswap_v8s16_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $q0
    ; CHECK-LABEL: name: bswap_v8s16_legal
    ; CHECK: liveins: $q0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(<8 x s16>) = COPY $q0
    ; CHECK-NEXT: %bswap:_(<8 x s16>) = G_BSWAP %copy
    ; CHECK-NEXT: $q0 = COPY %bswap(<8 x s16>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %copy:_(<8 x s16>) = COPY $q0
    %bswap:_(<8 x s16>) = G_BSWAP %copy
    $q0 = COPY %bswap(<8 x s16>)
    RET_ReallyLR implicit $q0
...
---
name:            bswap_v4s32_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $q0
    ; CHECK-LABEL: name: bswap_v4s32_legal
    ; CHECK: liveins: $q0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(<4 x s32>) = COPY $q0
    ; CHECK-NEXT: %bswap:_(<4 x s32>) = G_BSWAP %copy
    ; CHECK-NEXT: $q0 = COPY %bswap(<4 x s32>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %copy:_(<4 x s32>) = COPY $q0
    %bswap:_(<4 x s32>) = G_BSWAP %copy
    $q0 = COPY %bswap(<4 x s32>)
    RET_ReallyLR implicit $q0
...
---
name:            bswap_v2s32_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $d0
    ; CHECK-LABEL: name: bswap_v2s32_legal
    ; CHECK: liveins: $d0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(<2 x s32>) = COPY $d0
    ; CHECK-NEXT: %bswap:_(<2 x s32>) = G_BSWAP %copy
    ; CHECK-NEXT: $d0 = COPY %bswap(<2 x s32>)
    ; CHECK-NEXT: RET_ReallyLR implicit $d0
    %copy:_(<2 x s32>) = COPY $d0
    %bswap:_(<2 x s32>) = G_BSWAP %copy
    $d0 = COPY %bswap(<2 x s32>)
    RET_ReallyLR implicit $d0
...
---
name:            bswap_v2s64_legal
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $q0
    ; CHECK-LABEL: name: bswap_v2s64_legal
    ; CHECK: liveins: $q0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %copy:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: %bswap:_(<2 x s64>) = G_BSWAP %copy
    ; CHECK-NEXT: $q0 = COPY %bswap(<2 x s64>)
    ; CHECK-NEXT: RET_ReallyLR implicit $q0
    %copy:_(<2 x s64>) = COPY $q0
    %bswap:_(<2 x s64>) = G_BSWAP %copy
    $q0 = COPY %bswap(<2 x s64>)
    RET_ReallyLR implicit $q0
...
---
name:            bswap_s80
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: bswap_s80
    ; CHECK: liveins: $x0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
    ; CHECK-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[DEF]]
    ; CHECK-NEXT: [[BSWAP1:%[0-9]+]]:_(s64) = G_BSWAP [[DEF]]
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 48
    ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[BSWAP]], [[C]](s64)
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
    ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[BSWAP1]], [[C1]](s64)
    ; CHECK-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[LSHR]], [[SHL]]
    ; CHECK-NEXT: $x0 = COPY [[OR]](s64)
    ; CHECK-NEXT: RET_ReallyLR implicit $x0
    %val:_(s80) = G_IMPLICIT_DEF
    %bswap:_(s80) = G_BSWAP %val
    %trunc:_(s64) = G_TRUNC %bswap
    $x0 = COPY %trunc(s64)
    RET_ReallyLR implicit $x0
...
---
name:            bswap_v2s48
tracksRegLiveness: true
body:             |
  bb.0:
  liveins: $q0, $x8
    ; CHECK-LABEL: name: bswap_v2s48
    ; CHECK: liveins: $q0, $x8
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x8
    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q0
    ; CHECK-NEXT: [[BSWAP:%[0-9]+]]:_(<2 x s64>) = G_BSWAP [[COPY1]]
    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
    ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[C]](s64), [[C]](s64)
    ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(<2 x s64>) = G_LSHR [[BSWAP]], [[BUILD_VECTOR]](<2 x s64>)
    ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[LSHR]](<2 x s64>)
    ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
    ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:_(s64) = G_LSHR [[UV]], [[C1]](s64)
    ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
    ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C2]](s64)
    ; CHECK-NEXT: G_STORE [[UV]](s64), [[COPY]](p0) :: (store (s32), align 16)
    ; CHECK-NEXT: G_STORE [[LSHR1]](s64), [[PTR_ADD]](p0) :: (store (s16) into unknown-address + 4, align 4)
    ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 6
    ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C3]](s64)
    ; CHECK-NEXT: [[LSHR2:%[0-9]+]]:_(s64) = G_LSHR [[UV1]], [[C1]](s64)
    ; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD1]], [[C2]](s64)
    ; CHECK-NEXT: G_STORE [[UV1]](s64), [[PTR_ADD1]](p0) :: (store (s32) into unknown-address + 6, align 2)
    ; CHECK-NEXT: G_STORE [[LSHR2]](s64), [[PTR_ADD2]](p0) :: (store (s16) into unknown-address + 10)
    ; CHECK-NEXT: RET_ReallyLR
  %1:_(p0) = COPY $x8
  %2:_(<2 x s64>) = COPY $q0
  %0:_(<2 x s48>) = G_TRUNC %2:_(<2 x s64>)
  %bswap:_(<2 x s48>) = G_BSWAP %0
  G_STORE %bswap:_(<2 x s48>), %1:_(p0) :: (store (<2 x s48>), align 16)
  RET_ReallyLR
...