summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/ScheduleDAGInstrs.cpp7
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp65
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h2
-rw-r--r--llvm/lib/Target/AMDGPU/SIInstrInfo.h2
4 files changed, 34 insertions, 42 deletions
diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
index 96a1f86c3e0..d11406cc330 100644
--- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -270,8 +270,13 @@ void ScheduleDAGInstrs::addPhysRegDataDeps(SUnit *SU, unsigned OperIdx) {
Dep.setLatency(SchedModel.computeOperandLatency(SU->getInstr(), OperIdx,
RegUse, UseOp));
ST.adjustSchedDependency(SU, UseSU, Dep);
- } else
+ } else {
Dep.setLatency(0);
+ // FIXME: We could always let target to adjustSchedDependency(), and
+ // remove this condition, but that currently asserts in Hexagon BE.
+ if (SU->getInstr()->isBundle() || (RegUse && RegUse->isBundle()))
+ ST.adjustSchedDependency(SU, UseSU, Dep);
+ }
UseSU->addPred(Dep);
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
index 16bde062b1d..af1dc8d7a48 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -716,6 +716,31 @@ unsigned GCNSubtarget::getMaxNumVGPRs(const MachineFunction &MF) const {
return MaxNumVGPRs;
}
+void GCNSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst,
+ SDep &Dep) const {
+ if (Dep.getKind() != SDep::Kind::Data || !Dep.getReg() ||
+ !Src->isInstr() || !Dst->isInstr())
+ return;
+
+ MachineInstr *SrcI = Src->getInstr();
+ MachineInstr *DstI = Dst->getInstr();
+
+ if (SrcI->isBundle()) {
+ const SIRegisterInfo *TRI = getRegisterInfo();
+ auto Reg = Dep.getReg();
+ MachineBasicBlock::const_instr_iterator I(SrcI->getIterator());
+ MachineBasicBlock::const_instr_iterator E(SrcI->getParent()->instr_end());
+ for (++I; I != E && I->isBundledWithPred(); ++I) {
+ if (!I->modifiesRegister(Reg, TRI))
+ continue;
+ Dep.setLatency(InstrInfo.getInstrLatency(getInstrItineraryData(), *I));
+ break;
+ }
+ } else if (DstI->isBundle()) {
+ Dep.setLatency(InstrInfo.getInstrLatency(getInstrItineraryData(), *SrcI));
+ }
+}
+
namespace {
struct MemOpClusterMutation : ScheduleDAGMutation {
const SIInstrInfo *TII;
@@ -764,45 +789,6 @@ struct MemOpClusterMutation : ScheduleDAGMutation {
}
};
-struct FixBundleLatencyMutation : ScheduleDAGMutation {
- const SIInstrInfo *TII;
-
- const TargetSchedModel *TSchedModel;
-
- FixBundleLatencyMutation(const SIInstrInfo *tii) : TII(tii) {}
-
- unsigned computeLatency(const MachineInstr &MI, unsigned Reg) const {
- const SIRegisterInfo &TRI = TII->getRegisterInfo();
- MachineBasicBlock::const_instr_iterator I(MI.getIterator());
- MachineBasicBlock::const_instr_iterator E(MI.getParent()->instr_end());
- unsigned Lat = 0;
- for (++I; I != E && I->isBundledWithPred(); ++I) {
- if (!I->modifiesRegister(Reg, &TRI))
- continue;
- Lat = TSchedModel->computeInstrLatency(&*I);
- break;
- }
- return Lat;
- }
-
- void apply(ScheduleDAGInstrs *DAGInstrs) override {
- ScheduleDAGMI *DAG = static_cast<ScheduleDAGMI*>(DAGInstrs);
- TSchedModel = DAGInstrs->getSchedModel();
- if (!TSchedModel || DAG->SUnits.empty())
- return;
-
- for (SUnit &SU : DAG->SUnits) {
- if (!SU.isInstr() || !SU.getInstr()->isBundle())
- continue;
- for (SDep &Dep : SU.Succs) {
- if (Dep.getKind() == SDep::Kind::Data && Dep.getReg())
- if (unsigned Lat = computeLatency(*SU.getInstr(), Dep.getReg()))
- Dep.setLatency(Lat);
- }
- }
- }
-};
-
struct FillMFMAShadowMutation : ScheduleDAGMutation {
const SIInstrInfo *TII;
@@ -929,7 +915,6 @@ struct FillMFMAShadowMutation : ScheduleDAGMutation {
void GCNSubtarget::getPostRAMutations(
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
- Mutations.push_back(std::make_unique<FixBundleLatencyMutation>(&InstrInfo));
Mutations.push_back(std::make_unique<MemOpClusterMutation>(&InstrInfo));
Mutations.push_back(std::make_unique<FillMFMAShadowMutation>(&InstrInfo));
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
index b0188b003c7..19a240800ba 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
@@ -1212,6 +1212,8 @@ public:
unsigned getMinWavesPerEU() const override {
return AMDGPU::IsaInfo::getMinWavesPerEU(this);
}
+
+ void adjustSchedDependency(SUnit *Src, SUnit *Dst, SDep &Dep) const override;
};
class R600Subtarget final : public R600GenSubtargetInfo,
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 14a19733048..899eba7d2a1 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -1045,7 +1045,7 @@ public:
unsigned getInstrLatency(const InstrItineraryData *ItinData,
const MachineInstr &MI,
- unsigned *PredCost) const override;
+ unsigned *PredCost = nullptr) const override;
};
/// \brief Returns true if a reg:subreg pair P has a TRC class
OpenPOWER on IntegriCloud