Commit bf67ce5f authored by epertoso's avatar epertoso Committed by Commit bot

[turbofan] Do Smi comparison without untagging when lowering SpeculativeNumber(Compare).

BUG=

Review-Url: https://codereview.chromium.org/2626603002
Cr-Commit-Position: refs/heads/master@{#42186}
parent de242272
...@@ -817,6 +817,24 @@ const Operator* RepresentationChanger::Int32OverflowOperatorFor( ...@@ -817,6 +817,24 @@ const Operator* RepresentationChanger::Int32OverflowOperatorFor(
} }
} }
const Operator* RepresentationChanger::TaggedSignedOperatorFor(
IrOpcode::Value opcode) {
switch (opcode) {
case IrOpcode::kSpeculativeNumberLessThan:
return machine()->Is32() ? machine()->Int32LessThan()
: machine()->Int64LessThan();
case IrOpcode::kSpeculativeNumberLessThanOrEqual:
return machine()->Is32() ? machine()->Int32LessThanOrEqual()
: machine()->Int64LessThanOrEqual();
case IrOpcode::kSpeculativeNumberEqual:
return machine()->Is32() ? machine()->Word32Equal()
: machine()->Word64Equal();
default:
UNREACHABLE();
return nullptr;
}
}
const Operator* RepresentationChanger::Uint32OperatorFor( const Operator* RepresentationChanger::Uint32OperatorFor(
IrOpcode::Value opcode) { IrOpcode::Value opcode) {
switch (opcode) { switch (opcode) {
......
...@@ -238,6 +238,7 @@ class RepresentationChanger final { ...@@ -238,6 +238,7 @@ class RepresentationChanger final {
UseInfo use_info); UseInfo use_info);
const Operator* Int32OperatorFor(IrOpcode::Value opcode); const Operator* Int32OperatorFor(IrOpcode::Value opcode);
const Operator* Int32OverflowOperatorFor(IrOpcode::Value opcode); const Operator* Int32OverflowOperatorFor(IrOpcode::Value opcode);
const Operator* TaggedSignedOperatorFor(IrOpcode::Value opcode);
const Operator* Uint32OperatorFor(IrOpcode::Value opcode); const Operator* Uint32OperatorFor(IrOpcode::Value opcode);
const Operator* Uint32OverflowOperatorFor(IrOpcode::Value opcode); const Operator* Uint32OverflowOperatorFor(IrOpcode::Value opcode);
const Operator* Float64OperatorFor(IrOpcode::Value opcode); const Operator* Float64OperatorFor(IrOpcode::Value opcode);
......
...@@ -697,6 +697,11 @@ class RepresentationSelector { ...@@ -697,6 +697,11 @@ class RepresentationSelector {
GetUpperBound(node->InputAt(1))->Is(type); GetUpperBound(node->InputAt(1))->Is(type);
} }
bool IsNodeRepresentationTagged(Node* node) {
MachineRepresentation representation = GetInfo(node)->representation();
return IsAnyTagged(representation);
}
bool OneInputCannotBe(Node* node, Type* type) { bool OneInputCannotBe(Node* node, Type* type) {
DCHECK_EQ(2, node->op()->ValueInputCount()); DCHECK_EQ(2, node->op()->ValueInputCount());
return !GetUpperBound(node->InputAt(0))->Maybe(type) || return !GetUpperBound(node->InputAt(0))->Maybe(type) ||
...@@ -1583,15 +1588,35 @@ class RepresentationSelector { ...@@ -1583,15 +1588,35 @@ class RepresentationSelector {
NumberOperationHint hint = NumberOperationHintOf(node->op()); NumberOperationHint hint = NumberOperationHintOf(node->op());
switch (hint) { switch (hint) {
case NumberOperationHint::kSignedSmall: case NumberOperationHint::kSignedSmall:
case NumberOperationHint::kSigned32: case NumberOperationHint::kSigned32: {
if (propagate()) {
VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint), VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
MachineRepresentation::kBit); MachineRepresentation::kBit);
if (lower()) ChangeToPureOp(node, Int32Op(node)); } else if (retype()) {
SetOutput(node, MachineRepresentation::kBit, Type::Any());
} else {
DCHECK(lower());
Node* lhs = node->InputAt(0);
Node* rhs = node->InputAt(1);
if (IsNodeRepresentationTagged(lhs) &&
IsNodeRepresentationTagged(rhs)) {
VisitBinop(node, UseInfo::CheckedSignedSmallAsTaggedSigned(),
MachineRepresentation::kBit);
ChangeToPureOp(
node, changer_->TaggedSignedOperatorFor(node->opcode()));
} else {
VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
MachineRepresentation::kBit);
ChangeToPureOp(node, Int32Op(node));
}
}
return; return;
}
case NumberOperationHint::kNumberOrOddball: case NumberOperationHint::kNumberOrOddball:
// Abstract and strict equality don't perform ToNumber conversions // Abstract and strict equality don't perform ToNumber conversions
// on Oddballs, so make sure we don't accidentially sneak in a hint // on Oddballs, so make sure we don't accidentially sneak in a
// with Oddball feedback here. // hint with Oddball feedback here.
DCHECK_NE(IrOpcode::kSpeculativeNumberEqual, node->opcode()); DCHECK_NE(IrOpcode::kSpeculativeNumberEqual, node->opcode());
// Fallthrough // Fallthrough
case NumberOperationHint::kNumber: case NumberOperationHint::kNumber:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment