Index: llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp =================================================================== --- llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp +++ llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp @@ -304,7 +304,9 @@ std::vector Unsched; Unsched.reserve(NumRegionInstrs); + bool SeenLdSt = false; for (auto &I : *this) { + SeenLdSt |= I.mayLoadOrStore(); Unsched.push_back(&I); } @@ -379,6 +381,8 @@ PressureAfter.less(ST, PressureBefore) || !RescheduleRegions[RegionIdx]) { Pressure[RegionIdx] = PressureAfter; + if (!SeenLdSt && (Stage + 1) == UnclusteredReschedule) + RescheduleRegions[RegionIdx] = false; return; } else { LLVM_DEBUG(dbgs() << "New pressure will result in more spilling.\n"); @@ -386,7 +390,8 @@ } LLVM_DEBUG(dbgs() << "Attempting to revert scheduling.\n"); - RescheduleRegions[RegionIdx] = true; + RescheduleRegions[RegionIdx] = SeenLdSt || + (Stage + 1) != UnclusteredReschedule; RegionEnd = RegionBegin; for (MachineInstr *MI : Unsched) { if (MI->isDebugInstr())