Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 39104bb50d2f5093669d6d627e312a0970d2c0d5..e6610a72dd51d44febd34d70e5fccd5f8192f7fe 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -630,6 +630,15 @@ static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { |
Reduction JSTypedLowering::Reduce(Node* node) { |
+ // Check if the output type is a singleton. In that case we already know the |
+ // result value and can simply replace the node unless there are effects. |
+ if (node->bounds().upper->IsConstant() && |
+ !IrOpcode::IsLeafOpcode(node->opcode()) && |
+ !OperatorProperties::HasEffectOutput(node->op())) { |
+ return ReplaceEagerly(node, jsgraph()->Constant( |
+ node->bounds().upper->AsConstant()->Value())); |
+ // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? |
+ } |
switch (node->opcode()) { |
case IrOpcode::kJSEqual: |
return ReduceJSEqual(node, false); |