src/share/vm/opto/ifnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 5091921 Sdiff src/share/vm/opto

src/share/vm/opto/ifnode.cpp

Print this page




 219   // dependent regions, 's' and 't'.  Now we will merge the two paths
 220   // just prior to 's' and 't' from the two IFs.  At least 1 path (and quite
 221   // likely 2 or more) will promptly constant fold away.
 222   PhaseGVN *phase = igvn;
 223 
 224   // Make a region merging constants and a region merging the rest
 225   uint req_c = 0;
 226   Node* predicate_proj = NULL;
 227   for (uint ii = 1; ii < r->req(); ii++) {
 228     if (phi->in(ii) == con1) {
 229       req_c++;
 230     }
 231     Node* proj = PhaseIdealLoop::find_predicate(r->in(ii));
 232     if (proj != NULL) {
 233       assert(predicate_proj == NULL, "only one predicate entry expected");
 234       predicate_proj = proj;
 235     }
 236   }
 237   Node* predicate_c = NULL;
 238   Node* predicate_x = NULL;

 239 
 240   Node *region_c = new (igvn->C, req_c + 1) RegionNode(req_c + 1);
 241   Node *phi_c    = con1;
 242   uint  len      = r->req();
 243   Node *region_x = new (igvn->C, len - req_c) RegionNode(len - req_c);
 244   Node *phi_x    = PhiNode::make_blank(region_x, phi);
 245   for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) {
 246     if (phi->in(i) == con1) {
 247       region_c->init_req( i_c++, r  ->in(i) );
 248       if (r->in(i) == predicate_proj)
 249         predicate_c = predicate_proj;
 250     } else {
 251       region_x->init_req( i_x,   r  ->in(i) );
 252       phi_x   ->init_req( i_x++, phi->in(i) );
 253       if (r->in(i) == predicate_proj)
 254         predicate_x = predicate_proj;
 255     }
 256   }
 257 
 258   // Register the new RegionNodes but do not transform them.  Cannot


 277   // Make the bool
 278   Node *b_c = phase->transform(new (igvn->C, 2) BoolNode(cmp_c,b->_test._test));
 279   Node *b_x = phase->transform(new (igvn->C, 2) BoolNode(cmp_x,b->_test._test));
 280   // Make the IfNode
 281   IfNode *iff_c = new (igvn->C, 2) IfNode(region_c,b_c,iff->_prob,iff->_fcnt);
 282   igvn->set_type_bottom(iff_c);
 283   igvn->_worklist.push(iff_c);
 284   hook->init_req(2, iff_c);
 285 
 286   IfNode *iff_x = new (igvn->C, 2) IfNode(region_x,b_x,iff->_prob, iff->_fcnt);
 287   igvn->set_type_bottom(iff_x);
 288   igvn->_worklist.push(iff_x);
 289   hook->init_req(3, iff_x);
 290 
 291   // Make the true/false arms
 292   Node *iff_c_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_c));
 293   Node *iff_c_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_c));
 294   if (predicate_c != NULL) {
 295     assert(predicate_x == NULL, "only one predicate entry expected");
 296     // Clone loop predicates to each path
 297     iff_c_t = igvn->clone_loop_predicates(predicate_c, iff_c_t);
 298     iff_c_f = igvn->clone_loop_predicates(predicate_c, iff_c_f);
 299   }
 300   Node *iff_x_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_x));
 301   Node *iff_x_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_x));
 302   if (predicate_x != NULL) {
 303     assert(predicate_c == NULL, "only one predicate entry expected");
 304     // Clone loop predicates to each path
 305     iff_x_t = igvn->clone_loop_predicates(predicate_x, iff_x_t);
 306     iff_x_f = igvn->clone_loop_predicates(predicate_x, iff_x_f);
 307   }
 308 
 309   // Merge the TRUE paths
 310   Node *region_s = new (igvn->C, 3) RegionNode(3);
 311   igvn->_worklist.push(region_s);
 312   region_s->init_req(1, iff_c_t);
 313   region_s->init_req(2, iff_x_t);
 314   igvn->register_new_node_with_optimizer( region_s );
 315 
 316   // Merge the FALSE paths
 317   Node *region_f = new (igvn->C, 3) RegionNode(3);
 318   igvn->_worklist.push(region_f);
 319   region_f->init_req(1, iff_c_f);
 320   region_f->init_req(2, iff_x_f);
 321   igvn->register_new_node_with_optimizer( region_f );
 322 
 323   igvn->hash_delete(cmp);// Remove soon-to-be-dead node from hash table.
 324   cmp->set_req(1,NULL);  // Whack the inputs to cmp because it will be dead
 325   cmp->set_req(2,NULL);
 326   // Check for all uses of the Phi and give them a new home.




 219   // dependent regions, 's' and 't'.  Now we will merge the two paths
 220   // just prior to 's' and 't' from the two IFs.  At least 1 path (and quite
 221   // likely 2 or more) will promptly constant fold away.
 222   PhaseGVN *phase = igvn;
 223 
 224   // Make a region merging constants and a region merging the rest
 225   uint req_c = 0;
 226   Node* predicate_proj = NULL;
 227   for (uint ii = 1; ii < r->req(); ii++) {
 228     if (phi->in(ii) == con1) {
 229       req_c++;
 230     }
 231     Node* proj = PhaseIdealLoop::find_predicate(r->in(ii));
 232     if (proj != NULL) {
 233       assert(predicate_proj == NULL, "only one predicate entry expected");
 234       predicate_proj = proj;
 235     }
 236   }
 237   Node* predicate_c = NULL;
 238   Node* predicate_x = NULL;
 239   bool counted_loop = r->is_CountedLoop();
 240 
 241   Node *region_c = new (igvn->C, req_c + 1) RegionNode(req_c + 1);
 242   Node *phi_c    = con1;
 243   uint  len      = r->req();
 244   Node *region_x = new (igvn->C, len - req_c) RegionNode(len - req_c);
 245   Node *phi_x    = PhiNode::make_blank(region_x, phi);
 246   for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) {
 247     if (phi->in(i) == con1) {
 248       region_c->init_req( i_c++, r  ->in(i) );
 249       if (r->in(i) == predicate_proj)
 250         predicate_c = predicate_proj;
 251     } else {
 252       region_x->init_req( i_x,   r  ->in(i) );
 253       phi_x   ->init_req( i_x++, phi->in(i) );
 254       if (r->in(i) == predicate_proj)
 255         predicate_x = predicate_proj;
 256     }
 257   }
 258 
 259   // Register the new RegionNodes but do not transform them.  Cannot


 278   // Make the bool
 279   Node *b_c = phase->transform(new (igvn->C, 2) BoolNode(cmp_c,b->_test._test));
 280   Node *b_x = phase->transform(new (igvn->C, 2) BoolNode(cmp_x,b->_test._test));
 281   // Make the IfNode
 282   IfNode *iff_c = new (igvn->C, 2) IfNode(region_c,b_c,iff->_prob,iff->_fcnt);
 283   igvn->set_type_bottom(iff_c);
 284   igvn->_worklist.push(iff_c);
 285   hook->init_req(2, iff_c);
 286 
 287   IfNode *iff_x = new (igvn->C, 2) IfNode(region_x,b_x,iff->_prob, iff->_fcnt);
 288   igvn->set_type_bottom(iff_x);
 289   igvn->_worklist.push(iff_x);
 290   hook->init_req(3, iff_x);
 291 
 292   // Make the true/false arms
 293   Node *iff_c_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_c));
 294   Node *iff_c_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_c));
 295   if (predicate_c != NULL) {
 296     assert(predicate_x == NULL, "only one predicate entry expected");
 297     // Clone loop predicates to each path
 298     iff_c_t = igvn->clone_loop_predicates(predicate_c, iff_c_t, !counted_loop);
 299     iff_c_f = igvn->clone_loop_predicates(predicate_c, iff_c_f, !counted_loop);
 300   }
 301   Node *iff_x_t = phase->transform(new (igvn->C, 1) IfTrueNode (iff_x));
 302   Node *iff_x_f = phase->transform(new (igvn->C, 1) IfFalseNode(iff_x));
 303   if (predicate_x != NULL) {
 304     assert(predicate_c == NULL, "only one predicate entry expected");
 305     // Clone loop predicates to each path
 306     iff_x_t = igvn->clone_loop_predicates(predicate_x, iff_x_t, !counted_loop);
 307     iff_x_f = igvn->clone_loop_predicates(predicate_x, iff_x_f, !counted_loop);
 308   }
 309 
 310   // Merge the TRUE paths
 311   Node *region_s = new (igvn->C, 3) RegionNode(3);
 312   igvn->_worklist.push(region_s);
 313   region_s->init_req(1, iff_c_t);
 314   region_s->init_req(2, iff_x_t);
 315   igvn->register_new_node_with_optimizer( region_s );
 316 
 317   // Merge the FALSE paths
 318   Node *region_f = new (igvn->C, 3) RegionNode(3);
 319   igvn->_worklist.push(region_f);
 320   region_f->init_req(1, iff_c_f);
 321   region_f->init_req(2, iff_x_f);
 322   igvn->register_new_node_with_optimizer( region_f );
 323 
 324   igvn->hash_delete(cmp);// Remove soon-to-be-dead node from hash table.
 325   cmp->set_req(1,NULL);  // Whack the inputs to cmp because it will be dead
 326   cmp->set_req(2,NULL);
 327   // Check for all uses of the Phi and give them a new home.


src/share/vm/opto/ifnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File