diff options
author | Mingyao Yang <mingyao@google.com> | 2015-02-27 14:43:53 -0800 |
---|---|---|
committer | Mingyao Yang <mingyao@google.com> | 2015-03-02 15:45:08 -0800 |
commit | 4559f000b323b64e4bd179b72cfb788b30b25b23 (patch) | |
tree | 00728f44d761f8663bbadc51d6d6eb67c42465ff /compiler/optimizing/bounds_check_elimination.cc | |
parent | 1d8587fe1d98909b4949282f14c0334085fdc964 (diff) | |
download | art-4559f000b323b64e4bd179b72cfb788b30b25b23.zip art-4559f000b323b64e4bd179b72cfb788b30b25b23.tar.gz art-4559f000b323b64e4bd179b72cfb788b30b25b23.tar.bz2 |
bce: handle a pattern for circular buffer
Change-Id: Ie54bdd7c044af58deea0d0addaaa8186cabf3532
Diffstat (limited to 'compiler/optimizing/bounds_check_elimination.cc')
-rw-r--r-- | compiler/optimizing/bounds_check_elimination.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc index 811a3bd..deaeb8e 100644 --- a/compiler/optimizing/bounds_check_elimination.cc +++ b/compiler/optimizing/bounds_check_elimination.cc @@ -823,6 +823,21 @@ class BCEVisitor : public HGraphVisitor { FindAndHandlePartialArrayLength(ushr); } + void VisitAnd(HAnd* instruction) { + if (instruction->GetRight()->IsIntConstant()) { + int32_t constant = instruction->GetRight()->AsIntConstant()->GetValue(); + if (constant > 0) { + // constant serves as a mask so any number masked with it + // gets a [0, constant] value range. + ValueRange* range = new (GetGraph()->GetArena()) ValueRange( + GetGraph()->GetArena(), + ValueBound(nullptr, 0), + ValueBound(nullptr, constant)); + GetValueRangeMap(instruction->GetBlock())->Overwrite(instruction->GetId(), range); + } + } + } + void VisitNewArray(HNewArray* new_array) { HInstruction* len = new_array->InputAt(0); if (!len->IsIntConstant()) { |