diff options
author | 2016-02-24 14:17:53 -0800 | |
---|---|---|
committer | 2016-02-25 09:26:57 -0800 | |
commit | 358af839c60db9e178f0b0bb9d430711c071b82a (patch) | |
tree | bfeb6c0fe553161a6d3df57f2e35401ea36e94ff /compiler/optimizing/induction_var_range.cc | |
parent | 4e4e64511e530db37b33f450016afe49db3c4b20 (diff) |
Recognize for (int i = 0; i != x.length; i++) loops
Rationale:
Idiom occurs in real-life and is very straightforwardly
recognized by existing induction/range machinery.
Change-Id: I965a16e9de72f3523ea5023d30ed1c4e47ed5010
Diffstat (limited to 'compiler/optimizing/induction_var_range.cc')
-rw-r--r-- | compiler/optimizing/induction_var_range.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc index b162696a42..f9b6910acd 100644 --- a/compiler/optimizing/induction_var_range.cc +++ b/compiler/optimizing/induction_var_range.cc @@ -216,6 +216,14 @@ bool InductionVarRange::IsConstant(HInductionVarAnalysis::InductionInfo* info, } } } while (RefineOuter(&v_min, &v_max)); + // Exploit array length + c >= c, with c <= 0 to avoid arithmetic wrap-around anomalies + // (e.g. array length == maxint and c == 1 would yield minint). + if (request == kAtLeast) { + if (v_min.a_constant == 1 && v_min.b_constant <= 0 && v_min.instruction->IsArrayLength()) { + *value = v_min.b_constant; + return true; + } + } } return false; } |