Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: src/compiler/machine-operator-reducer.cc

Issue 1468313009: Revert of [machine-operator-reducer] fix float truncation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/math-52-mul-div.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/machine-operator-reducer.h" 5 #include "src/compiler/machine-operator-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/compiler/diamond.h" 10 #include "src/compiler/diamond.h"
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 return Changed(node); 641 return Changed(node);
642 } 642 }
643 return NoChange(); 643 return NoChange();
644 } 644 }
645 645
646 646
647 Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { 647 Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) {
648 Float64Matcher m(node->InputAt(0)); 648 Float64Matcher m(node->InputAt(0));
649 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); 649 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
650 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); 650 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
651 if (m.IsRoundInt64ToFloat64()) { 651 if (m.IsRoundInt64ToFloat64()) return Replace(m.node()->InputAt(0));
652 Node* value = m.node()->InputAt(0);
653 Type* type = NodeProperties::GetType(value);
654 Type::RangeType* range = type->GetRange();
655
656 // Rounding int64 to float64 should not lose precision
657 if (range != nullptr && range->Min() >= 0 &&
658 range->Max() <= 0xFFFFFFFFFFFFFULL) {
659 return Replace(
660 graph()->NewNode(machine()->TruncateInt64ToInt32(), value));
661 }
662 }
663 if (m.IsPhi()) { 652 if (m.IsPhi()) {
664 Node* const phi = m.node(); 653 Node* const phi = m.node();
665 DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi))); 654 DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi)));
666 if (phi->OwnedBy(node)) { 655 if (phi->OwnedBy(node)) {
667 // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn)) 656 // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn))
668 // => Phi[Int32](TruncateFloat64ToInt32[mode](x1), 657 // => Phi[Int32](TruncateFloat64ToInt32[mode](x1),
669 // ..., 658 // ...,
670 // TruncateFloat64ToInt32[mode](xn)) 659 // TruncateFloat64ToInt32[mode](xn))
671 const int value_input_count = phi->InputCount() - 1; 660 const int value_input_count = phi->InputCount() - 1;
672 for (int i = 0; i < value_input_count; ++i) { 661 for (int i = 0; i < value_input_count; ++i) {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1077 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1089 return jsgraph()->machine(); 1078 return jsgraph()->machine();
1090 } 1079 }
1091 1080
1092 1081
1093 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1082 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1094 1083
1095 } // namespace compiler 1084 } // namespace compiler
1096 } // namespace internal 1085 } // namespace internal
1097 } // namespace v8 1086 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/math-52-mul-div.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698