Index: runtime/vm/intermediate_language_x64.cc |
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc |
index 1738532b8acfe29782089f7cdfe2583f659b9f05..21d895ef9f1a88e3b19dfaf62550aed671a8bf70 100644 |
--- a/runtime/vm/intermediate_language_x64.cc |
+++ b/runtime/vm/intermediate_language_x64.cc |
@@ -2848,13 +2848,24 @@ void CheckedSmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
new CheckedSmiSlowPath(this, compiler->CurrentTryIndex()); |
compiler->AddSlowPathCode(slow_path); |
// Test operands if necessary. |
+ |
+ intptr_t left_cid = left()->Type()->ToCid(); |
+ intptr_t right_cid = right()->Type()->ToCid(); |
Register left = locs()->in(0).reg(); |
Register right = locs()->in(1).reg(); |
- Register result = locs()->out(0).reg(); |
- __ movq(TMP, left); |
- __ orq(TMP, right); |
- __ testq(TMP, Immediate(kSmiTagMask)); |
+ if (this->left()->definition() == this->right()->definition()) { |
+ __ testq(left, Immediate(kSmiTagMask)); |
+ } else if (left_cid == kSmiCid) { |
+ __ testq(right, Immediate(kSmiTagMask)); |
+ } else if (right_cid == kSmiCid) { |
+ __ testq(left, Immediate(kSmiTagMask)); |
+ } else { |
+ __ movq(TMP, left); |
+ __ orq(TMP, right); |
+ __ testq(TMP, Immediate(kSmiTagMask)); |
+ } |
__ j(NOT_ZERO, slow_path->entry_label()); |
+ Register result = locs()->out(0).reg(); |
switch (op_kind()) { |
case Token::kADD: |
__ movq(result, left); |