mirror of
https://github.com/RPCSX/llvm.git
synced 2025-04-03 16:51:42 +00:00
Small cleanup of MachineLICM.cpp
Specifically: - Calculate the loop pre-header once at the stat of HoistOutOfLoop, so: - We don't-DFS walk the MachineDomTree if we aren't going to do anything - Don't call getCurPreheader for each Scope - Don't needlessly use a do-while loop - Use early exit for Scopes.size() == 0 No functional changes intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228350 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ff7b5e9dda
commit
c7c2518a65
@ -693,6 +693,10 @@ void MachineLICM::ExitScopeIfDone(MachineDomTreeNode *Node,
|
|||||||
/// one pass without iteration.
|
/// one pass without iteration.
|
||||||
///
|
///
|
||||||
void MachineLICM::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
|
void MachineLICM::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
|
||||||
|
MachineBasicBlock *Preheader = getCurPreheader();
|
||||||
|
if (!Preheader)
|
||||||
|
return;
|
||||||
|
|
||||||
SmallVector<MachineDomTreeNode*, 32> Scopes;
|
SmallVector<MachineDomTreeNode*, 32> Scopes;
|
||||||
SmallVector<MachineDomTreeNode*, 8> WorkList;
|
SmallVector<MachineDomTreeNode*, 8> WorkList;
|
||||||
DenseMap<MachineDomTreeNode*, MachineDomTreeNode*> ParentMap;
|
DenseMap<MachineDomTreeNode*, MachineDomTreeNode*> ParentMap;
|
||||||
@ -700,7 +704,7 @@ void MachineLICM::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
|
|||||||
|
|
||||||
// Perform a DFS walk to determine the order of visit.
|
// Perform a DFS walk to determine the order of visit.
|
||||||
WorkList.push_back(HeaderN);
|
WorkList.push_back(HeaderN);
|
||||||
do {
|
while (!WorkList.empty()) {
|
||||||
MachineDomTreeNode *Node = WorkList.pop_back_val();
|
MachineDomTreeNode *Node = WorkList.pop_back_val();
|
||||||
assert(Node && "Null dominator tree node?");
|
assert(Node && "Null dominator tree node?");
|
||||||
MachineBasicBlock *BB = Node->getBlock();
|
MachineBasicBlock *BB = Node->getBlock();
|
||||||
@ -734,28 +738,21 @@ void MachineLICM::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
|
|||||||
ParentMap[Child] = Node;
|
ParentMap[Child] = Node;
|
||||||
WorkList.push_back(Child);
|
WorkList.push_back(Child);
|
||||||
}
|
}
|
||||||
} while (!WorkList.empty());
|
|
||||||
|
|
||||||
if (Scopes.size() != 0) {
|
|
||||||
MachineBasicBlock *Preheader = getCurPreheader();
|
|
||||||
if (!Preheader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Compute registers which are livein into the loop headers.
|
|
||||||
RegSeen.clear();
|
|
||||||
BackTrace.clear();
|
|
||||||
InitRegPressure(Preheader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Scopes.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Compute registers which are livein into the loop headers.
|
||||||
|
RegSeen.clear();
|
||||||
|
BackTrace.clear();
|
||||||
|
InitRegPressure(Preheader);
|
||||||
|
|
||||||
// Now perform LICM.
|
// Now perform LICM.
|
||||||
for (unsigned i = 0, e = Scopes.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Scopes.size(); i != e; ++i) {
|
||||||
MachineDomTreeNode *Node = Scopes[i];
|
MachineDomTreeNode *Node = Scopes[i];
|
||||||
MachineBasicBlock *MBB = Node->getBlock();
|
MachineBasicBlock *MBB = Node->getBlock();
|
||||||
|
|
||||||
MachineBasicBlock *Preheader = getCurPreheader();
|
|
||||||
if (!Preheader)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
EnterScope(MBB);
|
EnterScope(MBB);
|
||||||
|
|
||||||
// Process the block
|
// Process the block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user