[pypy-dev] Optimize constant float division by multiplication?

Armin Rigo arigo at tunes.org
Fri Nov 7 10:44:52 CET 2014


Hi Toni,

On 6 November 2014 23:19, Toni Mattis
<toni.mattis at student.hpi.uni-potsdam.de> wrote:
> that sounds more convenient than manipulating floats as architecture
> dependent integers ;) So this is my implementation now:
>
> https://bitbucket.org/amintos/pypy/commits/f30efb9a8e54e56af7e7a0d07ec19d6985c1f4e0?at=float-opt

Thanks!  Do you mind if I merge this branch 'float-ops' into the
standard repo?  Or are you a person who wouldn't like to see the first
attempt show up in the history?  (Generally, histories are good to
have, and PyPy's contains tons of half-way or reverted checkins.)

> BTW, the jit log (PYPYLOG=jit-log-opt,jit-backend) tends to round small
> floats like '1.0 / 8.98846567431158e+307' to '0.000000', but '1.0 /
> 2.2250738585072014e-308' appears as a full 308-digit decimal number.
> This may cause some confusion when checking where the optimization is
> effective.

Ah, yes.  Maybe it would be better if the jit log showed floats with
full precision.  I think it's caused by `str(arg.getfloat())` in
metainterp/logger.py.  We could use instead
`rfloat.double_to_string(x, 'r', 0, 0)[0]`.


A bientôt,

Armin.


More information about the pypy-dev mailing list