diff options
author | 2015-09-10 12:50:58 -0700 | |
---|---|---|
committer | 2015-09-15 17:03:13 -0700 | |
commit | 22af3bee34d0ab1a4bd186c71ccab00366882259 (patch) | |
tree | 793f358d498142a2e60d7d5131c347b0fd668cbd /compiler/optimizing/induction_var_range.cc | |
parent | fe9a1b05ea5a21b6d9a2e9e5081f5e80ff8a1ba2 (diff) |
Use induction variable range analysis in BCE (statically).
Rationale: Finally! After lots of very large CLs, now a small CL
that uses the new induction variable analysis in BCE
(statically, using this dynamically with de-opt is TBD).
Despite its relative small size, be aware though,
since the CL introduces a new phase to the compiler.
Change-Id: If5555a173fd5d55d147c63138ef51fc296fa1414
Diffstat (limited to 'compiler/optimizing/induction_var_range.cc')
-rw-r--r-- | compiler/optimizing/induction_var_range.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc index bd903340ad..486e904bd1 100644 --- a/compiler/optimizing/induction_var_range.cc +++ b/compiler/optimizing/induction_var_range.cc @@ -126,6 +126,7 @@ HInductionVarAnalysis::InductionInfo* InductionVarRange::GetTripCount(HLoopInfor } InductionVarRange::Value InductionVarRange::GetFetch(HInstruction* instruction, + HInductionVarAnalysis::InductionInfo* trip, int32_t fail_value) { // Detect constants and chase the fetch a bit deeper into the HIR tree, so that it becomes // more likely range analysis will compare the same instructions as terminal nodes. @@ -134,9 +135,16 @@ InductionVarRange::Value InductionVarRange::GetFetch(HInstruction* instruction, return Value(value); } else if (instruction->IsAdd()) { if (IsIntAndGet(instruction->InputAt(0), &value)) { - return AddValue(Value(value), GetFetch(instruction->InputAt(1), fail_value), fail_value); + return AddValue(Value(value), + GetFetch(instruction->InputAt(1), trip, fail_value), fail_value); } else if (IsIntAndGet(instruction->InputAt(1), &value)) { - return AddValue(GetFetch(instruction->InputAt(0), fail_value), Value(value), fail_value); + return AddValue(GetFetch(instruction->InputAt(0), trip, fail_value), + Value(value), fail_value); + } + } else if (fail_value < 0) { + // Special case: within the loop-body, minimum of trip-count is 1. + if (trip != nullptr && instruction == trip->op_b->fetch) { + return Value(1); } } return Value(instruction, 1, 0); @@ -163,7 +171,7 @@ InductionVarRange::Value InductionVarRange::GetMin(HInductionVarAnalysis::Induct case HInductionVarAnalysis::kDiv: return GetDiv(info->op_a, info->op_b, trip, INT_MIN); case HInductionVarAnalysis::kFetch: - return GetFetch(info->fetch, INT_MIN); + return GetFetch(info->fetch, trip, INT_MIN); } break; case HInductionVarAnalysis::kLinear: @@ -200,7 +208,7 @@ InductionVarRange::Value InductionVarRange::GetMax(HInductionVarAnalysis::Induct case HInductionVarAnalysis::kDiv: return GetDiv(info->op_a, info->op_b, trip, INT_MAX); case HInductionVarAnalysis::kFetch: - return GetFetch(info->fetch, INT_MAX); + return GetFetch(info->fetch, trip, INT_MAX); } break; case HInductionVarAnalysis::kLinear: |