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

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

Issue 2170343002: [turbofan] Change Float64Max/Float64Min to JavaScript semantics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips/mips64 ports. Created 4 years, 5 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/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | 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 ad55f1db910e9095f4bc1c08f762fd64b7f26e3c..d236041b8f76617f7c71fc9d22811c6188a64936 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1763,6 +1763,58 @@ class RepresentationSelector {
if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
return;
}
+ case IrOpcode::kNumberMax: {
+ // TODO(turbofan): We should consider feedback types here as well.
+ if (BothInputsAreUnsigned32(node)) {
+ VisitUint32Binop(node);
+ if (lower()) {
+ lowering->DoMax(node, lowering->machine()->Uint32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (BothInputsAreSigned32(node)) {
+ VisitInt32Binop(node);
+ if (lower()) {
+ 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));
+ }
+ return;
+ }
+ case IrOpcode::kNumberMin: {
+ // TODO(turbofan): We should consider feedback types here as well.
+ if (BothInputsAreUnsigned32(node)) {
+ VisitUint32Binop(node);
+ if (lower()) {
+ lowering->DoMin(node, lowering->machine()->Uint32LessThan(),
+ MachineRepresentation::kWord32);
+ }
+ } else if (BothInputsAreSigned32(node)) {
+ VisitInt32Binop(node);
+ if (lower()) {
+ 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));
+ }
+ return;
+ }
case IrOpcode::kNumberAtan2:
case IrOpcode::kNumberPow: {
VisitBinop(node, UseInfo::TruncatingFloat64(),
@@ -3393,6 +3445,27 @@ Node* SimplifiedLowering::Uint32Mod(Node* const node) {
return graph()->NewNode(phi_op, true0, false0, merge0);
}
+void SimplifiedLowering::DoMax(Node* node, Operator const* op,
+ MachineRepresentation rep) {
+ Node* const lhs = node->InputAt(0);
+ Node* const rhs = node->InputAt(1);
+
+ node->ReplaceInput(0, graph()->NewNode(op, lhs, rhs));
+ DCHECK_EQ(rhs, node->InputAt(1));
+ node->AppendInput(graph()->zone(), lhs);
+ NodeProperties::ChangeOp(node, common()->Select(rep));
+}
+
+void SimplifiedLowering::DoMin(Node* node, Operator const* op,
+ MachineRepresentation rep) {
+ Node* const lhs = node->InputAt(0);
+ Node* const rhs = node->InputAt(1);
+
+ node->InsertInput(graph()->zone(), 0, graph()->NewNode(op, lhs, rhs));
+ DCHECK_EQ(lhs, node->InputAt(1));
+ DCHECK_EQ(rhs, node->InputAt(2));
+ NodeProperties::ChangeOp(node, common()->Select(rep));
+}
void SimplifiedLowering::DoShift(Node* node, Operator const* op,
Type* rhs_type) {
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698