--- old/src/share/vm/opto/ifnode.cpp 2016-01-04 11:16:09.524964259 +0100 +++ new/src/share/vm/opto/ifnode.cpp 2016-01-04 11:16:09.460964262 +0100 @@ -1530,13 +1530,7 @@ 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)) { + if (t == TypeTuple::IFNEITHER || always_taken(t)) { // IfNode control return in(0)->in(0); } @@ -1544,6 +1538,17 @@ 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