< prev index next >

src/share/vm/opto/ifnode.cpp

Print this page
rev 12674 : 8164954: split_if creates empty phi and region nodes
Summary: Don't split if all edges will be moved to new phi
Reviewed-by:


 232   // all the control flow.  Below the original IF we have 2 control
 233   // dependent regions, 's' and 't'.  Now we will merge the two paths
 234   // just prior to 's' and 't' from the two IFs.  At least 1 path (and quite
 235   // likely 2 or more) will promptly constant fold away.
 236   PhaseGVN *phase = igvn;
 237 
 238   // Make a region merging constants and a region merging the rest
 239   uint req_c = 0;
 240   Node* predicate_proj = NULL;
 241   int nb_predicate_proj = 0;
 242   for (uint ii = 1; ii < r->req(); ii++) {
 243     if (phi->in(ii) == con1) {
 244       req_c++;
 245     }
 246     Node* proj = PhaseIdealLoop::find_predicate(r->in(ii));
 247     if (proj != NULL) {
 248       nb_predicate_proj++;
 249       predicate_proj = proj;
 250     }
 251   }







 252   if (nb_predicate_proj > 1) {
 253     // Can happen in case of loop unswitching and when the loop is
 254     // optimized out: it's not a loop anymore so we don't care about
 255     // predicates.
 256     assert(!r->is_Loop(), "this must not be a loop anymore");
 257     predicate_proj = NULL;
 258   }
 259   Node* predicate_c = NULL;
 260   Node* predicate_x = NULL;
 261   bool counted_loop = r->is_CountedLoop();
 262 
 263   Node *region_c = new RegionNode(req_c + 1);
 264   Node *phi_c    = con1;
 265   uint  len      = r->req();
 266   Node *region_x = new RegionNode(len - req_c);
 267   Node *phi_x    = PhiNode::make_blank(region_x, phi);
 268   for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) {
 269     if (phi->in(i) == con1) {
 270       region_c->init_req( i_c++, r  ->in(i) );
 271       if (r->in(i) == predicate_proj)




 232   // all the control flow.  Below the original IF we have 2 control
 233   // dependent regions, 's' and 't'.  Now we will merge the two paths
 234   // just prior to 's' and 't' from the two IFs.  At least 1 path (and quite
 235   // likely 2 or more) will promptly constant fold away.
 236   PhaseGVN *phase = igvn;
 237 
 238   // Make a region merging constants and a region merging the rest
 239   uint req_c = 0;
 240   Node* predicate_proj = NULL;
 241   int nb_predicate_proj = 0;
 242   for (uint ii = 1; ii < r->req(); ii++) {
 243     if (phi->in(ii) == con1) {
 244       req_c++;
 245     }
 246     Node* proj = PhaseIdealLoop::find_predicate(r->in(ii));
 247     if (proj != NULL) {
 248       nb_predicate_proj++;
 249       predicate_proj = proj;
 250     }
 251   }
 252 
 253   // If all the defs of the phi are the same constant, we already have the desired end state.
 254   // Skip the split that would create empty phi and region nodes.
 255   if((r->req() - req_c) == 1) {
 256     return NULL;
 257   }
 258 
 259   if (nb_predicate_proj > 1) {
 260     // Can happen in case of loop unswitching and when the loop is
 261     // optimized out: it's not a loop anymore so we don't care about
 262     // predicates.
 263     assert(!r->is_Loop(), "this must not be a loop anymore");
 264     predicate_proj = NULL;
 265   }
 266   Node* predicate_c = NULL;
 267   Node* predicate_x = NULL;
 268   bool counted_loop = r->is_CountedLoop();
 269 
 270   Node *region_c = new RegionNode(req_c + 1);
 271   Node *phi_c    = con1;
 272   uint  len      = r->req();
 273   Node *region_x = new RegionNode(len - req_c);
 274   Node *phi_x    = PhiNode::make_blank(region_x, phi);
 275   for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) {
 276     if (phi->in(i) == con1) {
 277       region_c->init_req( i_c++, r  ->in(i) );
 278       if (r->in(i) == predicate_proj)


< prev index next >