diff options
author | 2022-07-21 10:31:21 +0100 | |
---|---|---|
committer | 2022-07-26 14:35:33 +0000 | |
commit | 4f18b94f4f8140644cabbfff5077178a19dd37e4 (patch) | |
tree | fa7272cdbfadf95b25b7fa6f5e83566e1f65c51d /compiler/optimizing/induction_var_range.h | |
parent | 254f9a9222c8247f5cdff68e4c6c942de5b6ecf9 (diff) |
Make linear loop optimization safe from overflow
In the calcuation of `a * i + b`, `a` itself is calculated by doing:
`(end - start) + (step - 1) / step`
(Note that we add `step - 1` as a way of doing `ceiling`).
This way of calculating `a` can overflow and produce the wrong result
if end and start are in opposite sides of the spectrum.
We can force `a` to be a constant to guarantee that the right result
will be generated when doing loop optimization.
Bug: 231415860
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: Ic056441f8d672b3c48cbbd2f3e4ebd7528e2c65b
Diffstat (limited to 'compiler/optimizing/induction_var_range.h')
-rw-r--r-- | compiler/optimizing/induction_var_range.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/optimizing/induction_var_range.h b/compiler/optimizing/induction_var_range.h index 552837c044..6555bc2206 100644 --- a/compiler/optimizing/induction_var_range.h +++ b/compiler/optimizing/induction_var_range.h @@ -317,6 +317,15 @@ class InductionVarRange { /*out*/ bool* needs_finite_test, /*out*/ bool* needs_taken_test) const; + bool GenerateLastValueLinear(const HBasicBlock* context, + const HLoopInformation* loop, + HInductionVarAnalysis::InductionInfo* info, + HInductionVarAnalysis::InductionInfo* trip, + HGraph* graph, + HBasicBlock* block, + bool is_min, + /*out*/ HInstruction** result) const; + bool GenerateLastValuePolynomial(const HBasicBlock* context, const HLoopInformation* loop, HInductionVarAnalysis::InductionInfo* info, |