diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2015-01-26 14:45:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-26 14:46:00 +0000 |
commit | 76d032bacd65e396609631bb6aca3a90a80116f7 (patch) | |
tree | d53d23ed8ccacd41fffb70f2157506d0b9d59182 /compiler/optimizing/gvn.cc | |
parent | c2c25a939a8bc98365c282f76f8f33f9549034b8 (diff) | |
parent | 86dde1658a1951c251dd5c6ff21ecc5c281879a6 (diff) | |
download | art-76d032bacd65e396609631bb6aca3a90a80116f7.tar.gz art-76d032bacd65e396609631bb6aca3a90a80116f7.tar.bz2 art-76d032bacd65e396609631bb6aca3a90a80116f7.zip |
Merge "Introduce a SideEffectsAnalysis class."
Diffstat (limited to 'compiler/optimizing/gvn.cc')
-rw-r--r-- | compiler/optimizing/gvn.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc index 6e5f1bd203..781aad5c72 100644 --- a/compiler/optimizing/gvn.cc +++ b/compiler/optimizing/gvn.cc @@ -18,24 +18,12 @@ namespace art { -void GlobalValueNumberer::Run() { - ComputeSideEffects(); - - sets_.Put(graph_->GetEntryBlock()->GetBlockId(), new (allocator_) ValueSet(allocator_)); - - // Do reverse post order to ensure the non back-edge predecessors of a block are - // visited before the block itself. - for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { - VisitBasicBlock(it.Current()); - } -} - -void GlobalValueNumberer::UpdateLoopEffects(HLoopInformation* info, SideEffects effects) { +void SideEffectsAnalysis::UpdateLoopEffects(HLoopInformation* info, SideEffects effects) { int id = info->GetHeader()->GetBlockId(); loop_effects_.Put(id, loop_effects_.Get(id).Union(effects)); } -void GlobalValueNumberer::ComputeSideEffects() { +void SideEffectsAnalysis::Run() { if (kIsDebugBuild) { for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { HBasicBlock* block = it.Current(); @@ -80,17 +68,29 @@ void GlobalValueNumberer::ComputeSideEffects() { UpdateLoopEffects(block->GetLoopInformation(), effects); } } + has_run_ = true; } -SideEffects GlobalValueNumberer::GetLoopEffects(HBasicBlock* block) const { +SideEffects SideEffectsAnalysis::GetLoopEffects(HBasicBlock* block) const { DCHECK(block->IsLoopHeader()); return loop_effects_.Get(block->GetBlockId()); } -SideEffects GlobalValueNumberer::GetBlockEffects(HBasicBlock* block) const { +SideEffects SideEffectsAnalysis::GetBlockEffects(HBasicBlock* block) const { return block_effects_.Get(block->GetBlockId()); } +void GlobalValueNumberer::Run() { + DCHECK(side_effects_.HasRun()); + sets_.Put(graph_->GetEntryBlock()->GetBlockId(), new (allocator_) ValueSet(allocator_)); + + // Use the reverse post order to ensure the non back-edge predecessors of a block are + // visited before the block itself. + for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { + VisitBasicBlock(it.Current()); + } +} + void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) { ValueSet* set = nullptr; const GrowableArray<HBasicBlock*>& predecessors = block->GetPredecessors(); @@ -110,7 +110,7 @@ void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) { if (!set->IsEmpty()) { if (block->IsLoopHeader()) { DCHECK_EQ(block->GetDominator(), block->GetLoopInformation()->GetPreHeader()); - set->Kill(GetLoopEffects(block)); + set->Kill(side_effects_.GetLoopEffects(block)); } else if (predecessors.Size() > 1) { for (size_t i = 0, e = predecessors.Size(); i < e; ++i) { set->IntersectionWith(sets_.Get(predecessors.Get(i)->GetBlockId())); |