< prev index next >

src/hotspot/share/opto/split_if.cpp

Print this page

  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/addnode.hpp"
 28 #include "opto/callnode.hpp"

 29 #include "opto/loopnode.hpp"
 30 #include "opto/movenode.hpp"
 31 #include "opto/node.hpp"
 32 #include "opto/opaquenode.hpp"
 33 #include "opto/predicates.hpp"
 34 
 35 //------------------------------split_thru_region------------------------------
 36 // Split Node 'n' through merge point.
 37 RegionNode* PhaseIdealLoop::split_thru_region(Node* n, RegionNode* region) {
 38   assert(n->is_CFG(), "");
 39   RegionNode* 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));

612       Node* n = region->out(i);
613       if( n == region ) continue;
614       // The IF to be split is OK.
615       if( n == iff ) continue;
616       if( !n->is_Phi() ) {      // Found pinned memory op or such
617         if (split_up(n, region, iff)) {
618           i = region->refresh_out_pos(i);
619           progress = true;
620         }
621         continue;
622       }
623       assert( n->in(0) == region, "" );
624 
625       // Recursively split up all users of a Phi
626       for (j = n->outs(); n->has_out(j); j++) {
627         Node* m = n->out(j);
628         // If m is dead, throw it away, and declare progress
629         if (_loop_or_ctrl[m->_idx] == nullptr) {
630           _igvn.remove_dead_node(m);
631           // fall through
632         }
633         else if (m != iff && split_up(m, region, iff)) {
634           // fall through
635         } else {
636           continue;
637         }
638         // Something unpredictable changed.
639         // Tell the iterators to refresh themselves, and rerun the loop.
640         i = region->refresh_out_pos(i);
641         j = region->refresh_out_pos(j);
642         progress = true;
643       }
644     }
645   }
646 
647   // Now we have no instructions in the block containing the IF.
648   // Split the IF.
649   RegionNode *new_iff = split_thru_region(iff, region);
650 
651   // Replace both uses of 'new_iff' with Regions merging True/False
652   // paths.  This makes 'new_iff' go dead.
653   Node *old_false = nullptr, *old_true = nullptr;

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

613       Node* n = region->out(i);
614       if( n == region ) continue;
615       // The IF to be split is OK.
616       if( n == iff ) continue;
617       if( !n->is_Phi() ) {      // Found pinned memory op or such
618         if (split_up(n, region, iff)) {
619           i = region->refresh_out_pos(i);
620           progress = true;
621         }
622         continue;
623       }
624       assert( n->in(0) == region, "" );
625 
626       // Recursively split up all users of a Phi
627       for (j = n->outs(); n->has_out(j); j++) {
628         Node* m = n->out(j);
629         // If m is dead, throw it away, and declare progress
630         if (_loop_or_ctrl[m->_idx] == nullptr) {
631           _igvn.remove_dead_node(m);
632           // fall through
633         } else if (m != iff && split_up(m, region, iff)) {

634           // fall through
635         } else {
636           continue;
637         }
638         // Something unpredictable changed.
639         // Tell the iterators to refresh themselves, and rerun the loop.
640         i = region->refresh_out_pos(i);
641         j = region->refresh_out_pos(j);
642         progress = true;
643       }
644     }
645   }
646 
647   // Now we have no instructions in the block containing the IF.
648   // Split the IF.
649   RegionNode *new_iff = split_thru_region(iff, region);
650 
651   // Replace both uses of 'new_iff' with Regions merging True/False
652   // paths.  This makes 'new_iff' go dead.
653   Node *old_false = nullptr, *old_true = nullptr;
< prev index next >