diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index bbf3c1406bf..c68a3bcfb5c 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -1209,9 +1209,6 @@ bool LoadNode::is_instance_field_load_with_local_phi(Node* ctrl) { //------------------------------Identity--------------------------------------- // Loads are identity if previous store is to same address Node* LoadNode::Identity(PhaseGVN* phase) { - if (has_pinned_control_dependency()) { - return this; - } // If the previous store-maker is the right kind of Store, and the store is // to the same address, then we are equal to the value stored. Node* mem = in(Memory); @@ -1229,9 +1226,16 @@ Node* LoadNode::Identity(PhaseGVN* phase) { } // (This works even when value is a Con, but LoadNode::Value // usually runs first, producing the singleton type of the Con.) - return value; + if (!has_pinned_control_dependency() || value->is_Con()) { + return value; + } else { + return this; + } } + if (has_pinned_control_dependency()) { + return this; + } // Search for an existing data phi which was generated before for the same // instance's field to avoid infinite generation of phis in a loop. Node *region = mem->in(0);