diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index a61af404b39..ca94fecaa5e 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -1594,14 +1594,14 @@ void LIR_Assembler::emit_opSubstitutabilityCheck(LIR_OpSubstitutabilityCheck* op Register left = op->left()->as_register(); Register right = op->right()->as_register(); - if (left == right) { - __ jmp(L_oops_equal); - } else { - __ cmpptr(left, right); - __ jcc(Assembler::equal, L_oops_equal); + move(op->equal_result(), op->result_opr()); + return; } + __ cmpptr(left, right); + __ jcc(Assembler::equal, L_oops_equal); + // (1) Null check -- if one of the operands is null, the other must not be null (because // the two references are not equal), so they are not substitutable, __ testptr(left, left); diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 0227615241c..4ef273bc3a2 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -3363,6 +3363,11 @@ void LIRGenerator::substitutability_check(If* x, LIRItem& left, LIRItem& right) void LIRGenerator::substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right, LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result, CodeEmitInfo* info) { + if (left.result() == right.result()) { + __ move(equal_result, result); + return; + } + LIR_Opr tmp1 = LIR_OprFact::illegalOpr; LIR_Opr tmp2 = LIR_OprFact::illegalOpr;