summaryrefslogtreecommitdiffstats
path: root/llvm/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
commite008b2d62ec796ba8bf3a313575b9f50c9af2683 (patch)
tree3a6e160fa206fe8a95356a687cbfb634db35a942 /llvm/lib/CodeGen/RegAlloc/IGNode.cpp
parent3e1dc145bde113a18de0443e7134bdc4e1ddac50 (diff)
downloadbcm5719-llvm-e008b2d62ec796ba8bf3a313575b9f50c9af2683.tar.gz
bcm5719-llvm-e008b2d62ec796ba8bf3a313575b9f50c9af2683.zip
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
Diffstat (limited to 'llvm/lib/CodeGen/RegAlloc/IGNode.cpp')
-rw-r--r--llvm/lib/CodeGen/RegAlloc/IGNode.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/RegAlloc/IGNode.cpp b/llvm/lib/CodeGen/RegAlloc/IGNode.cpp
index c8fca7a23b6..caee2961664 100644
--- a/llvm/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/llvm/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();
+}
+
+
OpenPOWER on IntegriCloud