< prev index next >

src/share/vm/opto/postaloc.cpp

Print this page




 645       // alive and well at the use (or else the allocator fubar'd).  Take
 646       // advantage of this info to set a reaching def for the use-reg.
 647       uint k;
 648       for (k = 1; k < n->req(); k++) {
 649         Node *def = n->in(k);   // n->in(k) is a USE; def is the DEF for this USE
 650         guarantee(def != NULL, "no disconnected nodes at this point");
 651         uint useidx = _lrg_map.live_range_id(def); // useidx is the live range index for this USE
 652 
 653         if( useidx ) {
 654           OptoReg::Name ureg = lrgs(useidx).reg();
 655           if( !value[ureg] ) {
 656             int idx;            // Skip occasional useless copy
 657             while( (idx=def->is_Copy()) != 0 &&
 658                    def->in(idx) != NULL &&  // NULL should not happen
 659                    ureg == lrgs(_lrg_map.live_range_id(def->in(idx))).reg())
 660               def = def->in(idx);
 661             Node *valdef = skip_copies(def); // tighten up val through non-useless copies
 662             value.map(ureg,valdef); // record improved reaching-def info
 663             regnd.map(ureg,   def);
 664             // Record other half of doubles
 665             uint def_ideal_reg = def->ideal_reg();
 666             int n_regs = RegMask::num_registers(def_ideal_reg);
 667             for (int l = 1; l < n_regs; l++) {
 668               OptoReg::Name ureg_lo = OptoReg::add(ureg,-l);
 669               if (!value[ureg_lo] &&
 670                   (!RegMask::can_represent(ureg_lo) ||
 671                    lrgs(useidx).mask().Member(ureg_lo))) { // Nearly always adjacent
 672                 value.map(ureg_lo,valdef); // record improved reaching-def info
 673                 regnd.map(ureg_lo,   def);
 674               }
 675             }
 676           }
 677         }
 678       }
 679 
 680       const uint two_adr = n->is_Mach() ? n->as_Mach()->two_adr() : 0;
 681 
 682       // Remove copies along input edges
 683       for (k = 1; k < n->req(); k++) {
 684         j -= elide_copy(n, k, block, value, regnd, two_adr != k);
 685       }


 689       if (!lidx) {
 690         continue;
 691       }
 692 
 693       // Update the register defined by this instruction
 694       OptoReg::Name nreg = lrgs(lidx).reg();
 695       // Skip through all copies to the _value_ being defined.
 696       // Do not change from int to pointer
 697       Node *val = skip_copies(n);
 698 
 699       // Clear out a dead definition before starting so that the
 700       // elimination code doesn't have to guard against it.  The
 701       // definition could in fact be a kill projection with a count of
 702       // 0 which is safe but since those are uninteresting for copy
 703       // elimination just delete them as well.
 704       if (regnd[nreg] != NULL && regnd[nreg]->outcnt() == 0) {
 705         regnd.map(nreg, NULL);
 706         value.map(nreg, NULL);
 707       }
 708 
 709       uint n_ideal_reg = n->ideal_reg();
 710       int n_regs = RegMask::num_registers(n_ideal_reg);
 711       if (n_regs == 1) {
 712         // If Node 'n' does not change the value mapped by the register,
 713         // then 'n' is a useless copy.  Do not update the register->node
 714         // mapping so 'n' will go dead.
 715         if( value[nreg] != val ) {
 716           if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, OptoReg::Bad)) {
 717             j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 718           } else {
 719             // Update the mapping: record new Node defined by the register
 720             regnd.map(nreg,n);
 721             // Update mapping for defined *value*, which is the defined
 722             // Node after skipping all copies.
 723             value.map(nreg,val);
 724           }
 725         } else if( !may_be_copy_of_callee(n) ) {
 726           assert(n->is_Copy(), "");
 727           j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 728         }
 729       } else if (RegMask::is_vector(n_ideal_reg)) {


 756           RegMask tmp = lrgs(lidx).mask();
 757           tmp.Remove(nreg);
 758           nreg_lo = tmp.find_first_elem();
 759         }
 760         if (value[nreg] != val || value[nreg_lo] != val) {
 761           if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, nreg_lo)) {
 762             j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 763           } else {
 764             regnd.map(nreg   , n );
 765             regnd.map(nreg_lo, n );
 766             value.map(nreg   ,val);
 767             value.map(nreg_lo,val);
 768           }
 769         } else if (!may_be_copy_of_callee(n)) {
 770           assert(n->is_Copy(), "");
 771           j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 772         }
 773       }
 774 
 775       // Fat projections kill many registers
 776       if( n_ideal_reg == MachProjNode::fat_proj ) {
 777         RegMask rm = n->out_RegMask();
 778         // wow, what an expensive iterator...
 779         nreg = rm.find_first_elem();
 780         while( OptoReg::is_valid(nreg)) {
 781           rm.Remove(nreg);
 782           value.map(nreg,n);
 783           regnd.map(nreg,n);
 784           nreg = rm.find_first_elem();
 785         }
 786       }
 787 
 788     } // End of for all instructions in the block
 789 
 790   } // End for all blocks
 791 }


 645       // alive and well at the use (or else the allocator fubar'd).  Take
 646       // advantage of this info to set a reaching def for the use-reg.
 647       uint k;
 648       for (k = 1; k < n->req(); k++) {
 649         Node *def = n->in(k);   // n->in(k) is a USE; def is the DEF for this USE
 650         guarantee(def != NULL, "no disconnected nodes at this point");
 651         uint useidx = _lrg_map.live_range_id(def); // useidx is the live range index for this USE
 652 
 653         if( useidx ) {
 654           OptoReg::Name ureg = lrgs(useidx).reg();
 655           if( !value[ureg] ) {
 656             int idx;            // Skip occasional useless copy
 657             while( (idx=def->is_Copy()) != 0 &&
 658                    def->in(idx) != NULL &&  // NULL should not happen
 659                    ureg == lrgs(_lrg_map.live_range_id(def->in(idx))).reg())
 660               def = def->in(idx);
 661             Node *valdef = skip_copies(def); // tighten up val through non-useless copies
 662             value.map(ureg,valdef); // record improved reaching-def info
 663             regnd.map(ureg,   def);
 664             // Record other half of doubles
 665             Opcodes def_ideal_reg = def->ideal_reg();
 666             int n_regs = RegMask::num_registers(def_ideal_reg);
 667             for (int l = 1; l < n_regs; l++) {
 668               OptoReg::Name ureg_lo = OptoReg::add(ureg,-l);
 669               if (!value[ureg_lo] &&
 670                   (!RegMask::can_represent(ureg_lo) ||
 671                    lrgs(useidx).mask().Member(ureg_lo))) { // Nearly always adjacent
 672                 value.map(ureg_lo,valdef); // record improved reaching-def info
 673                 regnd.map(ureg_lo,   def);
 674               }
 675             }
 676           }
 677         }
 678       }
 679 
 680       const uint two_adr = n->is_Mach() ? n->as_Mach()->two_adr() : 0;
 681 
 682       // Remove copies along input edges
 683       for (k = 1; k < n->req(); k++) {
 684         j -= elide_copy(n, k, block, value, regnd, two_adr != k);
 685       }


 689       if (!lidx) {
 690         continue;
 691       }
 692 
 693       // Update the register defined by this instruction
 694       OptoReg::Name nreg = lrgs(lidx).reg();
 695       // Skip through all copies to the _value_ being defined.
 696       // Do not change from int to pointer
 697       Node *val = skip_copies(n);
 698 
 699       // Clear out a dead definition before starting so that the
 700       // elimination code doesn't have to guard against it.  The
 701       // definition could in fact be a kill projection with a count of
 702       // 0 which is safe but since those are uninteresting for copy
 703       // elimination just delete them as well.
 704       if (regnd[nreg] != NULL && regnd[nreg]->outcnt() == 0) {
 705         regnd.map(nreg, NULL);
 706         value.map(nreg, NULL);
 707       }
 708 
 709       Opcodes n_ideal_reg = n->ideal_reg();
 710       int n_regs = RegMask::num_registers(n_ideal_reg);
 711       if (n_regs == 1) {
 712         // If Node 'n' does not change the value mapped by the register,
 713         // then 'n' is a useless copy.  Do not update the register->node
 714         // mapping so 'n' will go dead.
 715         if( value[nreg] != val ) {
 716           if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, OptoReg::Bad)) {
 717             j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 718           } else {
 719             // Update the mapping: record new Node defined by the register
 720             regnd.map(nreg,n);
 721             // Update mapping for defined *value*, which is the defined
 722             // Node after skipping all copies.
 723             value.map(nreg,val);
 724           }
 725         } else if( !may_be_copy_of_callee(n) ) {
 726           assert(n->is_Copy(), "");
 727           j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 728         }
 729       } else if (RegMask::is_vector(n_ideal_reg)) {


 756           RegMask tmp = lrgs(lidx).mask();
 757           tmp.Remove(nreg);
 758           nreg_lo = tmp.find_first_elem();
 759         }
 760         if (value[nreg] != val || value[nreg_lo] != val) {
 761           if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, nreg_lo)) {
 762             j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 763           } else {
 764             regnd.map(nreg   , n );
 765             regnd.map(nreg_lo, n );
 766             value.map(nreg   ,val);
 767             value.map(nreg_lo,val);
 768           }
 769         } else if (!may_be_copy_of_callee(n)) {
 770           assert(n->is_Copy(), "");
 771           j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
 772         }
 773       }
 774 
 775       // Fat projections kill many registers
 776       if( n_ideal_reg == static_cast<Opcodes>(MachProjNode::projType::fat_proj) ) {
 777         RegMask rm = n->out_RegMask();
 778         // wow, what an expensive iterator...
 779         nreg = rm.find_first_elem();
 780         while( OptoReg::is_valid(nreg)) {
 781           rm.Remove(nreg);
 782           value.map(nreg,n);
 783           regnd.map(nreg,n);
 784           nreg = rm.find_first_elem();
 785         }
 786       }
 787 
 788     } // End of for all instructions in the block
 789 
 790   } // End for all blocks
 791 }
< prev index next >