Skip to content

Commit d37ce53

Browse files
committed
AMDGPU: Set StackPointerRegisterToSaveRestore
This will enable selecting non-entry block allocas. Skip the SP write check in the base isSchedulingBoundary implementation to preserve the previous scheduling behavior and avoid test churn. It's apparently for compile time reasons, but if we were to use this more work would be needed since in some of the failing tests, we seem to incorrectly get hazard nops inserted.
1 parent a2a3e9f commit d37ce53

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
842842
setTargetDAGCombine(ISD::ATOMIC_LOAD_UMAX);
843843
setTargetDAGCombine(ISD::ATOMIC_LOAD_FADD);
844844

845+
// FIXME: In other contexts we pretend this is a per-function property.
846+
setStackPointerRegisterToSaveRestore(AMDGPU::SGPR32);
847+
845848
setSchedulingPreference(Sched::RegPressure);
846849
}
847850

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,13 +2936,21 @@ static bool changesVGPRIndexingMode(const MachineInstr &MI) {
29362936
bool SIInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
29372937
const MachineBasicBlock *MBB,
29382938
const MachineFunction &MF) const {
2939-
// XXX - Do we want the SP check in the base implementation?
2939+
// Skipping the check for SP writes in the base implementation. The reason it
2940+
// was added was apparently due to compile time concerns.
2941+
//
2942+
// TODO: Do we really want this barrier? It triggers unnecessary hazard nops
2943+
// but is probably avoidable.
2944+
2945+
// Copied from base implementation.
2946+
// Terminators and labels can't be scheduled around.
2947+
if (MI.isTerminator() || MI.isPosition())
2948+
return true;
29402949

29412950
// Target-independent instructions do not have an implicit-use of EXEC, even
29422951
// when they operate on VGPRs. Treating EXEC modifications as scheduling
29432952
// boundaries prevents incorrect movements of such instructions.
2944-
return TargetInstrInfo::isSchedulingBoundary(MI, MBB, MF) ||
2945-
MI.modifiesRegister(AMDGPU::EXEC, &RI) ||
2953+
return MI.modifiesRegister(AMDGPU::EXEC, &RI) ||
29462954
MI.getOpcode() == AMDGPU::S_SETREG_IMM32_B32 ||
29472955
MI.getOpcode() == AMDGPU::S_SETREG_B32 ||
29482956
MI.getOpcode() == AMDGPU::S_DENORM_MODE ||

0 commit comments

Comments
 (0)