hotspot/src/share/vm/opto/reg_split.cpp
changeset 19279 4be3c2e6663c
parent 17877 8ffbff23b733
child 19330 49d6711171e6
equal deleted inserted replaced
19160:6731e700c220 19279:4be3c2e6663c
   130     b = b->_succs[sidx];        // Switch to successor block
   130     b = b->_succs[sidx];        // Switch to successor block
   131     i = 1;                      // Right at start of block
   131     i = 1;                      // Right at start of block
   132   }
   132   }
   133 
   133 
   134   b->_nodes.insert(i,spill);    // Insert node in block
   134   b->_nodes.insert(i,spill);    // Insert node in block
   135   _cfg._bbs.map(spill->_idx,b); // Update node->block mapping to reflect
   135   _cfg.map_node_to_block(spill,  b); // Update node->block mapping to reflect
   136   // Adjust the point where we go hi-pressure
   136   // Adjust the point where we go hi-pressure
   137   if( i <= b->_ihrp_index ) b->_ihrp_index++;
   137   if( i <= b->_ihrp_index ) b->_ihrp_index++;
   138   if( i <= b->_fhrp_index ) b->_fhrp_index++;
   138   if( i <= b->_fhrp_index ) b->_fhrp_index++;
   139 
   139 
   140   // Assign a new Live Range Number to the SpillCopy and grow
   140   // Assign a new Live Range Number to the SpillCopy and grow
   217       if( def_down ) {
   217       if( def_down ) {
   218         // DEF is DOWN, so connect USE directly to the DEF
   218         // DEF is DOWN, so connect USE directly to the DEF
   219         use->set_req(useidx, def);
   219         use->set_req(useidx, def);
   220       } else {
   220       } else {
   221         // Block and index where the use occurs.
   221         // Block and index where the use occurs.
   222         Block *b = _cfg._bbs[use->_idx];
   222         Block *b = _cfg.get_block_for_node(use);
   223         // Put the clone just prior to use
   223         // Put the clone just prior to use
   224         int bindex = b->find_node(use);
   224         int bindex = b->find_node(use);
   225         // DEF is UP, so must copy it DOWN and hook in USE
   225         // DEF is UP, so must copy it DOWN and hook in USE
   226         // Insert SpillCopy before the USE, which uses DEF as its input,
   226         // Insert SpillCopy before the USE, which uses DEF as its input,
   227         // and defs a new live range, which is used by this node.
   227         // and defs a new live range, which is used by this node.
   268 
   268 
   269   // Block and index where the use occurs.
   269   // Block and index where the use occurs.
   270   int bindex;
   270   int bindex;
   271   // Phi input spill-copys belong at the end of the prior block
   271   // Phi input spill-copys belong at the end of the prior block
   272   if( use->is_Phi() ) {
   272   if( use->is_Phi() ) {
   273     b = _cfg._bbs[b->pred(useidx)->_idx];
   273     b = _cfg.get_block_for_node(b->pred(useidx));
   274     bindex = b->end_idx();
   274     bindex = b->end_idx();
   275   } else {
   275   } else {
   276     // Put the clone just prior to use
   276     // Put the clone just prior to use
   277     bindex = b->find_node(use);
   277     bindex = b->find_node(use);
   278   }
   278   }
   333       }
   333       }
   334       if (lrgs(lidx).is_singledef()) {
   334       if (lrgs(lidx).is_singledef()) {
   335         continue;
   335         continue;
   336       }
   336       }
   337 
   337 
   338       Block *b_def = _cfg._bbs[def->_idx];
   338       Block *b_def = _cfg.get_block_for_node(def);
   339       int idx_def = b_def->find_node(def);
   339       int idx_def = b_def->find_node(def);
   340       Node *in_spill = get_spillcopy_wide( in, def, i );
   340       Node *in_spill = get_spillcopy_wide( in, def, i );
   341       if( !in_spill ) return 0; // Bailed out
   341       if( !in_spill ) return 0; // Bailed out
   342       insert_proj(b_def,idx_def,in_spill,maxlrg++);
   342       insert_proj(b_def,idx_def,in_spill,maxlrg++);
   343       if( b_def == b )
   343       if( b_def == b )
   587         // reset the Reaches & UP entries
   587         // reset the Reaches & UP entries
   588         Reachblock[slidx] = lrgs(lidx)._def;
   588         Reachblock[slidx] = lrgs(lidx)._def;
   589         UPblock[slidx] = true;
   589         UPblock[slidx] = true;
   590         // Record following instruction in case 'n' rematerializes and
   590         // Record following instruction in case 'n' rematerializes and
   591         // kills flags
   591         // kills flags
   592         Block *pred1 = _cfg._bbs[b->pred(1)->_idx];
   592         Block *pred1 = _cfg.get_block_for_node(b->pred(1));
   593         continue;
   593         continue;
   594       }
   594       }
   595 
   595 
   596       // Initialize needs_phi and needs_split
   596       // Initialize needs_phi and needs_split
   597       bool needs_phi = false;
   597       bool needs_phi = false;
   599       bool has_phi = false;
   599       bool has_phi = false;
   600       // Walk the predecessor blocks to check inputs for that live range
   600       // Walk the predecessor blocks to check inputs for that live range
   601       // Grab predecessor block header
   601       // Grab predecessor block header
   602       n1 = b->pred(1);
   602       n1 = b->pred(1);
   603       // Grab the appropriate reaching def info for inpidx
   603       // Grab the appropriate reaching def info for inpidx
   604       pred = _cfg._bbs[n1->_idx];
   604       pred = _cfg.get_block_for_node(n1);
   605       pidx = pred->_pre_order;
   605       pidx = pred->_pre_order;
   606       Node **Ltmp = Reaches[pidx];
   606       Node **Ltmp = Reaches[pidx];
   607       bool  *Utmp = UP[pidx];
   607       bool  *Utmp = UP[pidx];
   608       n1 = Ltmp[slidx];
   608       n1 = Ltmp[slidx];
   609       u1 = Utmp[slidx];
   609       u1 = Utmp[slidx];
   614       // Compare inputs to see if a Phi is needed
   614       // Compare inputs to see if a Phi is needed
   615       for( inpidx = 2; inpidx < b->num_preds(); inpidx++ ) {
   615       for( inpidx = 2; inpidx < b->num_preds(); inpidx++ ) {
   616         // Grab predecessor block headers
   616         // Grab predecessor block headers
   617         n2 = b->pred(inpidx);
   617         n2 = b->pred(inpidx);
   618         // Grab the appropriate reaching def info for inpidx
   618         // Grab the appropriate reaching def info for inpidx
   619         pred = _cfg._bbs[n2->_idx];
   619         pred = _cfg.get_block_for_node(n2);
   620         pidx = pred->_pre_order;
   620         pidx = pred->_pre_order;
   621         Ltmp = Reaches[pidx];
   621         Ltmp = Reaches[pidx];
   622         Utmp = UP[pidx];
   622         Utmp = UP[pidx];
   623         n2 = Ltmp[slidx];
   623         n2 = Ltmp[slidx];
   624         u2 = Utmp[slidx];
   624         u2 = Utmp[slidx];
   699       // Do not need a phi, so grab the reaching DEF
   699       // Do not need a phi, so grab the reaching DEF
   700       else {
   700       else {
   701         // Grab predecessor block header
   701         // Grab predecessor block header
   702         n1 = b->pred(1);
   702         n1 = b->pred(1);
   703         // Grab the appropriate reaching def info for k
   703         // Grab the appropriate reaching def info for k
   704         pred = _cfg._bbs[n1->_idx];
   704         pred = _cfg.get_block_for_node(n1);
   705         pidx = pred->_pre_order;
   705         pidx = pred->_pre_order;
   706         Node **Ltmp = Reaches[pidx];
   706         Node **Ltmp = Reaches[pidx];
   707         bool  *Utmp = UP[pidx];
   707         bool  *Utmp = UP[pidx];
   708         // reset the Reaches & UP entries
   708         // reset the Reaches & UP entries
   709         Reachblock[slidx] = Ltmp[slidx];
   709         Reachblock[slidx] = Ltmp[slidx];
   917               def = clone_node(def, b, C);
   917               def = clone_node(def, b, C);
   918               if (def == NULL || C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
   918               if (def == NULL || C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
   919                 return 0;
   919                 return 0;
   920               }
   920               }
   921               _lrg_map.extend(def->_idx, 0);
   921               _lrg_map.extend(def->_idx, 0);
   922               _cfg._bbs.map(def->_idx,b);
   922               _cfg.map_node_to_block(def, b);
   923               n->set_req(inpidx, def);
   923               n->set_req(inpidx, def);
   924               continue;
   924               continue;
   925             }
   925             }
   926 
   926 
   927             // Rematerializable?  Then clone def at use site instead
   927             // Rematerializable?  Then clone def at use site instead
  1289   // Walk the phis list to patch inputs, split phis, and name phis
  1289   // Walk the phis list to patch inputs, split phis, and name phis
  1290   uint lrgs_before_phi_split = maxlrg;
  1290   uint lrgs_before_phi_split = maxlrg;
  1291   for( insidx = 0; insidx < phis->size(); insidx++ ) {
  1291   for( insidx = 0; insidx < phis->size(); insidx++ ) {
  1292     Node *phi = phis->at(insidx);
  1292     Node *phi = phis->at(insidx);
  1293     assert(phi->is_Phi(),"This list must only contain Phi Nodes");
  1293     assert(phi->is_Phi(),"This list must only contain Phi Nodes");
  1294     Block *b = _cfg._bbs[phi->_idx];
  1294     Block *b = _cfg.get_block_for_node(phi);
  1295     // Grab the live range number
  1295     // Grab the live range number
  1296     uint lidx = _lrg_map.find_id(phi);
  1296     uint lidx = _lrg_map.find_id(phi);
  1297     uint slidx = lrg2reach[lidx];
  1297     uint slidx = lrg2reach[lidx];
  1298     // Update node to lidx map
  1298     // Update node to lidx map
  1299     new_lrg(phi, maxlrg++);
  1299     new_lrg(phi, maxlrg++);
  1313     // Walk the predecessor blocks and assign the reaching def to the Phi.
  1313     // Walk the predecessor blocks and assign the reaching def to the Phi.
  1314     // Split Phi nodes by placing USE side splits wherever the reaching
  1314     // Split Phi nodes by placing USE side splits wherever the reaching
  1315     // DEF has the wrong UP/DOWN value.
  1315     // DEF has the wrong UP/DOWN value.
  1316     for( uint i = 1; i < b->num_preds(); i++ ) {
  1316     for( uint i = 1; i < b->num_preds(); i++ ) {
  1317       // Get predecessor block pre-order number
  1317       // Get predecessor block pre-order number
  1318       Block *pred = _cfg._bbs[b->pred(i)->_idx];
  1318       Block *pred = _cfg.get_block_for_node(b->pred(i));
  1319       pidx = pred->_pre_order;
  1319       pidx = pred->_pre_order;
  1320       // Grab reaching def
  1320       // Grab reaching def
  1321       Node *def = Reaches[pidx][slidx];
  1321       Node *def = Reaches[pidx][slidx];
  1322       assert( def, "must have reaching def" );
  1322       assert( def, "must have reaching def" );
  1323       // If input up/down sense and reg-pressure DISagree
  1323       // If input up/down sense and reg-pressure DISagree