Chromium Code Reviews| Index: src/compiler/machine-operator-reducer.cc |
| diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc |
| index 5951fb612a9f75feb3f456f840a8c2d364cb80a2..b4134d2c901b277e67e38f2ca49ef522ed998884 100644 |
| --- a/src/compiler/machine-operator-reducer.cc |
| +++ b/src/compiler/machine-operator-reducer.cc |
| @@ -648,7 +648,18 @@ Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { |
| Float64Matcher m(node->InputAt(0)); |
| if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
| if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); |
| - if (m.IsRoundInt64ToFloat64()) return Replace(m.node()->InputAt(0)); |
| + if (m.IsRoundInt64ToFloat64()) { |
| + Node* value = m.node()->InputAt(0); |
| + Type* type = NodeProperties::GetType(value); |
| + Type::RangeType* range = type->GetRange(); |
| + |
| + // Rounding int64 to float64 should not loose precision |
|
titzer
2015/11/24 19:30:35
s/loose/lose/
fedor.indutny
2015/11/24 19:33:37
Acknowledged.
|
| + if (range != nullptr && range->Min() >= 0 && |
| + range->Max() <= 0xFFFFFFFFFFFFFULL) { |
| + return Replace( |
| + graph()->NewNode(machine()->TruncateInt64ToInt32(), value)); |
| + } |
| + } |
| if (m.IsPhi()) { |
| Node* const phi = m.node(); |
| DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi))); |