Mercurial > hg > truffle
comparison src/share/vm/opto/loopTransform.cpp @ 6144:5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
Summary: replace frequent C2 optimizer code patterns with new methods calls
Reviewed-by: kvn, twisti
Contributed-by: vladimir.x.ivanov@oracle.com
author | kvn |
---|---|
date | Tue, 12 Jun 2012 16:23:31 -0700 |
parents | da6a29fb0da5 |
children | 0acd345fd810 |
comparison
equal
deleted
inserted
replaced
6143:8b0a4867acf0 | 6144:5e990493719e |
---|---|
959 _igvn.register_new_node_with_optimizer( zer_iff ); | 959 _igvn.register_new_node_with_optimizer( zer_iff ); |
960 set_idom(zer_iff, new_main_exit, dd_main_exit); | 960 set_idom(zer_iff, new_main_exit, dd_main_exit); |
961 set_loop(zer_iff, loop->_parent); | 961 set_loop(zer_iff, loop->_parent); |
962 | 962 |
963 // Plug in the false-path, taken if we need to skip post-loop | 963 // Plug in the false-path, taken if we need to skip post-loop |
964 _igvn.hash_delete( main_exit ); | 964 _igvn.replace_input_of(main_exit, 0, zer_iff); |
965 main_exit->set_req(0, zer_iff); | |
966 _igvn._worklist.push(main_exit); | |
967 set_idom(main_exit, zer_iff, dd_main_exit); | 965 set_idom(main_exit, zer_iff, dd_main_exit); |
968 set_idom(main_exit->unique_out(), zer_iff, dd_main_exit); | 966 set_idom(main_exit->unique_out(), zer_iff, dd_main_exit); |
969 // Make the true-path, must enter the post loop | 967 // Make the true-path, must enter the post loop |
970 Node *zer_taken = new (C, 1) IfTrueNode( zer_iff ); | 968 Node *zer_taken = new (C, 1) IfTrueNode( zer_iff ); |
971 _igvn.register_new_node_with_optimizer( zer_taken ); | 969 _igvn.register_new_node_with_optimizer( zer_taken ); |
1954 | 1952 |
1955 // Kill the eliminated test | 1953 // Kill the eliminated test |
1956 C->set_major_progress(); | 1954 C->set_major_progress(); |
1957 Node *kill_con = _igvn.intcon( 1-flip ); | 1955 Node *kill_con = _igvn.intcon( 1-flip ); |
1958 set_ctrl(kill_con, C->root()); | 1956 set_ctrl(kill_con, C->root()); |
1959 _igvn.hash_delete(iff); | 1957 _igvn.replace_input_of(iff, 1, kill_con); |
1960 iff->set_req(1, kill_con); | |
1961 _igvn._worklist.push(iff); | |
1962 // Find surviving projection | 1958 // Find surviving projection |
1963 assert(iff->is_If(), ""); | 1959 assert(iff->is_If(), ""); |
1964 ProjNode* dp = ((IfNode*)iff)->proj_out(1-flip); | 1960 ProjNode* dp = ((IfNode*)iff)->proj_out(1-flip); |
1965 // Find loads off the surviving projection; remove their control edge | 1961 // Find loads off the surviving projection; remove their control edge |
1966 for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) { | 1962 for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) { |
1967 Node* cd = dp->fast_out(i); // Control-dependent node | 1963 Node* cd = dp->fast_out(i); // Control-dependent node |
1968 if( cd->is_Load() ) { // Loads can now float around in the loop | 1964 if( cd->is_Load() ) { // Loads can now float around in the loop |
1969 _igvn.hash_delete(cd); | |
1970 // Allow the load to float around in the loop, or before it | 1965 // Allow the load to float around in the loop, or before it |
1971 // but NOT before the pre-loop. | 1966 // but NOT before the pre-loop. |
1972 cd->set_req(0, ctrl); // ctrl, not NULL | 1967 _igvn.replace_input_of(cd, 0, ctrl); // ctrl, not NULL |
1973 _igvn._worklist.push(cd); | |
1974 --i; | 1968 --i; |
1975 --imax; | 1969 --imax; |
1976 } | 1970 } |
1977 } | 1971 } |
1978 | 1972 |
2027 main_cmp = main_cmp->clone();// Clone a private CmpNode | 2021 main_cmp = main_cmp->clone();// Clone a private CmpNode |
2028 register_new_node( main_cmp, main_cle->in(0) ); | 2022 register_new_node( main_cmp, main_cle->in(0) ); |
2029 main_bol->set_req(1,main_cmp); | 2023 main_bol->set_req(1,main_cmp); |
2030 } | 2024 } |
2031 // Hack the now-private loop bounds | 2025 // Hack the now-private loop bounds |
2032 _igvn.hash_delete(main_cmp); | 2026 _igvn.replace_input_of(main_cmp, 2, main_limit); |
2033 main_cmp->set_req(2, main_limit); | |
2034 _igvn._worklist.push(main_cmp); | |
2035 // The OpaqueNode is unshared by design | 2027 // The OpaqueNode is unshared by design |
2036 _igvn.hash_delete(opqzm); | |
2037 assert( opqzm->outcnt() == 1, "cannot hack shared node" ); | 2028 assert( opqzm->outcnt() == 1, "cannot hack shared node" ); |
2038 opqzm->set_req(1,main_limit); | 2029 _igvn.replace_input_of(opqzm, 1, main_limit); |
2039 _igvn._worklist.push(opqzm); | |
2040 } | 2030 } |
2041 | 2031 |
2042 //------------------------------DCE_loop_body---------------------------------- | 2032 //------------------------------DCE_loop_body---------------------------------- |
2043 // Remove simplistic dead code from loop body | 2033 // Remove simplistic dead code from loop body |
2044 void IdealLoopTree::DCE_loop_body() { | 2034 void IdealLoopTree::DCE_loop_body() { |
2176 if (exact_limit != cl->limit()) { | 2166 if (exact_limit != cl->limit()) { |
2177 // We also need to replace the original limit to collapse loop exit. | 2167 // We also need to replace the original limit to collapse loop exit. |
2178 Node* cmp = cl->loopexit()->cmp_node(); | 2168 Node* cmp = cl->loopexit()->cmp_node(); |
2179 assert(cl->limit() == cmp->in(2), "sanity"); | 2169 assert(cl->limit() == cmp->in(2), "sanity"); |
2180 phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist | 2170 phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist |
2181 phase->_igvn.hash_delete(cmp); | 2171 phase->_igvn.replace_input_of(cmp, 2, exact_limit); // put cmp on worklist |
2182 cmp->set_req(2, exact_limit); | |
2183 phase->_igvn._worklist.push(cmp); // put cmp on worklist | |
2184 } | 2172 } |
2185 // Note: the final value after increment should not overflow since | 2173 // Note: the final value after increment should not overflow since |
2186 // counted loop has limit check predicate. | 2174 // counted loop has limit check predicate. |
2187 Node *final = new (phase->C, 3) SubINode( exact_limit, cl->stride() ); | 2175 Node *final = new (phase->C, 3) SubINode( exact_limit, cl->stride() ); |
2188 phase->register_new_node(final,cl->in(LoopNode::EntryControl)); | 2176 phase->register_new_node(final,cl->in(LoopNode::EntryControl)); |