diff options
author | 2016-05-17 16:30:10 +0100 | |
---|---|---|
committer | 2016-06-02 19:04:20 +0100 | |
commit | 372f10e5b0b34e2bb6e2b79aeba6c441e14afd1f (patch) | |
tree | 1f29c2467c8909ef0e0147f37f176caa1bcd2ccc /compiler/optimizing/ssa_liveness_analysis.cc | |
parent | 1b66fdf3f33c72dfdda4d31f6f17b6a0d8607402 (diff) |
Refactor handling of input records.
Introduce HInstruction::GetInputRecords(), a new virtual
function that returns an ArrayRef<> to all input records.
Implement all other functions dealing with input records as
wrappers around GetInputRecords(). Rewrite functions that
previously used multiple virtual calls to deal with input
records, especially in loops, to prefetch the ArrayRef<>
only once for each instruction. Besides avoiding all the
extra calls, this also allows the compiler (clang++) to
perform additional optimizations.
This speeds up the Nexus 5 boot image compilation by ~0.5s
(4% of "Compile Dex File", 2% of dex2oat time) on AOSP ToT.
Change-Id: Id8ebe0fb9405e38d918972a11bd724146e4ca578
Diffstat (limited to 'compiler/optimizing/ssa_liveness_analysis.cc')
-rw-r--r-- | compiler/optimizing/ssa_liveness_analysis.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc index 36e0d993d1..212d93532c 100644 --- a/compiler/optimizing/ssa_liveness_analysis.cc +++ b/compiler/optimizing/ssa_liveness_analysis.cc @@ -177,8 +177,9 @@ void SsaLivenessAnalysis::ComputeLiveness() { static void RecursivelyProcessInputs(HInstruction* current, HInstruction* actual_user, BitVector* live_in) { - for (size_t i = 0, e = current->InputCount(); i < e; ++i) { - HInstruction* input = current->InputAt(i); + auto&& inputs = current->GetInputs(); + for (size_t i = 0; i < inputs.size(); ++i) { + HInstruction* input = inputs[i]; bool has_in_location = current->GetLocations()->InAt(i).IsValid(); bool has_out_location = input->GetLocations()->Out().IsValid(); @@ -430,12 +431,12 @@ int LiveInterval::FindFirstRegisterHint(size_t* free_until, // If the instruction dies at the phi assignment, we can try having the // same register. if (end == user->GetBlock()->GetPredecessors()[input_index]->GetLifetimeEnd()) { - for (size_t i = 0, e = user->InputCount(); i < e; ++i) { + auto&& inputs = user->GetInputs(); + for (size_t i = 0; i < inputs.size(); ++i) { if (i == input_index) { continue; } - HInstruction* input = user->InputAt(i); - Location location = input->GetLiveInterval()->GetLocationAt( + Location location = inputs[i]->GetLiveInterval()->GetLocationAt( user->GetBlock()->GetPredecessors()[i]->GetLifetimeEnd() - 1); if (location.IsRegisterKind()) { int reg = RegisterOrLowRegister(location); @@ -471,10 +472,10 @@ int LiveInterval::FindHintAtDefinition() const { if (defined_by_->IsPhi()) { // Try to use the same register as one of the inputs. const ArenaVector<HBasicBlock*>& predecessors = defined_by_->GetBlock()->GetPredecessors(); - for (size_t i = 0, e = defined_by_->InputCount(); i < e; ++i) { - HInstruction* input = defined_by_->InputAt(i); + auto&& inputs = defined_by_->GetInputs(); + for (size_t i = 0; i < inputs.size(); ++i) { size_t end = predecessors[i]->GetLifetimeEnd(); - LiveInterval* input_interval = input->GetLiveInterval()->GetSiblingAt(end - 1); + LiveInterval* input_interval = inputs[i]->GetLiveInterval()->GetSiblingAt(end - 1); if (input_interval->GetEnd() == end) { // If the input dies at the end of the predecessor, we know its register can // be reused. |