--- old/src/share/vm/opto/ifg.cpp 2014-12-04 10:32:49.000000000 -0800 +++ new/src/share/vm/opto/ifg.cpp 2014-12-04 10:32:48.000000000 -0800 @@ -571,15 +571,35 @@ if( !n->is_Proj() || // Could also be a flags-projection of a dead ADD or such. (n2lidx(def) && !liveout.member(n2lidx(def)) ) ) { - b->_nodes.remove(j - 1); - if( lrgs(r)._def == n ) lrgs(r)._def = 0; - n->disconnect_inputs(NULL, C); - _cfg._bbs.map(n->_idx,NULL); - n->replace_by(C->top()); - // Since yanking a Node from block, high pressure moves up one - hrp_index[0]--; - hrp_index[1]--; - continue; + bool remove = true; + if (n->is_MachProj()) { + // Don't remove KILL projections if their "defining" nodes have + // memory effects (have SCMemProj projection node) - + // they are not dead even when their result is not used. + // For example, compareAndSwapL (and other CAS) and EncodeISOArray nodes. + // The method add_input_to_liveout() keeps such nodes alive (put them on liveout list) + // when it sees SCMemProj node in a block. Unfortunately SCMemProj node could be placed + // in block in such order that KILL MachProj nodes are processed first. + uint cnt = def->outcnt(); + for (uint i = 0; i < cnt; i++) { + Node* proj = def->raw_out(i); + if (proj->Opcode() == Op_SCMemProj) { + remove = false; + break; + } + } + } + if (remove) { + b->_nodes.remove(j - 1); + if( lrgs(r)._def == n ) lrgs(r)._def = 0; + n->disconnect_inputs(NULL, C); + _cfg._bbs.map(n->_idx,NULL); + n->replace_by(C->top()); + // Since yanking a Node from block, high pressure moves up one + hrp_index[0]--; + hrp_index[1]--; + continue; + } } // Fat-projections kill many registers which cannot be used to