forked from OSchip/llvm-project
Allow copy coalescing in more cases: if sum of node degrees is more than
than #available regs, compute the sum excluding duplicates and if that is less than #regs, go ahead and coalesce. Add method IGNode::getCombinedDegree to count excluding duplicates. llvm-svn: 3842
This commit is contained in:
parent
3e1dc145bd
commit
e008b2d62e
|
@ -36,3 +36,19 @@ void IGNode::delAdjIGNode(const IGNode *Node) {
|
|||
assert( It != AdjList.end() ); // the node must be there
|
||||
AdjList.erase(It);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get the number of unique neighbors if these two nodes are merged
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
unsigned
|
||||
IGNode::getCombinedDegree(const IGNode* otherNode) const
|
||||
{
|
||||
std::vector<IGNode*> nbrs(AdjList);
|
||||
nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end());
|
||||
sort(nbrs.begin(), nbrs.end());
|
||||
std::vector<IGNode*>::iterator new_end = unique(nbrs.begin(), nbrs.end());
|
||||
return new_end - nbrs.begin();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -318,6 +318,12 @@ void LiveRangeInfo::coalesceLRs()
|
|||
LROfDef->getUserIGNode()->getNumOfNeighbors() +
|
||||
LROfUse->getUserIGNode()->getNumOfNeighbors();
|
||||
|
||||
if (CombinedDegree > RCOfDef->getNumOfAvailRegs()) {
|
||||
// get more precise estimate of combined degree
|
||||
CombinedDegree = LROfDef->getUserIGNode()->
|
||||
getCombinedDegree(LROfUse->getUserIGNode());
|
||||
}
|
||||
|
||||
if (CombinedDegree <= RCOfDef->getNumOfAvailRegs()) {
|
||||
// if both LRs do not have suggested colors
|
||||
if (!(LROfDef->hasSuggestedColor() &&
|
||||
|
@ -353,7 +359,10 @@ void LiveRangeInfo::printLiveRanges() {
|
|||
for( ; HMI != LiveRangeMap.end(); ++HMI) {
|
||||
if (HMI->first && HMI->second) {
|
||||
cerr << " Value* " << RAV(HMI->first) << "\t: ";
|
||||
cerr << "LR# " << HMI->second->getUserIGNode()->getIndex();
|
||||
if (IGNode* igNode = HMI->second->getUserIGNode())
|
||||
cerr << "LR# " << igNode->getIndex();
|
||||
else
|
||||
cerr << "LR# " << "<no-IGNode>";
|
||||
cerr << "\t:Values = "; printSet(*HMI->second); cerr << "\n";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue