summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-11-11 01:34:21 +0000
committerMatthias Braun <matze@braunis.de>2016-11-11 01:34:21 +0000
commit325cd2c98ab64b8dbee7f493818ba01e0143d34b (patch)
treed9e65626f00ca77244351153fbe4b3d3a68408c8 /llvm/lib
parenta89d8ff0adc2782c53301733e308aa5954d7eff3 (diff)
downloadbcm5719-llvm-325cd2c98ab64b8dbee7f493818ba01e0143d34b.tar.gz
bcm5719-llvm-325cd2c98ab64b8dbee7f493818ba01e0143d34b.zip
ScheduleDAGInstrs: Add condjump deps to addSchedBarrierDeps()
addSchedBarrierDeps() is supposed to add use operands to the ExitSU node. The current implementation adds uses for calls/barrier instruction and the MBB live-outs in all other cases. The use operands of conditional jump instructions were missed. Also added code to macrofusion to set the latencies between nodes to zero to avoid problems with the fusing nodes lingering around in the pending list now. Differential Revision: https://reviews.llvm.org/D25140 llvm-svn: 286544
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp50
-rw-r--r--llvm/lib/CodeGen/ScheduleDAGInstrs.cpp11
2 files changed, 24 insertions, 37 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 335578b9bbc..51ceed350d6 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -1501,10 +1501,9 @@ namespace {
/// that may be fused by the processor into a single operation.
class MacroFusion : public ScheduleDAGMutation {
const TargetInstrInfo &TII;
- const TargetRegisterInfo &TRI;
public:
- MacroFusion(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI)
- : TII(TII), TRI(TRI) {}
+ MacroFusion(const TargetInstrInfo &TII)
+ : TII(TII) {}
void apply(ScheduleDAGInstrs *DAGInstrs) override;
};
@@ -1513,27 +1512,12 @@ public:
namespace llvm {
std::unique_ptr<ScheduleDAGMutation>
-createMacroFusionDAGMutation(const TargetInstrInfo *TII,
- const TargetRegisterInfo *TRI) {
- return make_unique<MacroFusion>(*TII, *TRI);
+createMacroFusionDAGMutation(const TargetInstrInfo *TII) {
+ return make_unique<MacroFusion>(*TII);
}
} // namespace llvm
-/// Returns true if \p MI reads a register written by \p Other.
-static bool HasDataDep(const TargetRegisterInfo &TRI, const MachineInstr &MI,
- const MachineInstr &Other) {
- for (const MachineOperand &MO : MI.uses()) {
- if (!MO.isReg() || !MO.readsReg())
- continue;
-
- unsigned Reg = MO.getReg();
- if (Other.modifiesRegister(Reg, &TRI))
- return true;
- }
- return false;
-}
-
/// \brief Callback from DAG postProcessing to create cluster edges to encourage
/// fused operations.
void MacroFusion::apply(ScheduleDAGInstrs *DAGInstrs) {
@@ -1545,16 +1529,12 @@ void MacroFusion::apply(ScheduleDAGInstrs *DAGInstrs) {
if (!Branch)
return;
- for (SUnit &SU : DAG->SUnits) {
- // SUnits with successors can't be schedule in front of the ExitSU.
- if (!SU.Succs.empty())
- continue;
- // We only care if the node writes to a register that the branch reads.
- MachineInstr *Pred = SU.getInstr();
- if (!HasDataDep(TRI, *Branch, *Pred))
+ for (SDep &PredDep : ExitSU.Preds) {
+ if (PredDep.isWeak())
continue;
-
- if (!TII.shouldScheduleAdjacent(*Pred, *Branch))
+ SUnit &SU = *PredDep.getSUnit();
+ MachineInstr &Pred = *SU.getInstr();
+ if (!TII.shouldScheduleAdjacent(Pred, *Branch))
continue;
// Create a single weak edge from SU to ExitSU. The only effect is to cause
@@ -1567,6 +1547,16 @@ void MacroFusion::apply(ScheduleDAGInstrs *DAGInstrs) {
(void)Success;
assert(Success && "No DAG nodes should be reachable from ExitSU");
+ // Adjust latency of data deps between the nodes.
+ for (SDep &PredDep : ExitSU.Preds) {
+ if (PredDep.getSUnit() == &SU)
+ PredDep.setLatency(0);
+ }
+ for (SDep &SuccDep : SU.Succs) {
+ if (SuccDep.getSUnit() == &ExitSU)
+ SuccDep.setLatency(0);
+ }
+
DEBUG(dbgs() << "Macro Fuse SU(" << SU.NodeNum << ")\n");
break;
}
@@ -3128,7 +3118,7 @@ static ScheduleDAGInstrs *createGenericSchedLive(MachineSchedContext *C) {
DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
}
if (EnableMacroFusion)
- DAG->addMutation(createMacroFusionDAGMutation(DAG->TII, DAG->TRI));
+ DAG->addMutation(createMacroFusionDAGMutation(DAG->TII));
return DAG;
}
diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
index a9b5e88e5b4..02461976177 100644
--- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -247,11 +247,8 @@ void ScheduleDAGInstrs::exitRegion() {
void ScheduleDAGInstrs::addSchedBarrierDeps() {
MachineInstr *ExitMI = RegionEnd != BB->end() ? &*RegionEnd : nullptr;
ExitSU.setInstr(ExitMI);
- bool AllDepKnown = ExitMI &&
- (ExitMI->isCall() || ExitMI->isBarrier());
- if (ExitMI && AllDepKnown) {
- // If it's a call or a barrier, add dependencies on the defs and uses of
- // instruction.
+ // Add dependencies on the defs and uses of the instruction.
+ if (ExitMI) {
for (const MachineOperand &MO : ExitMI->operands()) {
if (!MO.isReg() || MO.isDef()) continue;
unsigned Reg = MO.getReg();
@@ -261,10 +258,10 @@ void ScheduleDAGInstrs::addSchedBarrierDeps() {
addVRegUseDeps(&ExitSU, ExitMI->getOperandNo(&MO));
}
}
- } else {
+ }
+ if (!ExitMI || (!ExitMI->isCall() && !ExitMI->isBarrier())) {
// For others, e.g. fallthrough, conditional branch, assume the exit
// uses all the registers that are livein to the successor blocks.
- assert(Uses.empty() && "Uses in set before adding deps?");
for (const MachineBasicBlock *Succ : BB->successors()) {
for (const auto &LI : Succ->liveins()) {
if (!Uses.contains(LI.PhysReg))
OpenPOWER on IntegriCloud