[llvm] AMDGPU: Default to selecting frame indexes to SGPRs (PR #115060)

Mikael Holmén via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 04:10:14 PST 2024


mikaelholmen wrote:

Hi @arsenm 

Running the testcase local-stack-alloc-block-sp-reference.ll with verifiers on with this patch like
```
llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 < test/CodeGen/AMDGPU/local-stack-alloc-block-sp-reference.ll -verify-machineinstrs
```
fails with
```
# After Prologue/Epilogue Insertion & Frame Finalization
# Machine code for function func_local_stack_offset_uses_sp: NoPHIs, TracksLiveness, NoVRegs, TiedOpsRewritten, TracksDebugUserValues
Frame Objects:
  fi#0: size=4, align=8192, at location [SP+8192]
  fi#1: size=8480, align=4096, at location [SP+12288]
  fi#2: size=4, align=4, at location [SP]
Function Live Ins: $vgpr0, $vgpr1

bb.0.entry:
  successors: %bb.1(0x80000000); %bb.1(100.00%)
  liveins: $sgpr5, $vgpr0, $vgpr1
  $sgpr5 = frame-setup COPY $sgpr33
  $sgpr33 = frame-setup S_ADD_I32 $sgpr32, 524224, implicit-def $scc
  $sgpr33 = frame-setup S_AND_B32 killed $sgpr33, 4294443008, implicit-def dead $scc
  $sgpr32 = frame-setup S_ADD_I32 $sgpr32, 2097152, implicit-def dead $scc
  renamable $vgpr3 = V_LSHRREV_B32_e64 6, $sgpr33, implicit $exec
  renamable $vgpr2 = V_ADD_U32_e64 12352, killed $vgpr3, 0, implicit $exec
  renamable $vgpr3 = V_MOV_B32_e32 0, implicit $exec
  $vgpr4 = V_MOV_B32_e32 8192, implicit $exec
  BUFFER_STORE_DWORD_OFFEN renamable $vgpr3, killed $vgpr4, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr33, 0, 0, 0, implicit $exec :: (volatile store (s32) into %ir.pin.low, align 8192, addrspace 5)
  renamable $sgpr4 = S_MOV_B32 0

bb.1.loadstoreloop:
; predecessors: %bb.0, %bb.1
  successors: %bb.2(0x04000000), %bb.1(0x7c000000); %bb.2(3.12%), %bb.1(96.88%)
  liveins: $sgpr4, $sgpr5, $vgpr2, $vgpr3, $vgpr0_vgpr1:0x000000000000000F
  renamable $vgpr5 = V_LSHRREV_B32_e64 6, $sgpr33, implicit $exec
  renamable $vgpr4 = V_ADD_U32_e64 $sgpr4, killed $vgpr5, 0, implicit $exec
  $vgpr5 = V_MOV_B32_e32 12288, implicit $exec
  renamable $vgpr4 = V_ADD_U32_e64 killed $vgpr5, killed $vgpr4, 0, implicit $exec
  renamable $sgpr4 = S_ADD_I32 killed renamable $sgpr4, 1, implicit-def dead $scc
  S_CMPK_LT_U32 renamable $sgpr4, 8480, implicit-def $scc
  BUFFER_STORE_BYTE_OFFEN renamable $vgpr3, killed renamable $vgpr4, $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, implicit $exec :: (volatile store (s8) into %ir.1, addrspace 5)
  S_CBRANCH_SCC1 %bb.1, implicit killed $scc
  S_BRANCH %bb.2

bb.2.split:
; predecessors: %bb.1
  liveins: $sgpr5, $vgpr2, $vgpr0_vgpr1:0x000000000000000F
  renamable $vgpr4 = V_LSHRREV_B32_e64 6, $sgpr33, implicit $exec
  renamable $vgpr3 = V_ADD_U32_e32 20688, killed $vgpr4, implicit $exec
  renamable $vgpr4 = BUFFER_LOAD_DWORD_OFFEN renamable $vgpr3, $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, implicit $exec :: (volatile dereferenceable load (s32) from %ir.gep.large.offset, align 16, addrspace 5)
  renamable $vgpr5 = BUFFER_LOAD_DWORD_OFFEN renamable $vgpr3, $sgpr0_sgpr1_sgpr2_sgpr3, 0, 4, 0, 0, implicit $exec :: (volatile dereferenceable load (s32) from %ir.gep.large.offset + 4, basealign 16, addrspace 5)
  renamable $vgpr6 = BUFFER_LOAD_DWORD_OFFEN renamable $vgpr2, $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0, 0, 0, implicit $exec :: (volatile dereferenceable load (s32) from %ir.gep.small.offset, align 64, addrspace 5)
  renamable $vgpr7 = BUFFER_LOAD_DWORD_OFFEN renamable $vgpr2, $sgpr0_sgpr1_sgpr2_sgpr3, 0, 4, 0, 0, implicit $exec :: (volatile dereferenceable load (s32) from %ir.gep.small.offset + 4, basealign 64, addrspace 5)
  KILL killed renamable $vgpr2
  KILL killed renamable $vgpr3
  renamable $vgpr2, renamable $vcc = V_ADD_CO_U32_e64 killed $vgpr4, killed $vgpr6, 0, implicit $exec
  renamable $vgpr3, dead renamable $vcc = V_ADDC_U32_e64 killed $vgpr5, killed $vgpr7, killed $vcc, 0, implicit $exec
  GLOBAL_STORE_DWORDX2 killed renamable $vgpr0_vgpr1, killed renamable $vgpr2_vgpr3, 0, 0, implicit $exec :: (volatile store (s64) into %ir.out, addrspace 1)
  $sgpr32 = frame-destroy S_ADD_I32 $sgpr32, -2097152, implicit-def dead $scc
  $sgpr33 = frame-destroy COPY $sgpr5
  SI_RETURN

# End machine code for function func_local_stack_offset_uses_sp.

*** Bad machine code: VOP3 instruction uses literal ***
- function:    func_local_stack_offset_uses_sp
- basic block: %bb.0 entry (0x557d8286b118)
- instruction: renamable $vgpr2 = V_ADD_U32_e64 12352, killed $vgpr3, 0, implicit $exec
LLVM ERROR: Found 1 machine code errors.
```


https://github.com/llvm/llvm-project/pull/115060


More information about the llvm-commits mailing list