src/share/vm/opto/coalesce.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/coalesce.cpp

Print this page




 264           l--;
 265           continue;
 266         }
 267       }
 268 
 269       if (n->is_Phi()) {
 270         // Get the chosen name for the Phi
 271         uint phi_name = _phc._lrg_map.find(n);
 272         // Ignore the pre-allocated specials
 273         if (!phi_name) {
 274           continue;
 275         }
 276         // Check for mismatch inputs to Phi
 277         for (uint j = 1; j < cnt; j++) {
 278           Node *m = n->in(j);
 279           uint src_name = _phc._lrg_map.find(m);
 280           if (src_name != phi_name) {
 281             Block *pred = _phc._cfg.get_block_for_node(b->pred(j));
 282             Node *copy;
 283             assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach");
 284             // Rematerialize constants instead of copying them
 285             if( m->is_Mach() && m->as_Mach()->is_Con() &&
 286                 m->as_Mach()->rematerialize() ) {


 287               copy = m->clone();
 288               // Insert the copy in the predecessor basic block
 289               pred->add_inst(copy);
 290               // Copy any flags as well
 291               _phc.clone_projs(pred, pred->end_idx(), m, copy, _phc._lrg_map);
 292             } else {
 293               const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()];
 294               copy = new MachSpillCopyNode(MachSpillCopyNode::PhiInput, m, *rm, *rm);
 295               // Find a good place to insert.  Kinda tricky, use a subroutine
 296               insert_copy_with_overlap(pred,copy,phi_name,src_name);
 297             }
 298             // Insert the copy in the use-def chain
 299             n->set_req(j, copy);
 300             _phc._cfg.map_node_to_block(copy, pred);
 301             // Extend ("register allocate") the names array for the copy.
 302             _phc._lrg_map.extend(copy->_idx, phi_name);
 303           } // End of if Phi names do not match
 304         } // End of for all inputs to Phi
 305       } else { // End of if Phi
 306 
 307         // Now check for 2-address instructions
 308         uint idx;
 309         if( n->is_Mach() && (idx=n->as_Mach()->two_adr()) ) {
 310           // Get the chosen name for the Node
 311           uint name = _phc._lrg_map.find(n);
 312           assert (name, "no 2-address specials");
 313           // Check for name mis-match on the 2-address input
 314           Node *m = n->in(idx);
 315           if (_phc._lrg_map.find(m) != name) {
 316             Node *copy;
 317             assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach");
 318             // At this point it is unsafe to extend live ranges (6550579).
 319             // Rematerialize only constants as we do for Phi above.
 320             if(m->is_Mach() && m->as_Mach()->is_Con() &&
 321                m->as_Mach()->rematerialize()) {
 322               copy = m->clone();
 323               // Insert the copy in the basic block, just before us
 324               b->insert_node(copy, l++);
 325               l += _phc.clone_projs(b, l, m, copy, _phc._lrg_map);
 326             } else {
 327               const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()];
 328               copy = new MachSpillCopyNode(MachSpillCopyNode::TwoAddress, m, *rm, *rm);
 329               // Insert the copy in the basic block, just before us
 330               b->insert_node(copy, l++);
 331             }
 332             // Insert the copy in the use-def chain
 333             n->set_req(idx, copy);
 334             // Extend ("register allocate") the names array for the copy.
 335             _phc._lrg_map.extend(copy->_idx, name);
 336             _phc._cfg.map_node_to_block(copy, b);
 337           }
 338 
 339         } // End of is two-adr
 340 




 264           l--;
 265           continue;
 266         }
 267       }
 268 
 269       if (n->is_Phi()) {
 270         // Get the chosen name for the Phi
 271         uint phi_name = _phc._lrg_map.find(n);
 272         // Ignore the pre-allocated specials
 273         if (!phi_name) {
 274           continue;
 275         }
 276         // Check for mismatch inputs to Phi
 277         for (uint j = 1; j < cnt; j++) {
 278           Node *m = n->in(j);
 279           uint src_name = _phc._lrg_map.find(m);
 280           if (src_name != phi_name) {
 281             Block *pred = _phc._cfg.get_block_for_node(b->pred(j));
 282             Node *copy;
 283             assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach");
 284             // Rematerialize constants instead of copying them.
 285             // We do this only for immediate constants, we avoid constant table loads
 286             // because that will unsafely extend the live range of the constant table base.
 287             if (m->is_Mach() && m->as_Mach()->is_Con() && !m->as_Mach()->is_MachConstant() &&
 288                 m->as_Mach()->rematerialize()) {
 289               copy = m->clone();
 290               // Insert the copy in the predecessor basic block
 291               pred->add_inst(copy);
 292               // Copy any flags as well
 293               _phc.clone_projs(pred, pred->end_idx(), m, copy, _phc._lrg_map);
 294             } else {
 295               const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()];
 296               copy = new MachSpillCopyNode(MachSpillCopyNode::PhiInput, m, *rm, *rm);
 297               // Find a good place to insert.  Kinda tricky, use a subroutine
 298               insert_copy_with_overlap(pred,copy,phi_name,src_name);
 299             }
 300             // Insert the copy in the use-def chain
 301             n->set_req(j, copy);
 302             _phc._cfg.map_node_to_block(copy, pred);
 303             // Extend ("register allocate") the names array for the copy.
 304             _phc._lrg_map.extend(copy->_idx, phi_name);
 305           } // End of if Phi names do not match
 306         } // End of for all inputs to Phi
 307       } else { // End of if Phi
 308 
 309         // Now check for 2-address instructions
 310         uint idx;
 311         if( n->is_Mach() && (idx=n->as_Mach()->two_adr()) ) {
 312           // Get the chosen name for the Node
 313           uint name = _phc._lrg_map.find(n);
 314           assert (name, "no 2-address specials");
 315           // Check for name mis-match on the 2-address input
 316           Node *m = n->in(idx);
 317           if (_phc._lrg_map.find(m) != name) {
 318             Node *copy;
 319             assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach");
 320             // At this point it is unsafe to extend live ranges (6550579).
 321             // Rematerialize only constants as we do for Phi above.
 322             if (m->is_Mach() && m->as_Mach()->is_Con() && !m->as_Mach()->is_MachConstant() &&
 323                 m->as_Mach()->rematerialize()) {
 324               copy = m->clone();
 325               // Insert the copy in the basic block, just before us
 326               b->insert_node(copy, l++);
 327               l += _phc.clone_projs(b, l, m, copy, _phc._lrg_map);
 328             } else {
 329               const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()];
 330               copy = new MachSpillCopyNode(MachSpillCopyNode::TwoAddress, m, *rm, *rm);
 331               // Insert the copy in the basic block, just before us
 332               b->insert_node(copy, l++);
 333             }
 334             // Insert the copy in the use-def chain
 335             n->set_req(idx, copy);
 336             // Extend ("register allocate") the names array for the copy.
 337             _phc._lrg_map.extend(copy->_idx, name);
 338             _phc._cfg.map_node_to_block(copy, b);
 339           }
 340 
 341         } // End of is two-adr
 342 


src/share/vm/opto/coalesce.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File