Compiler projects using llvm
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck --check-prefix=GCN %s
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck --check-prefix=GCN %s

---
name:            bfe_and_lshr_s32
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0

    ; GCN-LABEL: name: bfe_and_lshr_s32
    ; GCN: liveins: $vgpr0
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
    ; GCN-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; GCN-NEXT: [[UBFX:%[0-9]+]]:_(s32) = G_UBFX [[COPY]], [[C1]](s32), [[C]]
    ; GCN-NEXT: $vgpr0 = COPY [[UBFX]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = G_CONSTANT i32 8
    %2:_(s32) = G_LSHR %0, %1(s32)
    %3:_(s32) = G_CONSTANT i32 31
    %4:_(s32) = G_AND %2, %3
    $vgpr0 = COPY %4(s32)

...

---
name:            bfe_and_lshr_s64
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0_vgpr1

    ; GCN-LABEL: name: bfe_and_lshr_s64
    ; GCN: liveins: $vgpr0_vgpr1
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 10
    ; GCN-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; GCN-NEXT: [[UBFX:%[0-9]+]]:_(s64) = G_UBFX [[COPY]], [[C1]](s32), [[C]]
    ; GCN-NEXT: $vgpr0_vgpr1 = COPY [[UBFX]](s64)
    %0:_(s64) = COPY $vgpr0_vgpr1
    %1:_(s32) = G_CONSTANT i32 8
    %2:_(s64) = G_LSHR %0, %1(s32)
    %3:_(s64) = G_CONSTANT i64 1023
    %4:_(s64) = G_AND %2, %3
    $vgpr0_vgpr1 = COPY %4(s64)

...

---
name:            toobig_and_lshr_s32
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0

    ; GCN-LABEL: name: toobig_and_lshr_s32
    ; GCN: liveins: $vgpr0
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 28
    ; GCN-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s32)
    ; GCN-NEXT: $vgpr0 = COPY [[LSHR]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = G_CONSTANT i32 28
    %2:_(s32) = G_LSHR %0, %1(s32)
    %3:_(s32) = G_CONSTANT i32 511
    %4:_(s32) = G_AND %2, %3
    $vgpr0 = COPY %4(s32)

...

---
name:            bfe_and_ashr_s32
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0

    ; GCN-LABEL: name: bfe_and_ashr_s32
    ; GCN: liveins: $vgpr0
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; GCN-NEXT: [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[C]](s32)
    ; GCN-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 31
    ; GCN-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ASHR]], [[C1]]
    ; GCN-NEXT: $vgpr0 = COPY [[AND]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = G_CONSTANT i32 8
    %2:_(s32) = G_ASHR %0, %1(s32)
    %3:_(s32) = G_CONSTANT i32 31
    %4:_(s32) = G_AND %2, %3
    $vgpr0 = COPY %4(s32)

...

---
name:            bfe_lshr_and_s32
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0

    ; GCN-LABEL: name: bfe_lshr_and_s32
    ; GCN: liveins: $vgpr0
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
    ; GCN-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; GCN-NEXT: [[UBFX:%[0-9]+]]:_(s32) = G_UBFX [[COPY]], [[C1]](s32), [[C]]
    ; GCN-NEXT: $vgpr0 = COPY [[UBFX]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = G_CONSTANT i32 7936 ; 31 << 8
    %2:_(s32) = G_AND %0, %1
    %3:_(s32) = G_CONSTANT i32 8
    %4:_(s32) = G_LSHR %2, %3(s32)
    $vgpr0 = COPY %4(s32)

...

---
name:            bfe_lshr_and_s64
legalized:       true
tracksRegLiveness: true

body: |
  bb.0.entry:
  liveins: $vgpr0_vgpr1

    ; GCN-LABEL: name: bfe_lshr_and_s64
    ; GCN: liveins: $vgpr0_vgpr1
    ; GCN-NEXT: {{  $}}
    ; GCN-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
    ; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 10
    ; GCN-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; GCN-NEXT: [[UBFX:%[0-9]+]]:_(s64) = G_UBFX [[COPY]], [[C1]](s32), [[C]]
    ; GCN-NEXT: $vgpr0_vgpr1 = COPY [[UBFX]](s64)
    %0:_(s64) = COPY $vgpr0_vgpr1
    %1:_(s64) = G_CONSTANT i64 261888 ; 1023 << 8
    %2:_(s64) = G_AND %0, %1
    %3:_(s32) = G_CONSTANT i32 8
    %4:_(s64) = G_LSHR %2, %3(s32)
    $vgpr0_vgpr1 = COPY %4(s64)

...