src/share/vm/opto/postaloc.cpp

Print this page
rev 2647 : 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
Summary: PhaseChaitin::yank_if_dead() should be able to handle MachTemp inputs as a special case and yank them.
Reviewed-by:


  55   for( i=0; i < limit; i++ ) {
  56     if( def->is_Proj() && def->in(0)->is_Start() &&
  57         _matcher.is_save_on_entry(lrgs(n2lidx(def)).reg()) )
  58       return true;              // Direct use of callee-save proj
  59     if( def->is_Copy() )        // Copies carry value through
  60       def = def->in(def->is_Copy());
  61     else if( def->is_Phi() )    // Phis can merge it from any direction
  62       def = def->in(1);
  63     else
  64       break;
  65     guarantee(def != NULL, "must not resurrect dead copy");
  66   }
  67   // If we reached the end and didn't find a callee save proj
  68   // then this may be a callee save proj so we return true
  69   // as the conservative answer. If we didn't reach then end
  70   // we must have discovered that it was not a callee save
  71   // else we would have returned.
  72   return i == limit;
  73 }
  74 
  75 
  76 
  77 //------------------------------yank_if_dead-----------------------------------
  78 // Removed an edge from 'old'.  Yank if dead.  Return adjustment counts to
  79 // iterators in the current block.
  80 int PhaseChaitin::yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
  81   int blk_adjust=0;
  82   while (old->outcnt() == 0 && old != C->top()) {
  83     Block *oldb = _cfg._bbs[old->_idx];
  84     oldb->find_remove(old);
  85     // Count 1 if deleting an instruction from the current block
  86     if( oldb == current_block ) blk_adjust++;
  87     _cfg._bbs.map(old->_idx,NULL);
  88     OptoReg::Name old_reg = lrgs(n2lidx(old)).reg();
  89     if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
  90       value->map(old_reg,NULL);  // Yank from value/regnd maps
  91       regnd->map(old_reg,NULL);  // This register's value is now unknown
  92     }
  93     assert(old->req() <= 2, "can't handle more inputs");
  94     Node *tmp = old->req() > 1 ? old->in(1) : NULL;





















  95     old->disconnect_inputs(NULL);
  96     if( !tmp ) break;
  97     old = tmp;
  98   }
  99   return blk_adjust;
 100 }
 101 
 102 //------------------------------use_prior_register-----------------------------
 103 // Use the prior value instead of the current value, in an effort to make
 104 // the current value go dead.  Return block iterator adjustment, in case
 105 // we yank some instructions from this block.
 106 int PhaseChaitin::use_prior_register( Node *n, uint idx, Node *def, Block *current_block, Node_List &value, Node_List &regnd ) {
 107   // No effect?
 108   if( def == n->in(idx) ) return 0;
 109   // Def is currently dead and can be removed?  Do not resurrect
 110   if( def->outcnt() == 0 ) return 0;
 111 
 112   // Not every pair of physical registers are assignment compatible,
 113   // e.g. on sparc floating point registers are not assignable to integer
 114   // registers.




  55   for( i=0; i < limit; i++ ) {
  56     if( def->is_Proj() && def->in(0)->is_Start() &&
  57         _matcher.is_save_on_entry(lrgs(n2lidx(def)).reg()) )
  58       return true;              // Direct use of callee-save proj
  59     if( def->is_Copy() )        // Copies carry value through
  60       def = def->in(def->is_Copy());
  61     else if( def->is_Phi() )    // Phis can merge it from any direction
  62       def = def->in(1);
  63     else
  64       break;
  65     guarantee(def != NULL, "must not resurrect dead copy");
  66   }
  67   // If we reached the end and didn't find a callee save proj
  68   // then this may be a callee save proj so we return true
  69   // as the conservative answer. If we didn't reach then end
  70   // we must have discovered that it was not a callee save
  71   // else we would have returned.
  72   return i == limit;
  73 }
  74 
  75 //------------------------------yank-----------------------------------
  76 // Helper function for yank_if_dead
  77 int PhaseChaitin::yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {



  78   int blk_adjust=0;

  79   Block *oldb = _cfg._bbs[old->_idx];
  80   oldb->find_remove(old);
  81   // Count 1 if deleting an instruction from the current block
  82   if( oldb == current_block ) blk_adjust++;
  83   _cfg._bbs.map(old->_idx,NULL);
  84   OptoReg::Name old_reg = lrgs(n2lidx(old)).reg();
  85   if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
  86     value->map(old_reg,NULL);  // Yank from value/regnd maps
  87     regnd->map(old_reg,NULL);  // This register's value is now unknown
  88   }
  89   return blk_adjust;
  90 }
  91 
  92 //------------------------------yank_if_dead-----------------------------------
  93 // Removed an edge from 'old'.  Yank if dead.  Return adjustment counts to
  94 // iterators in the current block.
  95 int PhaseChaitin::yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
  96   int blk_adjust=0;
  97   while (old->outcnt() == 0 && old != C->top()) {
  98     blk_adjust += yank(old, current_block, value, regnd);
  99 
 100     Node *tmp = NULL;
 101     for (uint i = 1; i < old->req(); i++) {
 102       if (old->in(i)->is_MachTemp()) {
 103         Node* machtmp = old->in(i);
 104         assert(machtmp->outcnt() == 1, "expected for a MachTemp");
 105         blk_adjust += yank(machtmp, current_block, value, regnd);
 106         machtmp->disconnect_inputs(NULL);
 107       } else {
 108         assert(tmp == NULL, "can't handle more non MachTemp inputs");
 109         tmp = old->in(i);
 110       }
 111     }
 112     old->disconnect_inputs(NULL);
 113     if( !tmp ) break;
 114     old = tmp;
 115   }
 116   return blk_adjust;
 117 }
 118 
 119 //------------------------------use_prior_register-----------------------------
 120 // Use the prior value instead of the current value, in an effort to make
 121 // the current value go dead.  Return block iterator adjustment, in case
 122 // we yank some instructions from this block.
 123 int PhaseChaitin::use_prior_register( Node *n, uint idx, Node *def, Block *current_block, Node_List &value, Node_List &regnd ) {
 124   // No effect?
 125   if( def == n->in(idx) ) return 0;
 126   // Def is currently dead and can be removed?  Do not resurrect
 127   if( def->outcnt() == 0 ) return 0;
 128 
 129   // Not every pair of physical registers are assignment compatible,
 130   // e.g. on sparc floating point registers are not assignable to integer
 131   // registers.