< prev index next >

src/hotspot/share/opto/split_if.cpp

Print this page

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "memory/allocation.inline.hpp"
 27 #include "opto/callnode.hpp"

 28 #include "opto/loopnode.hpp"
 29 #include "opto/movenode.hpp"
 30 
 31 
 32 //------------------------------split_thru_region------------------------------
 33 // Split Node 'n' through merge point.
 34 Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
 35   uint wins = 0;
 36   assert( n->is_CFG(), "" );
 37   assert( region->is_Region(), "" );
 38   Node *r = new RegionNode( region->req() );
 39   IdealLoopTree *loop = get_loop( n );
 40   for( uint i = 1; i < region->req(); i++ ) {
 41     Node *x = n->clone();
 42     Node *in0 = n->in(0);
 43     if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
 44     for( uint j = 1; j < n->req(); j++ ) {
 45       Node *in = n->in(j);
 46       if( get_ctrl(in) == region )
 47         x->set_req( j, in->in(i) );

457       Node* n = region->out(i);
458       if( n == region ) continue;
459       // The IF to be split is OK.
460       if( n == iff ) continue;
461       if( !n->is_Phi() ) {      // Found pinned memory op or such
462         if (split_up(n, region, iff)) {
463           i = region->refresh_out_pos(i);
464           progress = true;
465         }
466         continue;
467       }
468       assert( n->in(0) == region, "" );
469 
470       // Recursively split up all users of a Phi
471       for (j = n->outs(); n->has_out(j); j++) {
472         Node* m = n->out(j);
473         // If m is dead, throw it away, and declare progress
474         if (_nodes[m->_idx] == NULL) {
475           _igvn.remove_dead_node(m);
476           // fall through
477         }
478         else if (m != iff && split_up(m, region, iff)) {
479           // fall through
480         } else {
481           continue;
482         }
483         // Something unpredictable changed.
484         // Tell the iterators to refresh themselves, and rerun the loop.
485         i = region->refresh_out_pos(i);
486         j = region->refresh_out_pos(j);
487         progress = true;
488       }
489     }
490   }
491 
492   // Now we have no instructions in the block containing the IF.
493   // Split the IF.
494   Node *new_iff = split_thru_region( iff, region );
495 
496   // Replace both uses of 'new_iff' with Regions merging True/False
497   // paths.  This makes 'new_iff' go dead.
498   Node *old_false = NULL, *old_true = NULL;

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "memory/allocation.inline.hpp"
 27 #include "opto/callnode.hpp"
 28 #include "opto/inlinetypenode.hpp"
 29 #include "opto/loopnode.hpp"
 30 #include "opto/movenode.hpp"
 31 
 32 
 33 //------------------------------split_thru_region------------------------------
 34 // Split Node 'n' through merge point.
 35 Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
 36   uint wins = 0;
 37   assert( n->is_CFG(), "" );
 38   assert( region->is_Region(), "" );
 39   Node *r = new RegionNode( region->req() );
 40   IdealLoopTree *loop = get_loop( n );
 41   for( uint i = 1; i < region->req(); i++ ) {
 42     Node *x = n->clone();
 43     Node *in0 = n->in(0);
 44     if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
 45     for( uint j = 1; j < n->req(); j++ ) {
 46       Node *in = n->in(j);
 47       if( get_ctrl(in) == region )
 48         x->set_req( j, in->in(i) );

458       Node* n = region->out(i);
459       if( n == region ) continue;
460       // The IF to be split is OK.
461       if( n == iff ) continue;
462       if( !n->is_Phi() ) {      // Found pinned memory op or such
463         if (split_up(n, region, iff)) {
464           i = region->refresh_out_pos(i);
465           progress = true;
466         }
467         continue;
468       }
469       assert( n->in(0) == region, "" );
470 
471       // Recursively split up all users of a Phi
472       for (j = n->outs(); n->has_out(j); j++) {
473         Node* m = n->out(j);
474         // If m is dead, throw it away, and declare progress
475         if (_nodes[m->_idx] == NULL) {
476           _igvn.remove_dead_node(m);
477           // fall through
478         } else if (m != iff && split_up(m, region, iff)) {

479           // fall through
480         } else {
481           continue;
482         }
483         // Something unpredictable changed.
484         // Tell the iterators to refresh themselves, and rerun the loop.
485         i = region->refresh_out_pos(i);
486         j = region->refresh_out_pos(j);
487         progress = true;
488       }
489     }
490   }
491 
492   // Now we have no instructions in the block containing the IF.
493   // Split the IF.
494   Node *new_iff = split_thru_region( iff, region );
495 
496   // Replace both uses of 'new_iff' with Regions merging True/False
497   // paths.  This makes 'new_iff' go dead.
498   Node *old_false = NULL, *old_true = NULL;
< prev index next >