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

Amaury Forgeot d Arc tracker at bugs.pypy.org
Mon Aug 29 15:04:58 CEST 2011


Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:

What makes you think so? It seems on the contrary that it does.

In pypy/jit/metainterp/optimizeopt/pypy/jit/metainterp/optimizeopt/rewrite.py, in optimize_INT_FLOORDIV():

        if v1.intbound.known_ge(IntBound(0, 0)) and v2.is_constant():
            val = v2.box.getint()
            if val & (val - 1) == 0 and val > 0: # val == 2**shift
                op = op.copy_and_change(rop.INT_RSHIFT,
                                        args = [op.getarg(0), ConstInt(highest_bit(val))])

----------
nosy: +afa
status: unread -> chatting

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


More information about the pypy-issue mailing list