548 uint r = _lrg_map.live_range_id(n);
549
550 // Some special values do not allocate
551 if(r) {
552 // A DEF normally costs block frequency; rematerialized values are
553 // removed from the DEF sight, so LOWER costs here.
554 lrgs(r)._cost += n->rematerialize() ? 0 : b->_freq;
555
556 // If it is not live, then this instruction is dead. Probably caused
557 // by spilling and rematerialization. Who cares why, yank this baby.
558 if( !liveout.member(r) && n->Opcode() != Op_SafePoint ) {
559 Node *def = n->in(0);
560 if( !n->is_Proj() ||
561 // Could also be a flags-projection of a dead ADD or such.
562 (_lrg_map.live_range_id(def) && !liveout.member(_lrg_map.live_range_id(def)))) {
563 b->_nodes.remove(j - 1);
564 if (lrgs(r)._def == n) {
565 lrgs(r)._def = 0;
566 }
567 n->disconnect_inputs(NULL, C);
568 _cfg._bbs.map(n->_idx,NULL);
569 n->replace_by(C->top());
570 // Since yanking a Node from block, high pressure moves up one
571 hrp_index[0]--;
572 hrp_index[1]--;
573 continue;
574 }
575
576 // Fat-projections kill many registers which cannot be used to
577 // hold live ranges.
578 if (lrgs(r)._fat_proj) {
579 // Count the int-only registers
580 RegMask itmp = lrgs(r).mask();
581 itmp.AND(*Matcher::idealreg2regmask[Op_RegI]);
582 int iregs = itmp.Size();
583 if( pressure[0]+iregs > b->_reg_pressure )
584 b->_reg_pressure = pressure[0]+iregs;
585 if( pressure[0] <= (uint)INTPRESSURE &&
586 pressure[0]+iregs > (uint)INTPRESSURE ) {
587 hrp_index[0] = j-1;
588 }
590 RegMask ftmp = lrgs(r).mask();
591 ftmp.AND(*Matcher::idealreg2regmask[Op_RegD]);
592 int fregs = ftmp.Size();
593 if( pressure[1]+fregs > b->_freg_pressure )
594 b->_freg_pressure = pressure[1]+fregs;
595 if( pressure[1] <= (uint)FLOATPRESSURE &&
596 pressure[1]+fregs > (uint)FLOATPRESSURE ) {
597 hrp_index[1] = j-1;
598 }
599 }
600
601 } else { // Else it is live
602 // A DEF also ends 'area' partway through the block.
603 lrgs(r)._area -= cost;
604 assert(!(lrgs(r)._area < 0.0), "negative spill area" );
605
606 // Insure high score for immediate-use spill copies so they get a color
607 if( n->is_SpillCopy()
608 && lrgs(r).is_singledef() // MultiDef live range can still split
609 && n->outcnt() == 1 // and use must be in this block
610 && _cfg._bbs[n->unique_out()->_idx] == b ) {
611 // All single-use MachSpillCopy(s) that immediately precede their
612 // use must color early. If a longer live range steals their
613 // color, the spill copy will split and may push another spill copy
614 // further away resulting in an infinite spill-split-retry cycle.
615 // Assigning a zero area results in a high score() and a good
616 // location in the simplify list.
617 //
618
619 Node *single_use = n->unique_out();
620 assert( b->find_node(single_use) >= j, "Use must be later in block");
621 // Use can be earlier in block if it is a Phi, but then I should be a MultiDef
622
623 // Find first non SpillCopy 'm' that follows the current instruction
624 // (j - 1) is index for current instruction 'n'
625 Node *m = n;
626 for( uint i = j; i <= last_inst && m->is_SpillCopy(); ++i ) { m = b->_nodes[i]; }
627 if( m == single_use ) {
628 lrgs(r)._area = 0.0;
629 }
630 }
|
548 uint r = _lrg_map.live_range_id(n);
549
550 // Some special values do not allocate
551 if(r) {
552 // A DEF normally costs block frequency; rematerialized values are
553 // removed from the DEF sight, so LOWER costs here.
554 lrgs(r)._cost += n->rematerialize() ? 0 : b->_freq;
555
556 // If it is not live, then this instruction is dead. Probably caused
557 // by spilling and rematerialization. Who cares why, yank this baby.
558 if( !liveout.member(r) && n->Opcode() != Op_SafePoint ) {
559 Node *def = n->in(0);
560 if( !n->is_Proj() ||
561 // Could also be a flags-projection of a dead ADD or such.
562 (_lrg_map.live_range_id(def) && !liveout.member(_lrg_map.live_range_id(def)))) {
563 b->_nodes.remove(j - 1);
564 if (lrgs(r)._def == n) {
565 lrgs(r)._def = 0;
566 }
567 n->disconnect_inputs(NULL, C);
568 _cfg.unmap_node_from_block(n);
569 n->replace_by(C->top());
570 // Since yanking a Node from block, high pressure moves up one
571 hrp_index[0]--;
572 hrp_index[1]--;
573 continue;
574 }
575
576 // Fat-projections kill many registers which cannot be used to
577 // hold live ranges.
578 if (lrgs(r)._fat_proj) {
579 // Count the int-only registers
580 RegMask itmp = lrgs(r).mask();
581 itmp.AND(*Matcher::idealreg2regmask[Op_RegI]);
582 int iregs = itmp.Size();
583 if( pressure[0]+iregs > b->_reg_pressure )
584 b->_reg_pressure = pressure[0]+iregs;
585 if( pressure[0] <= (uint)INTPRESSURE &&
586 pressure[0]+iregs > (uint)INTPRESSURE ) {
587 hrp_index[0] = j-1;
588 }
590 RegMask ftmp = lrgs(r).mask();
591 ftmp.AND(*Matcher::idealreg2regmask[Op_RegD]);
592 int fregs = ftmp.Size();
593 if( pressure[1]+fregs > b->_freg_pressure )
594 b->_freg_pressure = pressure[1]+fregs;
595 if( pressure[1] <= (uint)FLOATPRESSURE &&
596 pressure[1]+fregs > (uint)FLOATPRESSURE ) {
597 hrp_index[1] = j-1;
598 }
599 }
600
601 } else { // Else it is live
602 // A DEF also ends 'area' partway through the block.
603 lrgs(r)._area -= cost;
604 assert(!(lrgs(r)._area < 0.0), "negative spill area" );
605
606 // Insure high score for immediate-use spill copies so they get a color
607 if( n->is_SpillCopy()
608 && lrgs(r).is_singledef() // MultiDef live range can still split
609 && n->outcnt() == 1 // and use must be in this block
610 && _cfg.get_block_for_node(n->unique_out()) == b ) {
611 // All single-use MachSpillCopy(s) that immediately precede their
612 // use must color early. If a longer live range steals their
613 // color, the spill copy will split and may push another spill copy
614 // further away resulting in an infinite spill-split-retry cycle.
615 // Assigning a zero area results in a high score() and a good
616 // location in the simplify list.
617 //
618
619 Node *single_use = n->unique_out();
620 assert( b->find_node(single_use) >= j, "Use must be later in block");
621 // Use can be earlier in block if it is a Phi, but then I should be a MultiDef
622
623 // Find first non SpillCopy 'm' that follows the current instruction
624 // (j - 1) is index for current instruction 'n'
625 Node *m = n;
626 for( uint i = j; i <= last_inst && m->is_SpillCopy(); ++i ) { m = b->_nodes[i]; }
627 if( m == single_use ) {
628 lrgs(r)._area = 0.0;
629 }
630 }
|