Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index 46cf22c2e60748927e4e49ff1e279df2eeb00b4c..093b09ecc0f711bd466af097dc88750097a1431f 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -1692,6 +1692,35 @@ class RepresentationSelector { |
} |
return; |
} |
+ case IrOpcode::kSpeculativeNumberShiftRight: { |
+ // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we |
+ // can only eliminate an unused speculative number operation if we know |
+ // that the inputs are PlainPrimitive, which excludes everything that's |
+ // might have side effects or throws during a ToNumber conversion. |
+ if (BothInputsAre(node, Type::PlainPrimitive())) { |
+ if (truncation.IsUnused()) return VisitUnused(node); |
+ } |
+ if (BothInputsAre(node, Type::NumberOrOddball())) { |
+ Type* rhs_type = GetUpperBound(node->InputAt(1)); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), |
+ UseInfo::TruncatingWord32(), |
+ MachineRepresentation::kWord32); |
+ if (lower()) { |
+ lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); |
+ } |
+ return; |
+ } |
+ BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
+ Type* rhs_type = GetUpperBound(node->InputAt(1)); |
+ VisitBinop(node, hint == BinaryOperationHints::kNumberOrOddball |
+ ? UseInfo::CheckedNumberOrOddballAsWord32() |
+ : UseInfo::CheckedSigned32AsWord32(), |
+ MachineRepresentation::kWord32, Type::Signed32()); |
+ if (lower()) { |
+ lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); |
+ } |
+ return; |
+ } |
case IrOpcode::kNumberShiftRightLogical: { |
Type* rhs_type = GetUpperBound(node->InputAt(1)); |
VisitBinop(node, UseInfo::TruncatingWord32(), |
@@ -1701,6 +1730,35 @@ class RepresentationSelector { |
} |
return; |
} |
+ case IrOpcode::kSpeculativeNumberShiftRightLogical: { |
+ // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we |
+ // can only eliminate an unused speculative number operation if we know |
+ // that the inputs are PlainPrimitive, which excludes everything that's |
+ // might have side effects or throws during a ToNumber conversion. |
+ if (BothInputsAre(node, Type::PlainPrimitive())) { |
+ if (truncation.IsUnused()) return VisitUnused(node); |
+ } |
+ if (BothInputsAre(node, Type::NumberOrOddball())) { |
+ Type* rhs_type = GetUpperBound(node->InputAt(1)); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), |
+ UseInfo::TruncatingWord32(), |
+ MachineRepresentation::kWord32); |
+ if (lower()) { |
+ lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
+ } |
+ return; |
+ } |
+ BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
+ Type* rhs_type = GetUpperBound(node->InputAt(1)); |
+ VisitBinop(node, hint == BinaryOperationHints::kNumberOrOddball |
+ ? UseInfo::CheckedNumberOrOddballAsWord32() |
+ : UseInfo::CheckedSigned32AsWord32(), |
+ MachineRepresentation::kWord32, Type::Unsigned32()); |
+ if (lower()) { |
+ lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
+ } |
+ return; |
+ } |
case IrOpcode::kNumberAbs: { |
if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { |
VisitUnop(node, UseInfo::TruncatingWord32(), |