diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-05-12 01:58:24 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-05-12 01:58:24 +0000 |
commit | 13d41b9d721f98372b97d2ec119e6c91932ab0ae (patch) | |
tree | b6068fb8e9346f9e69de380ca3ce9bc4f5e0a8a4 /lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | |
parent | 31ff1ff348bce63f5d802530c5a99f6a4d6db104 (diff) |
Add capability to scheduler to commute nodes for profit.
If a two-address code whose first operand has uses below, it should be commuted
when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/ScheduleDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp index 4a9b9c7f04..e05d9d7103 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp @@ -120,13 +120,10 @@ void ScheduleDAG::BuildSchedUnits() { if (MainNode->isTargetOpcode()) { unsigned Opc = MainNode->getTargetOpcode(); - if (TII->isTwoAddrInstr(Opc)) { + if (TII->isTwoAddrInstr(Opc)) SU->isTwoAddress = true; - SDNode *OpN = MainNode->getOperand(0).Val; - SUnit *OpSU = SUnitMap[OpN]; - if (OpSU) - OpSU->isDefNUseOperand = true; - } + if (TII->isCommutableInstr(Opc)) + SU->isCommutable = true; } // Find all predecessors and successors of the group. @@ -391,7 +388,18 @@ void ScheduleDAG::EmitNode(SDNode *Node, // instruction as appropriate. for (unsigned i = 0; i != NodeOperands; ++i) AddOperand(MI, Node->getOperand(i), i+NumResults, &II, VRBaseMap); - + + // Commute node if it has been determined to be profitable. + if (CommuteSet.count(Node)) { + MachineInstr *NewMI = TII->commuteInstruction(MI); + if (NewMI == 0) + DEBUG(std::cerr << "Sched: COMMUTING FAILED!\n"); + else { + DEBUG(std::cerr << "Sched: COMMUTED TO: " << *NewMI); + MI = NewMI; + } + } + // Now that we have emitted all operands, emit this instruction itself. if ((II.Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION) == 0) { BB->insert(BB->end(), MI); |