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
4 files changed