summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
diff options
context:
space:
mode:
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2017-02-23 20:19:44 +0000
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2017-02-23 20:19:44 +0000
commitce3ddd2de4c5dbd5a7a68b51ea38f96cf7fbf3aa (patch)
tree05d2e6754a3580a96a723b01dcd89dcf58eec2bb /llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
parent851125dca903fdaa458d87fb0a35349286a2395f (diff)
downloadbcm5719-llvm-ce3ddd2de4c5dbd5a7a68b51ea38f96cf7fbf3aa.tar.gz
bcm5719-llvm-ce3ddd2de4c5dbd5a7a68b51ea38f96cf7fbf3aa.zip
Correct register pressure calculation in presence of subregs
If a subreg is used in an instruction it counts as a whole superreg for the purpose of register pressure calculation. This patch corrects improper register pressure calculation by examining operand's lane mask. Differential Revision: https://reviews.llvm.org/D29835 llvm-svn: 296009
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 39324cbbcc0..f1d037d1159 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/MathExtras.h"
using namespace llvm;
@@ -1408,3 +1409,18 @@ const int *SIRegisterInfo::getRegUnitPressureSets(unsigned RegUnit) const {
return Empty;
return AMDGPURegisterInfo::getRegUnitPressureSets(RegUnit);
}
+
+unsigned SIRegisterInfo::getRegUnitWeight(const MachineRegisterInfo &MRI,
+ unsigned RegUnit,
+ LaneBitmask LaneMask) const {
+ unsigned Weight = TargetRegisterInfo::getRegUnitWeight(MRI, RegUnit,
+ LaneMask);
+ if (Weight > 1 && LaneMask.any() && !LaneMask.all() &&
+ isVirtualRegister(RegUnit)) {
+ LaneBitmask Max = MRI.getMaxLaneMaskForVReg(RegUnit);
+ if (Max != LaneMask && !Max.all() && !Max.none())
+ Weight = (Weight * countPopulation(LaneMask.getAsInteger())) /
+ countPopulation(Max.getAsInteger());
+ }
+ return Weight;
+}
OpenPOWER on IntegriCloud