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

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

Issue 2154073002: [Turbofan]: Eliminate the check for -0 if it's not possible/observable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. 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 0cc53ed9b48072796dcc8a44757edd3412ca4660..5a9376e2d553403918c4f3498d427e366df1ee79 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1077,6 +1077,22 @@ class RepresentationSelector {
return jsgraph_->simplified();
}
+ void LowerToCheckedInt32Mul(Node* node, Truncation truncation,
+ Type* input0_type, Type* input1_type) {
+ // If one of the inputs is positive and/or truncation is being applied,
+ // there is no need to return -0.
+ CheckForMinusZeroMode mz_mode =
+ truncation.TruncatesToWord32() ||
+ (input0_type->Is(Type::OrderedNumber()) &&
+ input0_type->Min() > 0) ||
+ (input1_type->Is(Type::OrderedNumber()) &&
+ input1_type->Min() > 0)
+ ? CheckForMinusZeroMode::kDontCheckForMinusZero
+ : CheckForMinusZeroMode::kCheckForMinusZero;
+
+ NodeProperties::ChangeOp(node, simplified()->CheckedInt32Mul(mz_mode));
+ }
+
void ChangeToInt32OverflowOp(Node* node) {
NodeProperties::ChangeOp(node, Int32OverflowOp(node));
}
@@ -1333,6 +1349,8 @@ class RepresentationSelector {
}
// Try to use type feedback.
BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+ Type* input0_type = TypeOf(node->InputAt(0));
+ Type* input1_type = TypeOf(node->InputAt(1));
// Handle the case when no int32 checks on inputs are necessary
// (but an overflow check is needed on the output).
@@ -1342,7 +1360,10 @@ class RepresentationSelector {
hint == BinaryOperationHints::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Signed32());
- if (lower()) ChangeToInt32OverflowOp(node);
+ if (lower()) {
+ LowerToCheckedInt32Mul(node, truncation, input0_type,
+ input1_type);
+ }
return;
}
}
@@ -1351,7 +1372,9 @@ class RepresentationSelector {
hint == BinaryOperationHints::kSigned32) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32, Type::Signed32());
- if (lower()) ChangeToInt32OverflowOp(node);
+ if (lower()) {
+ LowerToCheckedInt32Mul(node, truncation, input0_type, input1_type);
+ }
return;
}
« 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