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
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
index 7ad7018..2037d81 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
@@ -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";
     }
   }