comparison src/share/vm/opto/cfgnode.cpp @ 4137:04b9a2566eec

Merge with hsx23/hotspot.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 17 Dec 2011 21:40:27 +0100
parents 8c57262447d3
children 35acf8f0a2e4
comparison
equal deleted inserted replaced
3737:9dc19b7d89a3 4137:04b9a2566eec
458 458
459 if (can_reshape && cnt == 1) { 459 if (can_reshape && cnt == 1) {
460 // Is it dead loop? 460 // Is it dead loop?
461 // If it is LoopNopde it had 2 (+1 itself) inputs and 461 // If it is LoopNopde it had 2 (+1 itself) inputs and
462 // one of them was cut. The loop is dead if it was EntryContol. 462 // one of them was cut. The loop is dead if it was EntryContol.
463 assert(!this->is_Loop() || cnt_orig == 3, "Loop node should have 3 inputs"); 463 // Loop node may have only one input because entry path
464 if (this->is_Loop() && del_it == LoopNode::EntryControl || 464 // is removed in PhaseIdealLoop::Dominators().
465 assert(!this->is_Loop() || cnt_orig <= 3, "Loop node should have 3 or less inputs");
466 if (this->is_Loop() && (del_it == LoopNode::EntryControl ||
467 del_it == 0 && is_unreachable_region(phase)) ||
465 !this->is_Loop() && has_phis && is_unreachable_region(phase)) { 468 !this->is_Loop() && has_phis && is_unreachable_region(phase)) {
466 // Yes, the region will be removed during the next step below. 469 // Yes, the region will be removed during the next step below.
467 // Cut the backedge input and remove phis since no data paths left. 470 // Cut the backedge input and remove phis since no data paths left.
468 // We don't cut outputs to other nodes here since we need to put them 471 // We don't cut outputs to other nodes here since we need to put them
469 // on the worklist. 472 // on the worklist.
1347 //------------------------------split_once------------------------------------- 1350 //------------------------------split_once-------------------------------------
1348 // Helper for split_flow_path 1351 // Helper for split_flow_path
1349 static void split_once(PhaseIterGVN *igvn, Node *phi, Node *val, Node *n, Node *newn) { 1352 static void split_once(PhaseIterGVN *igvn, Node *phi, Node *val, Node *n, Node *newn) {
1350 igvn->hash_delete(n); // Remove from hash before hacking edges 1353 igvn->hash_delete(n); // Remove from hash before hacking edges
1351 1354
1352 Node* predicate_proj = NULL;
1353 uint j = 1; 1355 uint j = 1;
1354 for (uint i = phi->req()-1; i > 0; i--) { 1356 for (uint i = phi->req()-1; i > 0; i--) {
1355 if (phi->in(i) == val) { // Found a path with val? 1357 if (phi->in(i) == val) { // Found a path with val?
1356 if (n->is_Region()) {
1357 Node* proj = PhaseIdealLoop::find_predicate(n->in(i));
1358 if (proj != NULL) {
1359 assert(predicate_proj == NULL, "only one predicate entry expected");
1360 predicate_proj = proj;
1361 }
1362 }
1363 // Add to NEW Region/Phi, no DU info 1358 // Add to NEW Region/Phi, no DU info
1364 newn->set_req( j++, n->in(i) ); 1359 newn->set_req( j++, n->in(i) );
1365 // Remove from OLD Region/Phi 1360 // Remove from OLD Region/Phi
1366 n->del_req(i); 1361 n->del_req(i);
1367 } 1362 }
1368 } 1363 }
1369 1364
1370 // Register the new node but do not transform it. Cannot transform until the 1365 // Register the new node but do not transform it. Cannot transform until the
1371 // entire Region/Phi conglomerate has been hacked as a single huge transform. 1366 // entire Region/Phi conglomerate has been hacked as a single huge transform.
1372 igvn->register_new_node_with_optimizer( newn ); 1367 igvn->register_new_node_with_optimizer( newn );
1373
1374 // Clone loop predicates
1375 if (predicate_proj != NULL) {
1376 newn = igvn->clone_loop_predicates(predicate_proj, newn, !n->is_CountedLoop());
1377 }
1378 1368
1379 // Now I can point to the new node. 1369 // Now I can point to the new node.
1380 n->add_req(newn); 1370 n->add_req(newn);
1381 igvn->_worklist.push(n); 1371 igvn->_worklist.push(n);
1382 } 1372 }
1402 if( i >= phi->req() ) // Only split for constants 1392 if( i >= phi->req() ) // Only split for constants
1403 return NULL; 1393 return NULL;
1404 1394
1405 Node *val = phi->in(i); // Constant to split for 1395 Node *val = phi->in(i); // Constant to split for
1406 uint hit = 0; // Number of times it occurs 1396 uint hit = 0; // Number of times it occurs
1397 Node *r = phi->region();
1407 1398
1408 for( ; i < phi->req(); i++ ){ // Count occurrences of constant 1399 for( ; i < phi->req(); i++ ){ // Count occurrences of constant
1409 Node *n = phi->in(i); 1400 Node *n = phi->in(i);
1410 if( !n ) return NULL; 1401 if( !n ) return NULL;
1411 if( phase->type(n) == Type::TOP ) return NULL; 1402 if( phase->type(n) == Type::TOP ) return NULL;
1412 if( phi->in(i) == val ) 1403 if( phi->in(i) == val ) {
1413 hit++; 1404 hit++;
1405 if (PhaseIdealLoop::find_predicate(r->in(i)) != NULL) {
1406 return NULL; // don't split loop entry path
1407 }
1408 }
1414 } 1409 }
1415 1410
1416 if( hit <= 1 || // Make sure we find 2 or more 1411 if( hit <= 1 || // Make sure we find 2 or more
1417 hit == phi->req()-1 ) // and not ALL the same value 1412 hit == phi->req()-1 ) // and not ALL the same value
1418 return NULL; 1413 return NULL;
1419 1414
1420 // Now start splitting out the flow paths that merge the same value. 1415 // Now start splitting out the flow paths that merge the same value.
1421 // Split first the RegionNode. 1416 // Split first the RegionNode.
1422 PhaseIterGVN *igvn = phase->is_IterGVN(); 1417 PhaseIterGVN *igvn = phase->is_IterGVN();
1423 Node *r = phi->region();
1424 RegionNode *newr = new (phase->C, hit+1) RegionNode(hit+1); 1418 RegionNode *newr = new (phase->C, hit+1) RegionNode(hit+1);
1425 split_once(igvn, phi, val, r, newr); 1419 split_once(igvn, phi, val, r, newr);
1426 1420
1427 // Now split all other Phis than this one 1421 // Now split all other Phis than this one
1428 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) { 1422 for (DUIterator_Fast kmax, k = r->fast_outs(kmax); k < kmax; k++) {
1592 return NULL; // Identity will return TOP 1586 return NULL; // Identity will return TOP
1593 } else if (uin != NULL) { 1587 } else if (uin != NULL) {
1594 // Only one not-NULL unique input path is left. 1588 // Only one not-NULL unique input path is left.
1595 // Determine if this input is backedge of a loop. 1589 // Determine if this input is backedge of a loop.
1596 // (Skip new phis which have no uses and dead regions). 1590 // (Skip new phis which have no uses and dead regions).
1597 if( outcnt() > 0 && r->in(0) != NULL ) { 1591 if (outcnt() > 0 && r->in(0) != NULL) {
1598 // First, take the short cut when we know it is a loop and 1592 // First, take the short cut when we know it is a loop and
1599 // the EntryControl data path is dead. 1593 // the EntryControl data path is dead.
1600 assert(!r->is_Loop() || r->req() == 3, "Loop node should have 3 inputs"); 1594 // Loop node may have only one input because entry path
1595 // is removed in PhaseIdealLoop::Dominators().
1596 assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
1597 bool is_loop = (r->is_Loop() && r->req() == 3);
1601 // Then, check if there is a data loop when phi references itself directly 1598 // Then, check if there is a data loop when phi references itself directly
1602 // or through other data nodes. 1599 // or through other data nodes.
1603 if( r->is_Loop() && !phase->eqv_uncast(uin, in(LoopNode::EntryControl)) || 1600 if (is_loop && !phase->eqv_uncast(uin, in(LoopNode::EntryControl)) ||
1604 !r->is_Loop() && is_unsafe_data_reference(uin) ) { 1601 !is_loop && is_unsafe_data_reference(uin)) {
1605 // Break this data loop to avoid creation of a dead loop. 1602 // Break this data loop to avoid creation of a dead loop.
1606 if (can_reshape) { 1603 if (can_reshape) {
1607 return top; 1604 return top;
1608 } else { 1605 } else {
1609 // We can't return top if we are in Parse phase - cut inputs only 1606 // We can't return top if we are in Parse phase - cut inputs only