From e008b2d62ec796ba8bf3a313575b9f50c9af2683 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Fri, 20 Sep 2002 00:45:47 +0000 Subject: 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 --- llvm/lib/CodeGen/RegAlloc/IGNode.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'llvm/lib/CodeGen/RegAlloc/IGNode.cpp') 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 nbrs(AdjList); + nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end()); + sort(nbrs.begin(), nbrs.end()); + std::vector::iterator new_end = unique(nbrs.begin(), nbrs.end()); + return new_end - nbrs.begin(); +} + + -- cgit v1.2.3