diff options
author | 2019-01-31 10:31:09 +0000 | |
---|---|---|
committer | 2019-01-31 11:53:08 +0000 | |
commit | 53a41ac9305f3c435cbb975d773bbdb5490d8321 (patch) | |
tree | 1b9645dee56837dc9566d2243f77e64d3d3824a3 /compiler/optimizing/bounds_check_elimination.cc | |
parent | cf2320d65b363fd082e5e61e15c46065ae6c95c5 (diff) |
ART: Fix off-by-one error in BCE.
Bug: 123284765
Test: Additional test in 622-checker-bce-regressions
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: Ic231434aacc9dba0ccd664a3f4b7b5d8c665ae2a
Diffstat (limited to 'compiler/optimizing/bounds_check_elimination.cc')
-rw-r--r-- | compiler/optimizing/bounds_check_elimination.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc index 54a1ae9f9e..e35d50220e 100644 --- a/compiler/optimizing/bounds_check_elimination.cc +++ b/compiler/optimizing/bounds_check_elimination.cc @@ -845,8 +845,10 @@ class BCEVisitor : public HGraphVisitor { // make one more attempt to get a constant in the array range. ValueRange* existing_range = LookupValueRange(array_length, block); if (existing_range != nullptr && - existing_range->IsConstantValueRange()) { - ValueRange constant_array_range(&allocator_, lower, existing_range->GetLower()); + existing_range->IsConstantValueRange() && + existing_range->GetLower().GetConstant() > 0) { + ValueBound constant_upper(nullptr, existing_range->GetLower().GetConstant() - 1); + ValueRange constant_array_range(&allocator_, lower, constant_upper); if (index_range->FitsIn(&constant_array_range)) { ReplaceInstruction(bounds_check, index); return; |