From: Ruchira Sasanka Date: Tue, 8 Jan 2002 16:29:23 +0000 (+0000) Subject: Fixed a bug in spill cost estimation X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ce773da22344a3942b41dc2019d839f3e9231c21;p=oota-llvm.git Fixed a bug in spill cost estimation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1500 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp index 3ee79e328e8..3918871d69f 100644 --- a/lib/CodeGen/RegAlloc/RegClass.cpp +++ b/lib/CodeGen/RegAlloc/RegClass.cpp @@ -150,9 +150,9 @@ IGNode * RegClass::getIGNodeWithMinSpillCost() { unsigned int IGNodeListSize = IG.getIGNodeList().size(); - long MinSpillCost = -1; + double MinSpillCost; IGNode *MinCostIGNode = NULL; - + bool isFirstNode = true; // pass over IGNodeList to find the IGNode with minimum spill cost // among all IGNodes that are not yet pushed on to the stack @@ -165,11 +165,13 @@ IGNode * RegClass::getIGNodeWithMinSpillCost() if( ! IGNode->isOnStack() ) { - long SpillCost = (long) IGNode->getParentLR()->getSpillCost(); + double SpillCost = (double) IGNode->getParentLR()->getSpillCost() / + (double) (IGNode->getCurDegree() + 1); - if( MinSpillCost == -1) { // for the first IG node + if( isFirstNode ) { // for the first IG node MinSpillCost = SpillCost; MinCostIGNode = IGNode; + isFirstNode = false; } else if( MinSpillCost > SpillCost) { diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp index 3ee79e328e8..3918871d69f 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp +++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp @@ -150,9 +150,9 @@ IGNode * RegClass::getIGNodeWithMinSpillCost() { unsigned int IGNodeListSize = IG.getIGNodeList().size(); - long MinSpillCost = -1; + double MinSpillCost; IGNode *MinCostIGNode = NULL; - + bool isFirstNode = true; // pass over IGNodeList to find the IGNode with minimum spill cost // among all IGNodes that are not yet pushed on to the stack @@ -165,11 +165,13 @@ IGNode * RegClass::getIGNodeWithMinSpillCost() if( ! IGNode->isOnStack() ) { - long SpillCost = (long) IGNode->getParentLR()->getSpillCost(); + double SpillCost = (double) IGNode->getParentLR()->getSpillCost() / + (double) (IGNode->getCurDegree() + 1); - if( MinSpillCost == -1) { // for the first IG node + if( isFirstNode ) { // for the first IG node MinSpillCost = SpillCost; MinCostIGNode = IGNode; + isFirstNode = false; } else if( MinSpillCost > SpillCost) {