--- old/src/share/vm/opto/phaseX.cpp 2014-04-10 17:05:38.577622867 +0200 +++ new/src/share/vm/opto/phaseX.cpp 2014-04-10 17:05:38.509622868 +0200 @@ -1514,6 +1514,26 @@ C->set_root( transform(C->root())->as_Root() ); assert( C->top(), "missing TOP node" ); assert( C->root(), "missing root" ); + + // Eagerly remove castPP nodes here. CastPP nodes might not be + // removed in the subsequent IGVN phase if a node that changes + // in(1) of a castPP is processed prior to the castPP node. + Unique_Node_List to_remove; + for (uint i = 0; i < _worklist.size(); i++) { + Node* n = _worklist.at(i); + + if (n->is_ConstraintCast()) { + Node* nn = n->Identity(this); + if (nn != n) { + replace_node(n, nn); + to_remove.push(n); + } + } + } + + while (to_remove.size() > 0) { + _worklist.remove(to_remove.pop()); + } } //------------------------------transform--------------------------------------