1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -run-pass=prologepilog %s -o - | FileCheck %s
3
4# The wrong form of scavengeRegister was used, so it wasn't accounting
5# for the iterator passed to eliminateFrameIndex. It was instead using
6# the current iterator in the scavenger, which was not yet set if the
7# spill was the first instruction in the block.
8
9---
10name: scavenge_register_position
11tracksRegLiveness: true
12
13# Force a frame larger than the immediate field with a large alignment.
14stack:
15  - { id: 0, type: default, offset: 4096, size: 4, alignment: 8192 }
16
17machineFunctionInfo:
18  isEntryFunction: true
19  scratchRSrcReg:  $sgpr0_sgpr1_sgpr2_sgpr3
20  stackPtrOffsetReg:  $sgpr32
21  argumentInfo:
22    privateSegmentWaveByteOffset: { reg: '$sgpr4' }
23
24body:             |
25  ; CHECK-LABEL: name: scavenge_register_position
26  ; CHECK: bb.0:
27  ; CHECK:   successors: %bb.1(0x80000000)
28  ; CHECK:   liveins: $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4
29  ; CHECK:   $sgpr0 = S_ADD_U32 $sgpr0, $sgpr4, implicit-def $scc, implicit-def $sgpr0_sgpr1_sgpr2_sgpr3
30  ; CHECK:   $sgpr1 = S_ADDC_U32 $sgpr1, 0, implicit-def $scc, implicit $scc, implicit-def $sgpr0_sgpr1_sgpr2_sgpr3
31  ; CHECK:   $sgpr5 = S_MOV_B32 524288
32  ; CHECK:   $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, killed $sgpr5, 0, 0, 0, 0, 0, 0, implicit $exec :: (load 4 from %stack.0, align 8192, addrspace 5)
33  ; CHECK:   S_BRANCH %bb.1
34  ; CHECK: bb.1:
35  ; CHECK:   liveins: $sgpr0_sgpr1_sgpr2_sgpr3
36  ; CHECK:   $sgpr4 = S_MOV_B32 524288
37  ; CHECK:   $vgpr0 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, killed $sgpr4, 0, 0, 0, 0, 0, 0, implicit $exec :: (load 4 from %stack.0, align 8192, addrspace 5)
38  ; CHECK:   S_ENDPGM 0, implicit $vgpr0
39  bb.0:
40    $vgpr0 = SI_SPILL_V32_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 4 from %stack.0, addrspace 5)
41    S_BRANCH %bb.1
42
43  bb.1:
44    $vgpr0 = SI_SPILL_V32_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 4 from %stack.0, addrspace 5)
45    S_ENDPGM 0, implicit $vgpr0
46...
47