[llvm] r279867 - AMDGPU/SI: Use a better method for determining the largest pressure sets
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 14:16:37 PDT 2016
Author: tstellar
Date: Fri Aug 26 16:16:37 2016
New Revision: 279867
URL: http://llvm.org/viewvc/llvm-project?rev=279867&view=rev
Log:
AMDGPU/SI: Use a better method for determining the largest pressure sets
Summary:
There are a few different sgpr pressure sets, but we only care about
the one which covers all of the sgprs. We were using hard-coded
register pressure set names to determine the reg set id for the
biggest sgpr set. However, we were using the wrong name, and this
method is pretty fragile, since the reg pressure set names may
change.
The new method just looks for the pressure set that contains the most
reg units and sets that set as our SGPR pressure set. We've also
adopted the same technique for determining our VGPR pressure set.
Reviewers: arsenm
Subscribers: MatzeB, arsenm, llvm-commits, kzhuravl
Differential Revision: https://reviews.llvm.org/D23687
Modified:
llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp
llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.h
Modified: llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp?rev=279867&r1=279866&r2=279867&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp Fri Aug 26 16:16:37 2016
@@ -1657,8 +1657,8 @@ SIScheduleDAGMI::SIScheduleDAGMI(Machine
SITII = static_cast<const SIInstrInfo*>(TII);
SITRI = static_cast<const SIRegisterInfo*>(TRI);
- VGPRSetID = SITRI->getVGPR32PressureSet();
- SGPRSetID = SITRI->getSGPR32PressureSet();
+ VGPRSetID = SITRI->getVGPRPressureSet();
+ SGPRSetID = SITRI->getSGPRPressureSet();
}
SIScheduleDAGMI::~SIScheduleDAGMI() {
Modified: llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp?rev=279867&r1=279866&r2=279867&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.cpp Fri Aug 26 16:16:37 2016
@@ -95,19 +95,38 @@ SIRegisterInfo::SIRegisterInfo() : AMDGP
VGPRPressureSets(getNumRegPressureSets()) {
unsigned NumRegPressureSets = getNumRegPressureSets();
- SGPR32SetID = NumRegPressureSets;
- VGPR32SetID = NumRegPressureSets;
- for (unsigned i = 0; i < NumRegPressureSets; ++i) {
- if (strncmp("SGPR_32", getRegPressureSetName(i), 7) == 0)
- SGPR32SetID = i;
- else if (strncmp("VGPR_32", getRegPressureSetName(i), 7) == 0)
- VGPR32SetID = i;
+ SGPRSetID = NumRegPressureSets;
+ VGPRSetID = NumRegPressureSets;
+ for (unsigned i = 0; i < NumRegPressureSets; ++i) {
classifyPressureSet(i, AMDGPU::SGPR0, SGPRPressureSets);
classifyPressureSet(i, AMDGPU::VGPR0, VGPRPressureSets);
}
- assert(SGPR32SetID < NumRegPressureSets &&
- VGPR32SetID < NumRegPressureSets);
+
+ // Determine the number of reg units for each pressure set.
+ std::vector<unsigned> PressureSetRegUnits(NumRegPressureSets, 0);
+ for (unsigned i = 0, e = getNumRegUnits(); i != e; ++i) {
+ const int *PSets = getRegUnitPressureSets(i);
+ for (unsigned j = 0; PSets[j] != -1; ++j) {
+ PressureSetRegUnits[PSets[j]]++;
+ }
+ }
+
+ unsigned VGPRMax = 0, SGPRMax = 0;
+ for (unsigned i = 0; i < NumRegPressureSets; ++i) {
+ if (isVGPRPressureSet(i) && PressureSetRegUnits[i] > VGPRMax) {
+ VGPRSetID = i;
+ VGPRMax = PressureSetRegUnits[i];
+ continue;
+ }
+ if (isSGPRPressureSet(i) && PressureSetRegUnits[i] > SGPRMax) {
+ SGPRSetID = i;
+ SGPRMax = PressureSetRegUnits[i];
+ }
+ }
+
+ assert(SGPRSetID < NumRegPressureSets &&
+ VGPRSetID < NumRegPressureSets);
}
void SIRegisterInfo::reserveRegisterTuples(BitVector &Reserved, unsigned Reg) const {
Modified: llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.h?rev=279867&r1=279866&r2=279867&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIRegisterInfo.h Fri Aug 26 16:16:37 2016
@@ -25,8 +25,8 @@ class MachineRegisterInfo;
struct SIRegisterInfo final : public AMDGPURegisterInfo {
private:
- unsigned SGPR32SetID;
- unsigned VGPR32SetID;
+ unsigned SGPRSetID;
+ unsigned VGPRSetID;
BitVector SGPRPressureSets;
BitVector VGPRPressureSets;
@@ -182,11 +182,18 @@ public:
const TargetRegisterClass *RC,
const MachineFunction &MF) const;
- unsigned getSGPR32PressureSet() const { return SGPR32SetID; };
- unsigned getVGPR32PressureSet() const { return VGPR32SetID; };
+ unsigned getSGPRPressureSet() const { return SGPRSetID; };
+ unsigned getVGPRPressureSet() const { return VGPRSetID; };
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const;
+ bool isSGPRPressureSet(unsigned SetID) const {
+ return SGPRPressureSets.test(SetID) && !VGPRPressureSets.test(SetID);
+ }
+ bool isVGPRPressureSet(unsigned SetID) const {
+ return VGPRPressureSets.test(SetID) && !SGPRPressureSets.test(SetID);
+ }
+
private:
void buildScratchLoadStore(MachineBasicBlock::iterator MI,
unsigned LoadStoreOp, const MachineOperand *SrcDst,
More information about the llvm-commits
mailing list