Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index d72fc827591350c7b4283b89ee861cb23bb340d8..6e560dbffcc68634665cc073444ff94a2ab3bd2c 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -2104,7 +2104,8 @@ class RepresentationSelector { |
} |
case IrOpcode::kCheckBounds: { |
- if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { |
+ Type* index_type = TypeOf(node->InputAt(0)); |
+ if (index_type->Is(Type::Unsigned32())) { |
VisitBinop(node, UseInfo::TruncatingWord32(), |
MachineRepresentation::kWord32); |
} else { |
@@ -2112,6 +2113,13 @@ class RepresentationSelector { |
UseInfo::TruncatingWord32(), |
MachineRepresentation::kWord32); |
} |
+ if (lower()) { |
+ // The bounds check is redundant if we already know that |
+ // the index is within the bounds of [0.0, length[. |
+ if (index_type->Is(NodeProperties::GetType(node))) { |
+ DeferReplacement(node, node->InputAt(0)); |
+ } |
+ } |
return; |
} |
case IrOpcode::kCheckIf: { |