[llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/IGNode.cpp LiveRangeInfo.cpp
Vikram Adve
vadve at psmith.cs.uiuc.edu
Thu Sep 19 19:46:00 PDT 2002
Changes in directory llvm/lib/CodeGen/RegAlloc:
IGNode.cpp updated: 1.7 -> 1.8
LiveRangeInfo.cpp updated: 1.27 -> 1.28
---
Log message:
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.
---
Diffs of the changes:
Index: llvm/lib/CodeGen/RegAlloc/IGNode.cpp
diff -u llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.7 llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.8
--- llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.7 Sat Sep 14 18:05:33 2002
+++ llvm/lib/CodeGen/RegAlloc/IGNode.cpp Thu Sep 19 19:45:46 2002
@@ -36,3 +36,19 @@
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();
+}
+
+
Index: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
diff -u llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.27 llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.28
--- llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.27 Sat Sep 14 18:05:33 2002
+++ llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp Thu Sep 19 19:45:47 2002
@@ -318,6 +318,12 @@
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 @@
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";
}
}
More information about the llvm-commits
mailing list