< prev index next >

src/share/vm/opto/ifnode.cpp

Print this page

        

*** 1528,1551 **** //------------------------------Identity--------------------------------------- // If the test is constant & we match, then we are the input Control Node *IfProjNode::Identity(PhaseTransform *phase) { // Can only optimize if cannot go the other way const TypeTuple *t = phase->type(in(0))->is_tuple(); ! if (t == TypeTuple::IFNEITHER || ! // kill dead branch first otherwise the IfNode's control will ! // have 2 control uses (the IfNode that doesn't go away because ! // it still has uses and this branch of the ! // If). Node::has_special_unique_user() will cause this node to ! // be reprocessed once the dead branch is killed. ! (always_taken(t) && in(0)->outcnt() == 1)) { // IfNode control return in(0)->in(0); } // no progress return this; } #ifndef PRODUCT //-------------------------------related--------------------------------------- // An IfProjNode's related node set consists of its input (an IfNode) including // the IfNode's condition, plus all of its outputs at level 1. In compact mode, // the restrictions for IfNode apply (see IfNode::rel). --- 1528,1556 ---- //------------------------------Identity--------------------------------------- // If the test is constant & we match, then we are the input Control Node *IfProjNode::Identity(PhaseTransform *phase) { // Can only optimize if cannot go the other way const TypeTuple *t = phase->type(in(0))->is_tuple(); ! if (t == TypeTuple::IFNEITHER || always_taken(t)) { // IfNode control return in(0)->in(0); } // no progress return this; } + Node* IfProjNode::Ideal(PhaseGVN* phase, bool can_reshape) { + const Type* t = phase->type(in(0)); + if (can_reshape && in(0)->outcnt() == 2 && t != Type::TOP && always_taken(t->is_tuple())) { + // Cut off dead branch if this branch is always taken + Node* other = in(0)->as_If()->proj_out(!is_IfTrue()); + other->set_req(0, phase->C->top()); + return this; + } + return NULL; + } + #ifndef PRODUCT //-------------------------------related--------------------------------------- // An IfProjNode's related node set consists of its input (an IfNode) including // the IfNode's condition, plus all of its outputs at level 1. In compact mode, // the restrictions for IfNode apply (see IfNode::rel).
< prev index next >