diff options
author | 2015-04-25 17:00:45 +0100 | |
---|---|---|
committer | 2015-04-27 15:41:04 +0100 | |
commit | f725550c8df90f8ec07395d9be5177a4be591c12 (patch) | |
tree | bfecc5637c57f4593e0bd73c11ad7a8887f4f988 | |
parent | a0ee862288b702468f8c2b6d0ad0f1c61be0b483 (diff) |
Quick: Avoid unnecessary GVN work in release builds.
In GVN's post-processing phase, compare LVNs only in debug
builds as they should be equal anyway.
Remove the Gate() from GVN cleanup pass and remove the
DCHECK() from MIRGraph::GlobalValueNumberingCleanup()
to make it a no-op if the GVN didn't run.
Bug: 16398693
Change-Id: Ia4f1e7e3ecf12d0305966c86e0e7dbae61dab0b7
-rw-r--r-- | compiler/dex/bb_optimizations.cc | 11 | ||||
-rw-r--r-- | compiler/dex/bb_optimizations.h | 3 | ||||
-rw-r--r-- | compiler/dex/global_value_numbering.cc | 6 | ||||
-rw-r--r-- | compiler/dex/mir_optimization.cc | 2 |
4 files changed, 6 insertions, 16 deletions
diff --git a/compiler/dex/bb_optimizations.cc b/compiler/dex/bb_optimizations.cc index f351d990d0..11a7e44f98 100644 --- a/compiler/dex/bb_optimizations.cc +++ b/compiler/dex/bb_optimizations.cc @@ -17,7 +17,6 @@ #include "bb_optimizations.h" #include "dataflow_iterator.h" #include "dataflow_iterator-inl.h" -#include "global_value_numbering.h" namespace art { @@ -80,14 +79,4 @@ bool MethodUseCount::Worker(PassDataHolder* data) const { return false; } -bool GlobalValueNumberingCleanupPass::Gate(const PassDataHolder* data) const { - DCHECK(data != nullptr); - CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; - DCHECK(c_unit != nullptr); - // Do not do cleanup if GVN skipped this. - // TODO: Proper dependencies between passes? - return !GlobalValueNumbering::Skip(c_unit); -} - - } // namespace art diff --git a/compiler/dex/bb_optimizations.h b/compiler/dex/bb_optimizations.h index b948afd605..eb87c29f9d 100644 --- a/compiler/dex/bb_optimizations.h +++ b/compiler/dex/bb_optimizations.h @@ -284,9 +284,6 @@ class GlobalValueNumberingCleanupPass : public PassME { : PassME("GVNCleanup", kNoNodes, "") { } - // Depends on GlobalValueNumbering, so implemented in cc file. - bool Gate(const PassDataHolder* data) const OVERRIDE; - void Start(PassDataHolder* data) const OVERRIDE { DCHECK(data != nullptr); CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; diff --git a/compiler/dex/global_value_numbering.cc b/compiler/dex/global_value_numbering.cc index 30e3ce0354..e2b99871c8 100644 --- a/compiler/dex/global_value_numbering.cc +++ b/compiler/dex/global_value_numbering.cc @@ -128,8 +128,9 @@ bool GlobalValueNumbering::FinishBasicBlock(BasicBlock* bb) { ++bbs_processed_; merge_lvns_.clear(); - bool change = (lvns_[bb->id] == nullptr) || !lvns_[bb->id]->Equals(*work_lvn_); + bool change = false; if (mode_ == kModeGvn) { + change = (lvns_[bb->id] == nullptr) || !lvns_[bb->id]->Equals(*work_lvn_); // In GVN mode, keep the latest LVN even if Equals() indicates no change. This is // to keep the correct values of fields that do not contribute to Equals() as long // as they depend only on predecessor LVNs' fields that do contribute to Equals(). @@ -137,6 +138,9 @@ bool GlobalValueNumbering::FinishBasicBlock(BasicBlock* bb) { std::unique_ptr<const LocalValueNumbering> old_lvn(lvns_[bb->id]); lvns_[bb->id] = work_lvn_.release(); } else { + DCHECK_EQ(mode_, kModeGvnPostProcessing); // kModeLvn doesn't use FinishBasicBlock(). + DCHECK(lvns_[bb->id] != nullptr); + DCHECK(lvns_[bb->id]->Equals(*work_lvn_)); work_lvn_.reset(); } return change; diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index 3482602704..f7107c159d 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -1451,13 +1451,13 @@ void MIRGraph::EliminateDeadCodeEnd() { } void MIRGraph::GlobalValueNumberingCleanup() { + // If the GVN didn't run, these pointers should be null and everything is effectively no-op. delete temp_.gvn.dce; temp_.gvn.dce = nullptr; delete temp_.gvn.gvn; temp_.gvn.gvn = nullptr; temp_.gvn.ifield_ids = nullptr; temp_.gvn.sfield_ids = nullptr; - DCHECK(temp_scoped_alloc_ != nullptr); temp_scoped_alloc_.reset(); } |