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

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 707683003: [turbofan] Push TruncateFloat64ToInt32 into phis. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index 53b1d8006ab2ce9d4e6970da7d0dd9cf5b216fbf..bb1596f58bd93e74e8467555f6053cf2988dca49 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -523,12 +523,8 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
if (m.HasValue()) return ReplaceInt64(static_cast<uint64_t>(m.Value()));
break;
}
- case IrOpcode::kTruncateFloat64ToInt32: {
- Float64Matcher m(node->InputAt(0));
- if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
- if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
- break;
- }
+ case IrOpcode::kTruncateFloat64ToInt32:
+ return ReduceTruncateFloat64ToInt32(node);
case IrOpcode::kTruncateInt64ToInt32: {
Int64Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
@@ -692,6 +688,36 @@ Reduction MachineOperatorReducer::ReduceUint32Mod(Node* node) {
}
+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.IsPhi()) {
+ Node* const phi = m.node();
+ DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi)));
+ if (phi->OwnedBy(node)) {
+ // TruncateFloat64ToInt32(Phi[Float64](x1,...,xn))
+ // => Phi[Int32](TruncateFloat64ToInt32(x1),
+ // ...,
+ // TruncateFloat64ToInt32(xn))
+ const int value_input_count = phi->InputCount() - 1;
+ for (int i = 0; i < value_input_count; ++i) {
+ Node* input = graph()->NewNode(machine()->TruncateFloat64ToInt32(),
+ phi->InputAt(i));
+ // TODO(bmeurer): Reschedule input for reduction once we have Revisit()
+ // instead of recursing into ReduceTruncateFloat64ToInt32() here.
+ Reduction reduction = ReduceTruncateFloat64ToInt32(input);
+ if (reduction.Changed()) input = reduction.replacement();
+ phi->ReplaceInput(i, input);
+ }
+ phi->set_op(common()->Phi(kMachInt32, value_input_count));
+ return Replace(phi);
+ }
+ }
+ return NoChange();
+}
+
+
Reduction MachineOperatorReducer::ReduceStore(Node* node) {
MachineType const rep =
RepresentationOf(StoreRepresentationOf(node->op()).machine_type());
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698