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

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

Issue 2141953002: [Turbofan]: Add integer multiplication with overflow to typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@multiply
Patch Set: Code comments. 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/representation-change.cc ('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 2dfdf983bbb7ad263d66dcd757b7599836772759..2f273d4c4bdaad36a5d4256a4624ad979d8c6fd6 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1313,8 +1313,7 @@ class RepresentationSelector {
}
return;
}
- case IrOpcode::kSpeculativeNumberMultiply:
- case IrOpcode::kNumberMultiply: {
+ case IrOpcode::kSpeculativeNumberMultiply: {
if (BothInputsAre(node, Type::Integral32()) &&
(NodeProperties::GetType(node)->Is(Type::Signed32()) ||
NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
@@ -1330,19 +1329,57 @@ class RepresentationSelector {
if (lower()) ChangeToPureOp(node, Int32Op(node));
return;
}
- // Number x Number => Float64Mul
- if (BothInputsAre(node, Type::NumberOrUndefined())) {
- VisitFloat64Binop(node);
- if (lower()) ChangeToPureOp(node, Float64Op(node));
+ // Try to use type feedback.
+ BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+
+ // Handle the case when no int32 checks on inputs are necessary
+ // (but an overflow check is needed on the output).
+ if (BothInputsAre(node, Type::Signed32())) {
+ // If both the inputs the feedback are int32, use the overflow op.
+ if (hint == BinaryOperationHints::kSignedSmall ||
+ hint == BinaryOperationHints::kSigned32) {
+ VisitBinop(node, UseInfo::TruncatingWord32(),
+ MachineRepresentation::kWord32, Type::Signed32());
+ if (lower()) ChangeToInt32OverflowOp(node);
+ return;
+ }
+ }
+
+ if (hint == BinaryOperationHints::kSignedSmall ||
+ hint == BinaryOperationHints::kSigned32) {
+ VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
+ MachineRepresentation::kWord32, Type::Signed32());
+ if (lower()) ChangeToInt32OverflowOp(node);
return;
}
+
// Checked float64 x float64 => float64
- DCHECK_EQ(IrOpcode::kSpeculativeNumberMultiply, node->opcode());
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kFloat64, Type::Number());
if (lower()) ChangeToPureOp(node, Float64Op(node));
return;
}
+ case IrOpcode::kNumberMultiply: {
+ if (BothInputsAre(node, Type::Integral32()) &&
+ (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
+ NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
+ (truncation.TruncatesToWord32() &&
+ NodeProperties::GetType(node)->Is(
+ type_cache_.kSafeIntegerOrMinusZero)))) {
+ // Multiply reduces to Int32Mul if the inputs are integers, and
+ // (a) the output is either known to be Signed32, or
+ // (b) the output is known to be Unsigned32, or
+ // (c) the uses are truncating and the result is in the safe
+ // integer range.
+ VisitWord32TruncatingBinop(node);
+ if (lower()) ChangeToPureOp(node, Int32Op(node));
+ return;
+ }
+ // Number x Number => Float64Mul
+ VisitFloat64Binop(node);
+ if (lower()) ChangeToPureOp(node, Float64Op(node));
+ return;
+ }
case IrOpcode::kSpeculativeNumberDivide: {
if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
// => unsigned Uint32Div
« no previous file with comments | « src/compiler/representation-change.cc ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698