< 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 RegionNode* PhaseIdealLoop::split_thru_region(Node* n, RegionNode* region) {
 35   assert(n->is_CFG(), "");
 36   RegionNode* r = new RegionNode(region->req());
 37   IdealLoopTree* loop = get_loop(n);
 38   for (uint i = 1; i < region->req(); i++) {
 39     Node* x = n->clone();
 40     Node* in0 = n->in(0);
 41     if (in0->in(0) == region) x->set_req(0, in0->in(i));
 42     for (uint j = 1; j < n->req(); j++) {
 43       Node* in = n->in(j);
 44       if (get_ctrl(in) == region) {
 45         x->set_req(j, in->in(i));
 46       }
 47     }

476       Node* n = region->out(i);
477       if( n == region ) continue;
478       // The IF to be split is OK.
479       if( n == iff ) continue;
480       if( !n->is_Phi() ) {      // Found pinned memory op or such
481         if (split_up(n, region, iff)) {
482           i = region->refresh_out_pos(i);
483           progress = true;
484         }
485         continue;
486       }
487       assert( n->in(0) == region, "" );
488 
489       // Recursively split up all users of a Phi
490       for (j = n->outs(); n->has_out(j); j++) {
491         Node* m = n->out(j);
492         // If m is dead, throw it away, and declare progress
493         if (_nodes[m->_idx] == NULL) {
494           _igvn.remove_dead_node(m);
495           // fall through
496         }
497         else if (m != iff && split_up(m, region, iff)) {
498           // fall through
499         } else {
500           continue;
501         }
502         // Something unpredictable changed.
503         // Tell the iterators to refresh themselves, and rerun the loop.
504         i = region->refresh_out_pos(i);
505         j = region->refresh_out_pos(j);
506         progress = true;
507       }
508     }
509   }
510 
511   // Now we have no instructions in the block containing the IF.
512   // Split the IF.
513   RegionNode *new_iff = split_thru_region(iff, region);
514 
515   // Replace both uses of 'new_iff' with Regions merging True/False
516   // paths.  This makes 'new_iff' go dead.
517   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 RegionNode* PhaseIdealLoop::split_thru_region(Node* n, RegionNode* region) {
 36   assert(n->is_CFG(), "");
 37   RegionNode* r = new RegionNode(region->req());
 38   IdealLoopTree* loop = get_loop(n);
 39   for (uint i = 1; i < region->req(); i++) {
 40     Node* x = n->clone();
 41     Node* in0 = n->in(0);
 42     if (in0->in(0) == region) x->set_req(0, in0->in(i));
 43     for (uint j = 1; j < n->req(); j++) {
 44       Node* in = n->in(j);
 45       if (get_ctrl(in) == region) {
 46         x->set_req(j, in->in(i));
 47       }
 48     }

477       Node* n = region->out(i);
478       if( n == region ) continue;
479       // The IF to be split is OK.
480       if( n == iff ) continue;
481       if( !n->is_Phi() ) {      // Found pinned memory op or such
482         if (split_up(n, region, iff)) {
483           i = region->refresh_out_pos(i);
484           progress = true;
485         }
486         continue;
487       }
488       assert( n->in(0) == region, "" );
489 
490       // Recursively split up all users of a Phi
491       for (j = n->outs(); n->has_out(j); j++) {
492         Node* m = n->out(j);
493         // If m is dead, throw it away, and declare progress
494         if (_nodes[m->_idx] == NULL) {
495           _igvn.remove_dead_node(m);
496           // fall through
497         } else if (m != iff && split_up(m, region, iff)) {

498           // fall through
499         } else {
500           continue;
501         }
502         // Something unpredictable changed.
503         // Tell the iterators to refresh themselves, and rerun the loop.
504         i = region->refresh_out_pos(i);
505         j = region->refresh_out_pos(j);
506         progress = true;
507       }
508     }
509   }
510 
511   // Now we have no instructions in the block containing the IF.
512   // Split the IF.
513   RegionNode *new_iff = split_thru_region(iff, region);
514 
515   // Replace both uses of 'new_iff' with Regions merging True/False
516   // paths.  This makes 'new_iff' go dead.
517   Node *old_false = NULL, *old_true = NULL;
< prev index next >