diff options
author | 2015-09-18 09:26:15 -0400 | |
---|---|---|
committer | 2015-09-21 07:23:45 -0400 | |
commit | fe57faa2e0349418dda38e77ef1c0ac29db75f4d (patch) | |
tree | 38ba7a406f8a86a1152bd6c9f2d0a6c677423211 /compiler/optimizing/dead_code_elimination.cc | |
parent | 9e30c0e177adabaaf94a66c91130a19a7632fc7c (diff) |
[optimizing] Add basic PackedSwitch support
Add HPackedSwitch, and generate it from the builder. Code generators
convert this to a series of compare/branch tests. Better implementation
in the code generators as a real jump table will follow as separate CLs.
Change-Id: If14736fa4d62809b6ae95280148c55682e856911
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'compiler/optimizing/dead_code_elimination.cc')
-rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index 7d509a22a6..345ff72148 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -41,6 +41,21 @@ static void MarkReachableBlocks(HBasicBlock* block, ArenaBitVector* visited) { DCHECK(condition->AsIntConstant()->IsZero()); MarkReachableBlocks(if_instruction->IfFalseSuccessor(), visited); } + } else if (last_instruction->IsPackedSwitch() && + last_instruction->AsPackedSwitch()->InputAt(0)->IsIntConstant()) { + HPackedSwitch* switch_instruction = last_instruction->AsPackedSwitch(); + int32_t switch_value = switch_instruction->InputAt(0)->AsIntConstant()->GetValue(); + int32_t start_value = switch_instruction->GetStartValue(); + int32_t last_value = start_value + switch_instruction->GetNumEntries(); + for (int32_t case_value = start_value; case_value <= last_value; case_value++) { + if (case_value == last_value) { + MarkReachableBlocks(switch_instruction->GetDefaultBlock(), visited); + } + if (case_value == switch_value) { + MarkReachableBlocks(block->GetSuccessor(case_value - start_value), visited); + break; + } + } } else { for (HBasicBlock* successor : block->GetSuccessors()) { MarkReachableBlocks(successor, visited); |