diff options
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()) { |