[pypy-issue] [issue851] PyPy does not optimize division into shifts

Armin Rigo tracker at bugs.pypy.org
Mon Aug 29 15:49:55 CEST 2011


Armin Rigo <armin.rigo at gmail.com> added the comment:

The optimization only works if you know that 'i' is not negative.  In this
example, you don't know it a priori (because you compile only the loop, not the
"range(10**8)").  That's why it is not optimized.

It's most annoying because the Python-level i//2 is always equivalent to i>>1,
even for negative integers.  Here we are hit by the levels in-between: the
Python-level i//2 is turned into more complex code based on the C-level
division, which has different rounding behavior.

----------
nosy: +arigo

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue851>
________________________________________


More information about the pypy-issue mailing list