1434 return dominated_by(prev_dom, igvn);
1435 }
1436
1437 //------------------------------dominated_by-----------------------------------
1438 Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN *igvn) {
1439 #ifndef PRODUCT
1440 if (TraceIterativeGVN) {
1441 tty->print(" Removing IfNode: "); this->dump();
1442 }
1443 if (VerifyOpto && !igvn->allow_progress()) {
1444 // Found an equivalent dominating test,
1445 // we can not guarantee reaching a fix-point for these during iterativeGVN
1446 // since intervening nodes may not change.
1447 return NULL;
1448 }
1449 #endif
1450
1451 igvn->hash_delete(this); // Remove self to prevent spurious V-N
1452 Node *idom = in(0);
1453 // Need opcode to decide which way 'this' test goes
1454 int prev_op = prev_dom->Opcode();
1455 Node *top = igvn->C->top(); // Shortcut to top
1456
1457 // Loop predicates may have depending checks which should not
1458 // be skipped. For example, range check predicate has two checks
1459 // for lower and upper bounds.
1460 ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
1461 if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)
1462 prev_dom = idom;
1463
1464 // Now walk the current IfNode's projections.
1465 // Loop ends when 'this' has no more uses.
1466 for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
1467 Node *ifp = last_out(i); // Get IfTrue/IfFalse
1468 igvn->add_users_to_worklist(ifp);
1469 // Check which projection it is and set target.
1470 // Data-target is either the dominating projection of the same type
1471 // or TOP if the dominating projection is of opposite type.
1472 // Data-target will be used as the new control edge for the non-CFG
1473 // nodes like Casts and Loads.
1474 Node *data_target = (ifp->Opcode() == prev_op) ? prev_dom : top;
1488 } else { // Else, for control producers,
1489 igvn->replace_input_of(s, 0, data_target); // Move child to data-target
1490 }
1491 } // End for each child of a projection
1492
1493 igvn->remove_dead_node(ifp);
1494 } // End for each IfTrue/IfFalse child of If
1495
1496 // Kill the IfNode
1497 igvn->remove_dead_node(this);
1498
1499 // Must return either the original node (now dead) or a new node
1500 // (Do not return a top here, since that would break the uniqueness of top.)
1501 return new ConINode(TypeInt::ZERO);
1502 }
1503
1504 Node* IfNode::search_identical(int dist) {
1505 // Setup to scan up the CFG looking for a dominating test
1506 Node* dom = in(0);
1507 Node* prev_dom = this;
1508 int op = Opcode();
1509 // Search up the dominator tree for an If with an identical test
1510 while (dom->Opcode() != op || // Not same opcode?
1511 dom->in(1) != in(1) || // Not same input 1?
1512 (req() == 3 && dom->in(2) != in(2)) || // Not same input 2?
1513 prev_dom->in(0) != dom) { // One path of test does not dominate?
1514 if (dist < 0) return NULL;
1515
1516 dist--;
1517 prev_dom = dom;
1518 dom = up_one_dom(dom);
1519 if (!dom) return NULL;
1520 }
1521
1522 // Check that we did not follow a loop back to ourselves
1523 if (this == dom) {
1524 return NULL;
1525 }
1526
1527 #ifndef PRODUCT
1528 if (dist > 2) { // Add to count of NULL checks elided
|
1434 return dominated_by(prev_dom, igvn);
1435 }
1436
1437 //------------------------------dominated_by-----------------------------------
1438 Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN *igvn) {
1439 #ifndef PRODUCT
1440 if (TraceIterativeGVN) {
1441 tty->print(" Removing IfNode: "); this->dump();
1442 }
1443 if (VerifyOpto && !igvn->allow_progress()) {
1444 // Found an equivalent dominating test,
1445 // we can not guarantee reaching a fix-point for these during iterativeGVN
1446 // since intervening nodes may not change.
1447 return NULL;
1448 }
1449 #endif
1450
1451 igvn->hash_delete(this); // Remove self to prevent spurious V-N
1452 Node *idom = in(0);
1453 // Need opcode to decide which way 'this' test goes
1454 uint prev_op = prev_dom->Opcode();
1455 Node *top = igvn->C->top(); // Shortcut to top
1456
1457 // Loop predicates may have depending checks which should not
1458 // be skipped. For example, range check predicate has two checks
1459 // for lower and upper bounds.
1460 ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
1461 if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)
1462 prev_dom = idom;
1463
1464 // Now walk the current IfNode's projections.
1465 // Loop ends when 'this' has no more uses.
1466 for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
1467 Node *ifp = last_out(i); // Get IfTrue/IfFalse
1468 igvn->add_users_to_worklist(ifp);
1469 // Check which projection it is and set target.
1470 // Data-target is either the dominating projection of the same type
1471 // or TOP if the dominating projection is of opposite type.
1472 // Data-target will be used as the new control edge for the non-CFG
1473 // nodes like Casts and Loads.
1474 Node *data_target = (ifp->Opcode() == prev_op) ? prev_dom : top;
1488 } else { // Else, for control producers,
1489 igvn->replace_input_of(s, 0, data_target); // Move child to data-target
1490 }
1491 } // End for each child of a projection
1492
1493 igvn->remove_dead_node(ifp);
1494 } // End for each IfTrue/IfFalse child of If
1495
1496 // Kill the IfNode
1497 igvn->remove_dead_node(this);
1498
1499 // Must return either the original node (now dead) or a new node
1500 // (Do not return a top here, since that would break the uniqueness of top.)
1501 return new ConINode(TypeInt::ZERO);
1502 }
1503
1504 Node* IfNode::search_identical(int dist) {
1505 // Setup to scan up the CFG looking for a dominating test
1506 Node* dom = in(0);
1507 Node* prev_dom = this;
1508 uint op = Opcode();
1509 // Search up the dominator tree for an If with an identical test
1510 while (dom->Opcode() != op || // Not same opcode?
1511 dom->in(1) != in(1) || // Not same input 1?
1512 (req() == 3 && dom->in(2) != in(2)) || // Not same input 2?
1513 prev_dom->in(0) != dom) { // One path of test does not dominate?
1514 if (dist < 0) return NULL;
1515
1516 dist--;
1517 prev_dom = dom;
1518 dom = up_one_dom(dom);
1519 if (!dom) return NULL;
1520 }
1521
1522 // Check that we did not follow a loop back to ourselves
1523 if (this == dom) {
1524 return NULL;
1525 }
1526
1527 #ifndef PRODUCT
1528 if (dist > 2) { // Add to count of NULL checks elided
|