| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index 09322f31465afd774fb9ff8085a61f6877416e7b..bbf314204f022a2edb6fd10a1f2c33b8dd9a73e3 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -747,6 +747,21 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
|
| if (result.Changed()) return result;
|
| return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x)
|
| }
|
| + // Check for ToNumber truncation of signaling NaN to undefined mapping.
|
| + if (input->opcode() == IrOpcode::kSelect) {
|
| + Node* check = NodeProperties::GetValueInput(input, 0);
|
| + Node* vtrue = NodeProperties::GetValueInput(input, 1);
|
| + Type* vtrue_type = NodeProperties::GetType(vtrue);
|
| + Node* vfalse = NodeProperties::GetValueInput(input, 2);
|
| + Type* vfalse_type = NodeProperties::GetType(vfalse);
|
| + if (vtrue_type->Is(Type::Undefined()) && vfalse_type->Is(Type::Number())) {
|
| + if (check->opcode() == IrOpcode::kNumberIsHoleNaN &&
|
| + check->InputAt(0) == vfalse) {
|
| + // JSToNumber(Select(NumberIsHoleNaN(x), y:undefined, x:number)) => x
|
| + return Replace(vfalse);
|
| + }
|
| + }
|
| + }
|
| // Check if we have a cached conversion.
|
| Type* input_type = NodeProperties::GetType(input);
|
| if (input_type->Is(Type::Number())) {
|
|
|