diff -r aaa5ce0d9d01 -r 61e01c0389ba hotspot/src/share/vm/opto/castnode.cpp --- a/hotspot/src/share/vm/opto/castnode.cpp Sat Mar 25 00:00:13 2017 -0700 +++ b/hotspot/src/share/vm/opto/castnode.cpp Mon Mar 27 10:12:29 2017 +0200 @@ -225,7 +225,10 @@ } // Similar to ConvI2LNode::Ideal() for the same reasons - if (can_reshape && !phase->C->major_progress()) { + // Do not narrow the type of range check dependent CastIINodes to + // avoid corruption of the graph if a CastII is replaced by TOP but + // the corresponding range check is not removed. + if (can_reshape && !_range_check_dependency && !phase->C->major_progress()) { const TypeInt* this_type = this->type()->is_int(); const TypeInt* in_type = phase->type(in(1))->isa_int(); if (in_type != NULL && this_type != NULL &&