Index: lib/Target/AMDGPU/SIFrameLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIFrameLowering.cpp +++ lib/Target/AMDGPU/SIFrameLowering.cpp @@ -121,7 +121,12 @@ unsigned NumPreloaded = MFI->getNumPreloadedSGPRs() / 4; // Skip the last 2 elements because the last one is reserved for VCC, and // this is the 2nd to last element already. - for (MCPhysReg Reg : getAllSGPR128().drop_back(2).slice(NumPreloaded)) { + unsigned Drop = 2; + + if (ST.hasSGPRInitBug()) + Drop = 8; + + for (MCPhysReg Reg : getAllSGPR128().drop_back(Drop).slice(NumPreloaded)) { // Pick the first unallocated one. Make sure we don't clobber the other // reserved input we needed. if (!MRI.isPhysRegUsed(Reg)) {