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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2734193003: [turbofan] Consume feedback types for NumberMax and NumberMin. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « src/compiler/representation-change.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 8d1be4d09eefec5dd2e226667925e417a0da0992..fd456f8af4df571f4a9f094313182caeb8cada9b 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -2061,7 +2061,6 @@ class RepresentationSelector {
return;
}
case IrOpcode::kNumberMax: {
- // TODO(turbofan): We should consider feedback types here as well.
if (BothInputsAreUnsigned32(node)) {
VisitWord32TruncatingBinop(node);
if (lower()) {
@@ -2074,20 +2073,42 @@ class RepresentationSelector {
lowering->DoMax(node, lowering->machine()->Int32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAre(node, Type::PlainNumber())) {
- VisitFloat64Binop(node);
- if (lower()) {
- lowering->DoMax(node, lowering->machine()->Float64LessThan(),
- MachineRepresentation::kFloat64);
- }
} else {
- VisitFloat64Binop(node);
- if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ // Below we use feedback types and thus we must always promise
+ // a consistent truncation, namely Truncation::Float64().
+ Type* const lhs_type = TypeOf(node->InputAt(0));
+ Type* const rhs_type = TypeOf(node->InputAt(1));
+ if (lhs_type->Is(Type::Unsigned32()) &&
+ rhs_type->Is(Type::Unsigned32())) {
+ VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(),
Jarin 2017/03/07 23:00:51 Hmm, now that I have been staring at this for long
Benedikt Meurer 2017/03/08 04:44:07 Yes, I think it's sufficient to look at the feedba
+ MachineRepresentation::kWord32);
+ if (lower()) {
+ lowering->DoMax(node, lowering->machine()->Uint32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (lhs_type->Is(Type::Signed32()) &&
+ rhs_type->Is(Type::Signed32())) {
+ VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) {
+ lowering->DoMax(node, lowering->machine()->Int32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (lhs_type->Is(Type::PlainNumber()) &&
+ rhs_type->Is(Type::PlainNumber())) {
+ VisitFloat64Binop(node);
+ if (lower()) {
+ lowering->DoMax(node, lowering->machine()->Float64LessThan(),
+ MachineRepresentation::kFloat64);
+ }
+ } else {
+ VisitFloat64Binop(node);
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ }
}
return;
}
case IrOpcode::kNumberMin: {
- // TODO(turbofan): We should consider feedback types here as well.
if (BothInputsAreUnsigned32(node)) {
VisitWord32TruncatingBinop(node);
if (lower()) {
@@ -2100,15 +2121,38 @@ class RepresentationSelector {
lowering->DoMin(node, lowering->machine()->Int32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAre(node, Type::PlainNumber())) {
- VisitFloat64Binop(node);
- if (lower()) {
- lowering->DoMin(node, lowering->machine()->Float64LessThan(),
- MachineRepresentation::kFloat64);
- }
} else {
- VisitFloat64Binop(node);
- if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ // Below we use feedback types and thus we must always promise
+ // a consistent truncation, namely Truncation::Float64().
+ Type* const lhs_type = TypeOf(node->InputAt(0));
+ Type* const rhs_type = TypeOf(node->InputAt(1));
+ if (lhs_type->Is(Type::Unsigned32()) &&
+ rhs_type->Is(Type::Unsigned32())) {
+ VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) {
+ lowering->DoMin(node, lowering->machine()->Uint32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (lhs_type->Is(Type::Signed32()) &&
+ rhs_type->Is(Type::Signed32())) {
+ VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) {
+ lowering->DoMin(node, lowering->machine()->Int32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (lhs_type->Is(Type::PlainNumber()) &&
+ rhs_type->Is(Type::PlainNumber())) {
+ VisitFloat64Binop(node);
+ if (lower()) {
+ lowering->DoMin(node, lowering->machine()->Float64LessThan(),
+ MachineRepresentation::kFloat64);
+ }
+ } else {
+ VisitFloat64Binop(node);
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ }
}
return;
}
« no previous file with comments | « src/compiler/representation-change.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698