llvm/llvm/test/CodeGen/AMDGPU/si-fold-aligned-agprs.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -run-pass=si-fold-operands -verify-machineinstrs -o - %s | FileCheck --check-prefix=GFX90A %s

# Should fold only the aligned agpr copies with their uses.

---
name:            aligned_agpr_64
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_64
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_64_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[DEF]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_64_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_64
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_64
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_64 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_64_align2 = COPY killed [[DEF]]
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_64 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_96_sub0_subg1
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_96_sub0_subg1
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_96_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[DEF]].sub0_sub1, 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_96_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1.sub0_sub1:areg_96_align2
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_96_sub1_sub2
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_96_sub1_sub2
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_96_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_64_align2 = COPY killed [[DEF]].sub1_sub2
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_96_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1.sub1_sub2:areg_96_align2
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_96
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_96
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_96_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX3 [[COPY]], [[DEF]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_96_align2 = IMPLICIT_DEF
    %2:areg_96_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX3 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_96
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_96
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_96 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_96_align2 = COPY killed [[DEF]]
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX3 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_96 = IMPLICIT_DEF
    %2:areg_96_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX3 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_128_sub0_sub1
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_128_sub0_sub1
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[DEF]].sub0_sub1, 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1.sub0_sub1:areg_128_align2
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_128_sub2_sub3
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_128_sub2_sub3
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[DEF]].sub2_sub3, 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1.sub2_sub3:areg_128_align2
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_128_sub1_sub2
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_128_sub1_sub2
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_64_align2 = COPY killed [[DEF]].sub1_sub2
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX2 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_64_align2 = COPY killed %1.sub1_sub2:areg_128_align2
    GLOBAL_STORE_DWORDX2 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_128_sub0_sub1_sub2
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_128_sub0_sub1_sub2
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX3 [[COPY]], [[DEF]].sub0_sub1_sub2, 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_96_align2 = COPY killed %1.sub0_sub1_sub2:areg_128_align2
    GLOBAL_STORE_DWORDX3 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_128_sub1_sub2_sub3
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_128_sub1_sub2_sub3
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_96_align2 = COPY killed [[DEF]].sub1_sub2_sub3
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX3 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_96_align2 = COPY killed %1.sub1_sub2_sub3:areg_128_align2
    GLOBAL_STORE_DWORDX3 %0, %2, 0, 0, implicit $exec
...

---
name:            aligned_agpr_128
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: aligned_agpr_128
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128_align2 = IMPLICIT_DEF
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX4 [[COPY]], [[DEF]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128_align2 = IMPLICIT_DEF
    %2:areg_128_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX4 %0, %2, 0, 0, implicit $exec
...

---
name:            unaligned_agpr_128
tracksRegLiveness: true
body:             |
  bb.0:
    liveins: $vgpr0_vgpr1
    ; GFX90A-LABEL: name: unaligned_agpr_128
    ; GFX90A: liveins: $vgpr0_vgpr1
    ; GFX90A-NEXT: {{  $}}
    ; GFX90A-NEXT: [[COPY:%[0-9]+]]:vreg_64_align2 = COPY $vgpr0_vgpr1
    ; GFX90A-NEXT: [[DEF:%[0-9]+]]:areg_128 = IMPLICIT_DEF
    ; GFX90A-NEXT: [[COPY1:%[0-9]+]]:areg_128_align2 = COPY killed [[DEF]]
    ; GFX90A-NEXT: GLOBAL_STORE_DWORDX4 [[COPY]], [[COPY1]], 0, 0, implicit $exec
    %0:vreg_64_align2 = COPY $vgpr0_vgpr1
    %1:areg_128 = IMPLICIT_DEF
    %2:areg_128_align2 = COPY killed %1
    GLOBAL_STORE_DWORDX4 %0, %2, 0, 0, implicit $exec
...