Index: src/compiler/change-lowering.cc |
diff --git a/src/compiler/change-lowering.cc b/src/compiler/change-lowering.cc |
index 2348dd55177c2b6abf2b695f5162477b19d7f8b8..1024f02b1d7e64f2f9b4fb9707c997958b46360f 100644 |
--- a/src/compiler/change-lowering.cc |
+++ b/src/compiler/change-lowering.cc |
@@ -27,12 +27,9 @@ Reduction ChangeLowering::Reduce(Node* node) { |
case IrOpcode::kChangeTaggedToFloat64: |
return ChangeTaggedToFloat64(node->InputAt(0), control); |
case IrOpcode::kChangeTaggedToInt32: |
+ return ChangeTaggedToI32(node->InputAt(0), control, true); |
case IrOpcode::kChangeTaggedToUint32: |
- // ToInt32 and ToUint32 perform exactly the same operation, just the |
- // interpretation of the resulting 32 bit value is different, so we can |
- // use the same subgraph for both operations. |
- // See ECMA-262 9.5: ToInt32 and ECMA-262 9.6: ToUint32. |
- return ChangeTaggedToInt32(node->InputAt(0), control); |
+ return ChangeTaggedToI32(node->InputAt(0), control, false); |
case IrOpcode::kChangeUint32ToTagged: |
return ChangeUint32ToTagged(node->InputAt(0), control); |
default: |
@@ -170,7 +167,8 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node* val, Node* control) { |
} |
-Reduction ChangeLowering::ChangeTaggedToInt32(Node* val, Node* control) { |
+Reduction ChangeLowering::ChangeTaggedToI32(Node* val, Node* control, |
+ bool is_signed) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagMask == 1); |
@@ -179,8 +177,9 @@ Reduction ChangeLowering::ChangeTaggedToInt32(Node* val, Node* control) { |
Node* branch = graph()->NewNode(common()->Branch(), tag, control); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
- Node* change = graph()->NewNode(machine()->TruncateFloat64ToInt32(), |
- LoadHeapNumberValue(val, if_true)); |
+ Operator* op = is_signed ? machine()->ChangeFloat64ToInt32() |
+ : machine()->ChangeFloat64ToUint32(); |
+ Node* change = graph()->NewNode(op, LoadHeapNumberValue(val, if_true)); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* number = ChangeSmiToInt32(val); |