diff --git a/src/hydrogen.cc b/src/hydrogen.cc index b3549f527e..339a623ead 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -9193,10 +9193,11 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( if (combined_type->Is(Type::Receiver())) { if (Token::IsEqualityOp(op)) { // Can we get away with map check and not instance type check? + HValue* operand_to_check = + left->block()->block_id() < right->block()->block_id() ? left : right; if (combined_type->IsClass()) { Handle map = combined_type->AsClass(); - AddCheckMap(left, map); - AddCheckMap(right, map); + AddCheckMap(operand_to_check, map); HCompareObjectEqAndBranch* result = New(left, right); if (FLAG_emit_opt_code_positions) { @@ -9205,10 +9206,9 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( } return result; } else { - BuildCheckHeapObject(left); - Add(left, HCheckInstanceType::IS_SPEC_OBJECT); - BuildCheckHeapObject(right); - Add(right, HCheckInstanceType::IS_SPEC_OBJECT); + BuildCheckHeapObject(operand_to_check); + Add(operand_to_check, + HCheckInstanceType::IS_SPEC_OBJECT); HCompareObjectEqAndBranch* result = New(left, right); return result;