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

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

Issue 2035383003: [turbofan] Type feedback for numeric comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase, pure ops Created 4 years, 6 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 71ff60604b8c7ccd3ea25dc8590f8ea22a42de69..cf735a9a90bb6976fd6d29c5bd6096f69acd6b5c 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1040,7 +1040,6 @@ class RepresentationSelector {
Node* overflow = graph()->NewNode(common()->Projection(1), arith);
effect =
graph()->NewNode(simplified()->CheckIf(), overflow, effect, control);
-
Node* value = graph()->NewNode(common()->Projection(0), arith);
ReplaceEffectControlUses(node, effect, control);
DeferReplacement(node, value);
@@ -1219,11 +1218,13 @@ class RepresentationSelector {
case IrOpcode::kNumberLessThan:
case IrOpcode::kNumberLessThanOrEqual: {
// Number comparisons reduce to integer comparisons for integer inputs.
- if (BothInputsAreSigned32(node)) {
+ if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
// => signed Int32Cmp
VisitInt32Cmp(node);
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
- } else if (BothInputsAreUnsigned32(node)) {
+ } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
+ TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
// => unsigned Int32Cmp
VisitUint32Cmp(node);
if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
@@ -1239,6 +1240,40 @@ class RepresentationSelector {
case IrOpcode::kSpeculativeNumberSubtract:
return VisitSpeculativeAdditiveOp(node, truncation, lowering);
+ case IrOpcode::kSpeculativeNumberLessThan:
+ case IrOpcode::kSpeculativeNumberLessThanOrEqual:
+ case IrOpcode::kSpeculativeNumberEqual: {
+ // Number comparisons reduce to integer comparisons for integer inputs.
+ if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
+ // => signed Int32Cmp
+ VisitInt32Cmp(node);
+ if (lower()) ChangeToPureOp(node, Int32Op(node));
+ return;
+ } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
+ TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
+ // => unsigned Int32Cmp
+ VisitUint32Cmp(node);
+ if (lower()) ChangeToPureOp(node, Uint32Op(node));
+ return;
+ }
+ // Try to use type feedback.
+ CompareOperationHints::Hint hint = CompareOperationHintOf(node->op());
+
+ if (hint == CompareOperationHints::kSignedSmall) {
+ VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
+ MachineRepresentation::kBit);
+ if (lower()) ChangeToPureOp(node, Int32Op(node));
+ return;
+ }
+ DCHECK_EQ(CompareOperationHints::kNumber, hint);
+ // default case => Float64 comparison
+ VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(),
+ MachineRepresentation::kBit);
+ if (lower()) ChangeToPureOp(node, Float64Op(node));
+ return;
+ }
+
case IrOpcode::kNumberAdd:
case IrOpcode::kNumberSubtract: {
if (BothInputsAre(node, Type::Signed32()) &&
« 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