summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2016-05-02 16:23:09 +0000
committerTom Stellard <thomas.stellard@amd.com>2016-05-02 16:23:09 +0000
commita27007eb4fd0854cc2861c25c082f3cb64d8593e (patch)
treede23745d48d036c3929020c0a62c05ca809318bf /llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
parentec41cd2461c642a3f824e8ccfe8ae5b7bc6d621f (diff)
downloadbcm5719-llvm-a27007eb4fd0854cc2861c25c082f3cb64d8593e.tar.gz
bcm5719-llvm-a27007eb4fd0854cc2861c25c082f3cb64d8593e.zip
AMDGPU/SI: Use hazard recognizer to detect DPP hazards
Reviewers: arsenm Subscribers: arsenm, llvm-commits Differential Revision: http://reviews.llvm.org/D18603 llvm-svn: 268247
Diffstat (limited to 'llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 725727979e9..58a9a286e30 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -47,6 +47,9 @@ GCNHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
if (SIInstrInfo::isVMEM(*MI) && checkVMEMHazards(MI) > 0)
return NoopHazard;
+ if (SIInstrInfo::isDPP(*MI) && checkDPPHazards(MI) > 0)
+ return NoopHazard;
+
return NoHazard;
}
@@ -61,6 +64,9 @@ unsigned GCNHazardRecognizer::PreEmitNoops(MachineInstr *MI) {
if (SIInstrInfo::isVMEM(*MI))
return std::max(0, checkVMEMHazards(MI));
+ if (SIInstrInfo::isDPP(*MI))
+ return std::max(0, checkDPPHazards(MI));
+
return 0;
}
@@ -175,3 +181,23 @@ int GCNHazardRecognizer::checkVMEMHazards(MachineInstr* VMEM) {
}
return WaitStatesNeeded;
}
+
+int GCNHazardRecognizer::checkDPPHazards(MachineInstr *DPP) {
+ const AMDGPUSubtarget &ST = MF.getSubtarget<AMDGPUSubtarget>();
+ const SIRegisterInfo *TRI =
+ static_cast<const SIRegisterInfo*>(ST.getRegisterInfo());
+
+ // Check for DPP VGPR read after VALU VGPR write.
+ int DppVgprWaitStates = 2;
+ int WaitStatesNeeded = 0;
+
+ for (const MachineOperand &Use : DPP->uses()) {
+ if (!Use.isReg() || !TRI->isVGPR(MF.getRegInfo(), Use.getReg()))
+ continue;
+ int WaitStatesNeededForUse =
+ DppVgprWaitStates - getWaitStatesSinceDef(Use.getReg());
+ WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
+ }
+
+ return WaitStatesNeeded;
+}
OpenPOWER on IntegriCloud