diff options
author | David Brazdil <dbrazdil@google.com> | 2015-03-16 17:31:52 +0000 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2015-03-24 17:28:37 +0000 |
commit | 46e2a3915aa68c77426b71e95b9f3658250646b7 (patch) | |
tree | 2b0a4470b05291894db73c631fe94f0fdff8c46b /compiler/optimizing/builder.cc | |
parent | bce0855ca1dbb1fa226c5b6a81760272ce0b64ef (diff) | |
download | android_art-46e2a3915aa68c77426b71e95b9f3658250646b7.tar.gz android_art-46e2a3915aa68c77426b71e95b9f3658250646b7.tar.bz2 android_art-46e2a3915aa68c77426b71e95b9f3658250646b7.zip |
ART: Boolean simplifier
The optimization recognizes the negation pattern generated by 'javac'
and replaces it with a single condition. To this end, boolean values
are now consistently assumed to be represented by an integer.
This is a first optimization which deletes blocks from the HGraph and
does so by replacing the corresponding entries with null. Hence,
existing code can continue indexing the list of blocks with the block
ID, but must check for null when iterating over the list.
Change-Id: I7779da69cfa925c6521938ad0bcc11bc52335583
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r-- | compiler/optimizing/builder.cc | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index cbb41b1837..75b114bbef 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -2060,31 +2060,13 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 return true; } // NOLINT(readability/fn_size) -HIntConstant* HGraphBuilder::GetIntConstant0() { - if (constant0_ != nullptr) { - return constant0_; - } - constant0_ = new(arena_) HIntConstant(0); - entry_block_->AddInstruction(constant0_); - return constant0_; -} - -HIntConstant* HGraphBuilder::GetIntConstant1() { - if (constant1_ != nullptr) { - return constant1_; - } - constant1_ = new(arena_) HIntConstant(1); - entry_block_->AddInstruction(constant1_); - return constant1_; -} - HIntConstant* HGraphBuilder::GetIntConstant(int32_t constant) { switch (constant) { - case 0: return GetIntConstant0(); - case 1: return GetIntConstant1(); + case 0: return graph_->GetIntConstant0(); + case 1: return graph_->GetIntConstant1(); default: { HIntConstant* instruction = new (arena_) HIntConstant(constant); - entry_block_->AddInstruction(instruction); + graph_->AddConstant(instruction); return instruction; } } @@ -2092,7 +2074,7 @@ HIntConstant* HGraphBuilder::GetIntConstant(int32_t constant) { HLongConstant* HGraphBuilder::GetLongConstant(int64_t constant) { HLongConstant* instruction = new (arena_) HLongConstant(constant); - entry_block_->AddInstruction(instruction); + graph_->AddConstant(instruction); return instruction; } |