--- old/src/hotspot/share/opto/mulnode.cpp 2019-03-11 14:26:50.698354539 +0100 +++ new/src/hotspot/share/opto/mulnode.cpp 2019-03-11 14:26:50.486354542 +0100 @@ -155,6 +155,18 @@ if( t2->higher_equal( zero ) ) return zero; } + // Code pattern on return from a call that returns an __Value. Can + // be optimized away if the return value turns out to be an oop. + if (op == Op_AndX && + in(1) != NULL && + in(1)->Opcode() == Op_CastP2X && + in(1)->in(1) != NULL && + phase->type(in(1)->in(1))->isa_oopptr() && + t2->isa_intptr_t()->_lo >= 0 && + t2->isa_intptr_t()->_hi <= MinObjAlignmentInBytesMask) { + return add_id(); + } + // Either input is BOTTOM ==> the result is the local BOTTOM if( t1 == Type::BOTTOM || t2 == Type::BOTTOM ) return bottom_type(); @@ -584,6 +596,13 @@ return usr; } } + + if (con == markOopDesc::always_locked_pattern) { + assert(EnableValhalla || ACmpOnValues == 3, "should only be used for value types"); + if (in(1)->is_Load() && phase->type(in(1)->in(MemNode::Address))->is_valuetypeptr()) { + return in(2); // Obj is known to be a value type + } + } } return MulNode::Identity(phase); }