6750588: assert(lrg._area >= 0,"negative spill area") running NSK stmp0101 test

Handle NaN costs more carefully

Reviewed-by: kvn, never
This commit is contained in:
Chuck Rasbold 2008-09-24 15:56:36 -07:00
parent b15796424e
commit 42be28cece

View File

@ -485,8 +485,9 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
// Liveout things are presumed live for the whole block. We accumulate // Liveout things are presumed live for the whole block. We accumulate
// 'area' accordingly. If they get killed in the block, we'll subtract // 'area' accordingly. If they get killed in the block, we'll subtract
// the unused part of the block from the area. // the unused part of the block from the area.
double cost = b->_freq * double(last_inst-last_phi); int inst_count = last_inst - last_phi;
assert( cost >= 0, "negative spill cost" ); double cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count);
assert(!(cost < 0.0), "negative spill cost" );
IndexSetIterator elements(&liveout); IndexSetIterator elements(&liveout);
uint lidx; uint lidx;
while ((lidx = elements.next()) != 0) { while ((lidx = elements.next()) != 0) {
@ -590,7 +591,7 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
} else { // Else it is live } else { // Else it is live
// A DEF also ends 'area' partway through the block. // A DEF also ends 'area' partway through the block.
lrgs(r)._area -= cost; lrgs(r)._area -= cost;
assert( lrgs(r)._area >= 0, "negative spill area" ); assert(!(lrgs(r)._area < 0.0), "negative spill area" );
// Insure high score for immediate-use spill copies so they get a color // Insure high score for immediate-use spill copies so they get a color
if( n->is_SpillCopy() if( n->is_SpillCopy()
@ -703,8 +704,9 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
} // End of if normal register-allocated value } // End of if normal register-allocated value
cost -= b->_freq; // Area remaining in the block // Area remaining in the block
if( cost < 0.0 ) cost = 0.0; // Cost goes negative in the Phi area inst_count--;
cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count);
// Make all inputs live // Make all inputs live
if( !n->is_Phi() ) { // Phi function uses come from prior block if( !n->is_Phi() ) { // Phi function uses come from prior block
@ -751,7 +753,7 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
assert( pressure[0] == count_int_pressure (&liveout), "" ); assert( pressure[0] == count_int_pressure (&liveout), "" );
assert( pressure[1] == count_float_pressure(&liveout), "" ); assert( pressure[1] == count_float_pressure(&liveout), "" );
} }
assert( lrg._area >= 0, "negative spill area" ); assert(!(lrg._area < 0.0), "negative spill area" );
} }
} }
} // End of reverse pass over all instructions in block } // End of reverse pass over all instructions in block