diff --git a/src/hotspot/share/opto/vector.cpp b/src/hotspot/share/opto/vector.cpp index 8d55baf805d..f5ab1ef0f21 100644 --- a/src/hotspot/share/opto/vector.cpp +++ b/src/hotspot/share/opto/vector.cpp @@ -313,6 +313,21 @@ Node* PhaseVector::expand_vbox_node_helper(Node* vbox, } new_phi = C->initial_gvn()->transform(new_phi); return new_phi; + } else if (vbox->is_Phi() && (vect->is_Vector() || vect->is_LoadVector())) { + // Handle the case when the allocation input to VectorBoxNode is a phi + // but the vector input is not, which can definitely be the case if the + // vector input has been value-numbered. It seems to be safe to do by + // construction because VectorBoxNode and VectorBoxAllocate come in a + // specific order as a result of expanding an intrinsic call. After that, if + // any of the inputs to VectorBoxNode are value-numbered they can only + // move up and are guaranteed to dominate. + Node* new_phi = new PhiNode(vbox->as_Phi()->region(), box_type); + for (uint i = 1; i < vbox->req(); i++) { + Node* new_box = expand_vbox_node_helper(vbox->in(i), vect, box_type, vect_type); + new_phi->set_req(i, new_box); + } + new_phi = C->initial_gvn()->transform(new_phi); + return new_phi; } else if (vbox->is_Proj() && vbox->in(0)->Opcode() == Op_VectorBoxAllocate) { VectorBoxAllocateNode* vbox_alloc = static_cast(vbox->in(0)); return expand_vbox_alloc_node(vbox_alloc, vect, box_type, vect_type);