Armin Rigo <[email protected]> added the comment:
Sorry, I said something wrong in that IRC extract: we can't just use one xor,
it's a bit more complicated.
The branch is the "cheapest" I could reasonably come up with. A way to use the
combined div-and-mod x86 operation would be to recognize, in the x86 backend, a
combination of two resoperations, INT_TRUNCDIV followed by INT_TRUNCMOD. It
could be written by using this kind of logic in rtyper/rint.py:
d = int_truncdiv(a, b)
m = int_truncmod(a, b)
if b > 0:
d += (a&m)>>INT_BITS_1
else:
d += ((-m)&(-a)) >>INT_BITS_1
Or without any branch:
d = int_truncdiv(a, b)
m = int_truncmod(a, b)
d += ((a^b)&(m|-m))>>INT_BITS_1
It goes far into the land of obscurity if you ask me...
----------
nosy: +arigo
status: unread -> chatting
________________________________________
PyPy bug tracker <[email protected]>
<https://bugs.pypy.org/issue1701>
________________________________________
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue