Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index e816471ce604561601f90dfd08f41e25ed3d7495..c47126cf7241db445429b151f169ab33dade6d92 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -947,6 +947,25 @@ void HBoundsCheck::InferRepresentation(HInferRepresentationPhase* h_infer) { |
} |
+Range* HBoundsCheck::InferRange(Zone* zone) { |
+ Representation r = representation(); |
+ if (r.IsSmiOrInteger32() && length()->HasRange()) { |
+ int upper = length()->range()->upper() - (allow_equality() ? 0 : 1); |
+ int lower = 0; |
+ |
+ Range* result = new(zone) Range(lower, upper); |
+ if (index()->HasRange()) { |
+ result->Intersect(index()->range()); |
+ } |
+ |
+ // In case of Smi representation, clamp result to Smi::kMaxValue. |
+ if (r.IsSmi()) result->ClampToSmi(); |
+ return result; |
+ } |
+ return HValue::InferRange(zone); |
+} |
+ |
+ |
void HBoundsCheckBaseIndexInformation::PrintDataTo(StringStream* stream) { |
stream->Add("base: "); |
base_index()->PrintNameTo(stream); |