aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAlloc/IGNode.cpp
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-09-20 00:45:47 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-09-20 00:45:47 +0000
commit32f81a3469bd132116f892269c64682845d54e86 (patch)
tree963a538f8b98080f00892ae56ed032ca487e45c7 /lib/CodeGen/RegAlloc/IGNode.cpp
parentdcde9bd285dcc6e86677acfb959307a255424526 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAlloc/IGNode.cpp')
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp
index c8fca7a23b..caee296166 100644
--- a/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/lib/CodeGen/RegAlloc/IGNode.cpp
@@ -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();
+}
+
+