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

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

Issue 1919513002: [turbofan] Introduce TruncateTaggedToWord32 simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months 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 19ea06205361fef01f29d5a2dc22e6067de10554..7271503d46fdcc4f363d0de135e8cc43b636a876 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -419,8 +419,12 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
if (m.HasValue()) return ReplaceInt64(static_cast<uint64_t>(m.Value()));
break;
}
- case IrOpcode::kTruncateFloat64ToInt32:
- return ReduceTruncateFloat64ToInt32(node);
+ case IrOpcode::kTruncateFloat64ToWord32: {
+ Float64Matcher m(node->InputAt(0));
+ if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
+ if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
+ return NoChange();
+ }
case IrOpcode::kTruncateInt64ToInt32: {
Int64Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
@@ -433,6 +437,12 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0));
break;
}
+ case IrOpcode::kRoundFloat64ToInt32: {
+ Float64Matcher m(node->InputAt(0));
+ if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
+ if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
+ break;
+ }
case IrOpcode::kFloat64InsertLowWord32:
return ReduceFloat64InsertLowWord32(node);
case IrOpcode::kFloat64InsertHighWord32:
@@ -645,37 +655,6 @@ 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(MachineRepresentation::kFloat64, PhiRepresentationOf(phi->op()));
- if (phi->OwnedBy(node)) {
- // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn))
- // => Phi[Int32](TruncateFloat64ToInt32[mode](x1),
- // ...,
- // TruncateFloat64ToInt32[mode](xn))
- const int value_input_count = phi->InputCount() - 1;
- for (int i = 0; i < value_input_count; ++i) {
- Node* input = graph()->NewNode(node->op(), 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);
- }
- NodeProperties::ChangeOp(
- phi,
- common()->Phi(MachineRepresentation::kWord32, value_input_count));
- return Replace(phi);
- }
- }
- return NoChange();
-}
-
-
Reduction MachineOperatorReducer::ReduceStore(Node* node) {
MachineRepresentation const rep =
StoreRepresentationOf(node->op()).representation();

Powered by Google App Engine
This is Rietveld 408576698