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

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

Issue 2734193003: [turbofan] Consume feedback types for NumberMax and NumberMin. (Closed)
Patch Set: Use jarin@s suggestion. 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 | « no previous file | 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..17dd6e1109a78f6d6910109732660c01703bcae2 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -2061,20 +2061,27 @@ class RepresentationSelector {
return;
}
case IrOpcode::kNumberMax: {
- // TODO(turbofan): We should consider feedback types here as well.
- if (BothInputsAreUnsigned32(node)) {
+ // It is safe to use the feedback types for left and right hand side
+ // here, since we can only narrow those types and thus we can only
+ // promise a more specific truncation.
+ 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())) {
VisitWord32TruncatingBinop(node);
if (lower()) {
lowering->DoMax(node, lowering->machine()->Uint32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAreSigned32(node)) {
+ } else if (lhs_type->Is(Type::Signed32()) &&
+ rhs_type->Is(Type::Signed32())) {
VisitWord32TruncatingBinop(node);
if (lower()) {
lowering->DoMax(node, lowering->machine()->Int32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAre(node, Type::PlainNumber())) {
+ } else if (lhs_type->Is(Type::PlainNumber()) &&
+ rhs_type->Is(Type::PlainNumber())) {
VisitFloat64Binop(node);
if (lower()) {
lowering->DoMax(node, lowering->machine()->Float64LessThan(),
@@ -2087,20 +2094,27 @@ class RepresentationSelector {
return;
}
case IrOpcode::kNumberMin: {
- // TODO(turbofan): We should consider feedback types here as well.
- if (BothInputsAreUnsigned32(node)) {
+ // It is safe to use the feedback types for left and right hand side
+ // here, since we can only narrow those types and thus we can only
+ // promise a more specific truncation.
+ 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())) {
VisitWord32TruncatingBinop(node);
if (lower()) {
lowering->DoMin(node, lowering->machine()->Uint32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAreSigned32(node)) {
+ } else if (lhs_type->Is(Type::Signed32()) &&
+ rhs_type->Is(Type::Signed32())) {
VisitWord32TruncatingBinop(node);
if (lower()) {
lowering->DoMin(node, lowering->machine()->Int32LessThan(),
MachineRepresentation::kWord32);
}
- } else if (BothInputsAre(node, Type::PlainNumber())) {
+ } else if (lhs_type->Is(Type::PlainNumber()) &&
+ rhs_type->Is(Type::PlainNumber())) {
VisitFloat64Binop(node);
if (lower()) {
lowering->DoMin(node, lowering->machine()->Float64LessThan(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698