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

src/share/vm/opto/coalesce.cpp

Print this page

        

*** 50,60 **** uint j; Block *b = _phc._cfg._blocks[i]; // Print a nice block header tty->print("B%d: ",b->_pre_order); for( j=1; j<b->num_preds(); j++ ) ! tty->print("B%d ", _phc._cfg._bbs[b->pred(j)->_idx]->_pre_order); tty->print("-> "); for( j=0; j<b->_num_succs; j++ ) tty->print("B%d ",b->_succs[j]->_pre_order); tty->print(" IDom: B%d/#%d\n", b->_idom ? b->_idom->_pre_order : 0, b->_dom_depth); uint cnt = b->_nodes.size(); --- 50,60 ---- uint j; Block *b = _phc._cfg._blocks[i]; // Print a nice block header tty->print("B%d: ",b->_pre_order); for( j=1; j<b->num_preds(); j++ ) ! tty->print("B%d ", _phc._cfg.get_block_for_node(b->pred(j))->_pre_order); tty->print("-> "); for( j=0; j<b->_num_succs; j++ ) tty->print("B%d ",b->_succs[j]->_pre_order); tty->print(" IDom: B%d/#%d\n", b->_idom ? b->_idom->_pre_order : 0, b->_dom_depth); uint cnt = b->_nodes.size();
*** 206,216 **** // Insert new temp between copy and source tmp ->set_req(idx,copy->in(idx)); copy->set_req(idx,tmp); // Save source in temp early, before source is killed b->_nodes.insert(kill_src_idx,tmp); ! _phc._cfg._bbs.map( tmp->_idx, b ); last_use_idx++; } // Insert just after last use b->_nodes.insert(last_use_idx+1,copy); --- 206,216 ---- // Insert new temp between copy and source tmp ->set_req(idx,copy->in(idx)); copy->set_req(idx,tmp); // Save source in temp early, before source is killed b->_nodes.insert(kill_src_idx,tmp); ! _phc._cfg.map_node_to_block(tmp, b); last_use_idx++; } // Insert just after last use b->_nodes.insert(last_use_idx+1,copy);
*** 284,294 **** // Check for mismatch inputs to Phi for (uint j = 1; j < cnt; j++) { Node *m = n->in(j); uint src_name = _phc._lrg_map.find(m); if (src_name != phi_name) { ! Block *pred = _phc._cfg._bbs[b->pred(j)->_idx]; Node *copy; assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach"); // Rematerialize constants instead of copying them if( m->is_Mach() && m->as_Mach()->is_Con() && m->as_Mach()->rematerialize() ) { --- 284,294 ---- // Check for mismatch inputs to Phi for (uint j = 1; j < cnt; j++) { Node *m = n->in(j); uint src_name = _phc._lrg_map.find(m); if (src_name != phi_name) { ! Block *pred = _phc._cfg.get_block_for_node(b->pred(j)); Node *copy; assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach"); // Rematerialize constants instead of copying them if( m->is_Mach() && m->as_Mach()->is_Con() && m->as_Mach()->rematerialize() ) {
*** 303,313 **** // Find a good place to insert. Kinda tricky, use a subroutine insert_copy_with_overlap(pred,copy,phi_name,src_name); } // Insert the copy in the use-def chain n->set_req(j, copy); ! _phc._cfg._bbs.map( copy->_idx, pred ); // Extend ("register allocate") the names array for the copy. _phc._lrg_map.extend(copy->_idx, phi_name); } // End of if Phi names do not match } // End of for all inputs to Phi } else { // End of if Phi --- 303,313 ---- // Find a good place to insert. Kinda tricky, use a subroutine insert_copy_with_overlap(pred,copy,phi_name,src_name); } // Insert the copy in the use-def chain n->set_req(j, copy); ! _phc._cfg.map_node_to_block(copy, pred); // Extend ("register allocate") the names array for the copy. _phc._lrg_map.extend(copy->_idx, phi_name); } // End of if Phi names do not match } // End of for all inputs to Phi } else { // End of if Phi
*** 341,357 **** } // Insert the copy in the use-def chain n->set_req(idx, copy); // Extend ("register allocate") the names array for the copy. _phc._lrg_map.extend(copy->_idx, name); ! _phc._cfg._bbs.map( copy->_idx, b ); } } // End of is two-adr // Insert a copy at a debug use for a lrg which has high frequency ! if (b->_freq < OPTO_DEBUG_SPLIT_FREQ || b->is_uncommon(_phc._cfg._bbs)) { // Walk the debug inputs to the node and check for lrg freq JVMState* jvms = n->jvms(); uint debug_start = jvms ? jvms->debug_start() : 999999; uint debug_end = jvms ? jvms->debug_end() : 999999; for(uint inpidx = debug_start; inpidx < debug_end; inpidx++) { --- 341,357 ---- } // Insert the copy in the use-def chain n->set_req(idx, copy); // Extend ("register allocate") the names array for the copy. _phc._lrg_map.extend(copy->_idx, name); ! _phc._cfg.map_node_to_block(copy, b); } } // End of is two-adr // Insert a copy at a debug use for a lrg which has high frequency ! if (b->_freq < OPTO_DEBUG_SPLIT_FREQ || b->is_uncommon(&_phc._cfg)) { // Walk the debug inputs to the node and check for lrg freq JVMState* jvms = n->jvms(); uint debug_start = jvms ? jvms->debug_start() : 999999; uint debug_end = jvms ? jvms->debug_end() : 999999; for(uint inpidx = debug_start; inpidx < debug_end; inpidx++) {
*** 389,399 **** b->_nodes.insert( l++, copy ); // Extend ("register allocate") the names array for the copy. uint max_lrg_id = _phc._lrg_map.max_lrg_id(); _phc.new_lrg(copy, max_lrg_id); _phc._lrg_map.set_max_lrg_id(max_lrg_id + 1); ! _phc._cfg._bbs.map(copy->_idx, b); //tty->print_cr("Split a debug use in Aggressive Coalesce"); } // End of if high frequency use/def } // End of for all debug inputs } // End of if low frequency safepoint --- 389,399 ---- b->_nodes.insert( l++, copy ); // Extend ("register allocate") the names array for the copy. uint max_lrg_id = _phc._lrg_map.max_lrg_id(); _phc.new_lrg(copy, max_lrg_id); _phc._lrg_map.set_max_lrg_id(max_lrg_id + 1); ! _phc._cfg.map_node_to_block(copy, b); //tty->print_cr("Split a debug use in Aggressive Coalesce"); } // End of if high frequency use/def } // End of for all debug inputs } // End of if low frequency safepoint
*** 435,445 **** uint i; for( i=0; i<b->_num_succs; i++ ) { Block *bs = b->_succs[i]; // Find index of 'b' in 'bs' predecessors uint j=1; ! while( _phc._cfg._bbs[bs->pred(j)->_idx] != b ) j++; // Visit all the Phis in successor block for( uint k = 1; k<bs->_nodes.size(); k++ ) { Node *n = bs->_nodes[k]; if( !n->is_Phi() ) break; combine_these_two( n, n->in(j) ); --- 435,448 ---- uint i; for( i=0; i<b->_num_succs; i++ ) { Block *bs = b->_succs[i]; // Find index of 'b' in 'bs' predecessors uint j=1; ! while (_phc._cfg.get_block_for_node(bs->pred(j)) != b) { ! j++; ! } ! // Visit all the Phis in successor block for( uint k = 1; k<bs->_nodes.size(); k++ ) { Node *n = bs->_nodes[k]; if( !n->is_Phi() ) break; combine_these_two( n, n->in(j) );
*** 508,520 **** b->_nodes.remove(bindex); if( bindex < b->_ihrp_index ) b->_ihrp_index--; if( bindex < b->_fhrp_index ) b->_fhrp_index--; // Stretched lr1; add it to liveness of intermediate blocks ! Block *b2 = _phc._cfg._bbs[src_copy->_idx]; while( b != b2 ) { ! b = _phc._cfg._bbs[b->pred(1)->_idx]; _phc._live->live(b)->insert(lr1); } } //------------------------------compute_separating_interferences--------------- --- 511,523 ---- b->_nodes.remove(bindex); if( bindex < b->_ihrp_index ) b->_ihrp_index--; if( bindex < b->_fhrp_index ) b->_fhrp_index--; // Stretched lr1; add it to liveness of intermediate blocks ! Block *b2 = _phc._cfg.get_block_for_node(src_copy); while( b != b2 ) { ! b = _phc._cfg.get_block_for_node(b->pred(1)); _phc._live->live(b)->insert(lr1); } } //------------------------------compute_separating_interferences---------------
*** 530,540 **** while( 1 ) { // Find previous instruction bindex2--; // Chain backwards 1 instruction while( bindex2 == 0 ) { // At block start, find prior block assert( b2->num_preds() == 2, "cannot double coalesce across c-flow" ); ! b2 = _phc._cfg._bbs[b2->pred(1)->_idx]; bindex2 = b2->end_idx()-1; } // Get prior instruction assert(bindex2 < b2->_nodes.size(), "index out of bounds"); Node *x = b2->_nodes[bindex2]; --- 533,543 ---- while( 1 ) { // Find previous instruction bindex2--; // Chain backwards 1 instruction while( bindex2 == 0 ) { // At block start, find prior block assert( b2->num_preds() == 2, "cannot double coalesce across c-flow" ); ! b2 = _phc._cfg.get_block_for_node(b2->pred(1)); bindex2 = b2->end_idx()-1; } // Get prior instruction assert(bindex2 < b2->_nodes.size(), "index out of bounds"); Node *x = b2->_nodes[bindex2];
*** 674,685 **** // Number of bits free uint rm_size = rm.Size(); if (UseFPUForSpilling && rm.is_AllStack() ) { // Don't coalesce when frequency difference is large ! Block *dst_b = _phc._cfg._bbs[dst_copy->_idx]; ! Block *src_def_b = _phc._cfg._bbs[src_def->_idx]; if (src_def_b->_freq > 10*dst_b->_freq ) return false; } // If we can use any stack slot, then effective size is infinite --- 677,688 ---- // Number of bits free uint rm_size = rm.Size(); if (UseFPUForSpilling && rm.is_AllStack() ) { // Don't coalesce when frequency difference is large ! Block *dst_b = _phc._cfg.get_block_for_node(dst_copy); ! Block *src_def_b = _phc._cfg.get_block_for_node(src_def); if (src_def_b->_freq > 10*dst_b->_freq ) return false; } // If we can use any stack slot, then effective size is infinite
*** 688,709 **** if( rm_size == 0 ) return false; // Another early bail-out test is when we are double-coalescing and the // 2 copies are separated by some control flow. if( dst_copy != src_copy ) { ! Block *src_b = _phc._cfg._bbs[src_copy->_idx]; Block *b2 = b; while( b2 != src_b ) { if( b2->num_preds() > 2 ){// Found merge-point _phc._lost_opp_cflow_coalesce++; // extra record_bias commented out because Chris believes it is not // productive. Since we can record only 1 bias, we want to choose one // that stands a chance of working and this one probably does not. //record_bias( _phc._lrgs, lr1, lr2 ); return false; // To hard to find all interferences } ! b2 = _phc._cfg._bbs[b2->pred(1)->_idx]; } } // Union the two interference sets together into '_ulr' uint reg_degree = _ulr.lrg_union( lr1, lr2, rm_size, _phc._ifg, rm ); --- 691,712 ---- if( rm_size == 0 ) return false; // Another early bail-out test is when we are double-coalescing and the // 2 copies are separated by some control flow. if( dst_copy != src_copy ) { ! Block *src_b = _phc._cfg.get_block_for_node(src_copy); Block *b2 = b; while( b2 != src_b ) { if( b2->num_preds() > 2 ){// Found merge-point _phc._lost_opp_cflow_coalesce++; // extra record_bias commented out because Chris believes it is not // productive. Since we can record only 1 bias, we want to choose one // that stands a chance of working and this one probably does not. //record_bias( _phc._lrgs, lr1, lr2 ); return false; // To hard to find all interferences } ! b2 = _phc._cfg.get_block_for_node(b2->pred(1)); } } // Union the two interference sets together into '_ulr' uint reg_degree = _ulr.lrg_union( lr1, lr2, rm_size, _phc._ifg, rm );
*** 784,795 **** //------------------------------coalesce--------------------------------------- // Conservative (but pessimistic) copy coalescing of a single block void PhaseConservativeCoalesce::coalesce( Block *b ) { // Bail out on infrequent blocks ! if( b->is_uncommon(_phc._cfg._bbs) ) return; // Check this block for copies. for( uint i = 1; i<b->end_idx(); i++ ) { // Check for actual copies on inputs. Coalesce a copy into its // input if use and copy's input are compatible. Node *copy1 = b->_nodes[i]; --- 787,799 ---- //------------------------------coalesce--------------------------------------- // Conservative (but pessimistic) copy coalescing of a single block void PhaseConservativeCoalesce::coalesce( Block *b ) { // Bail out on infrequent blocks ! if (b->is_uncommon(&_phc._cfg)) { return; + } // Check this block for copies. for( uint i = 1; i<b->end_idx(); i++ ) { // Check for actual copies on inputs. Coalesce a copy into its // input if use and copy's input are compatible. Node *copy1 = b->_nodes[i];
src/share/vm/opto/coalesce.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File