[pypy-dev] Slow int code

Roger Flores aidembb at yahoo.com
Wed Feb 27 21:10:04 CET 2013


Hi guys.  I've been looking at two simple routines using jitviewer to figure out why they're so much slower than expected.


I've also noticed that http://pypy.org/performance.html has the line "Bad examples include doing computations with
large longs – which is performed by unoptimizable support code.".  I'm worried that my 32 bit int code is falling into this, and I'm wondering what I can do to avoid it?

Trivial code like

if (self.low ^ self.high) & 0x80000000 == 0:


is expanding into several dozen asm instructions.  I'm suspecting that lines like 

self.low = (self.low << 1) & 0xffffffff


with it's shift left are convincing the jit to consider the int to need 64 bits (large long?) instead of 32.


Ideas?  The asm is clearly operating on QWORDs and calling routines to do the bit arithmetic instead of single instructions.  Is this what that line in performance.html is warning about?



-Roger

BTW Fijal's jitviewer is a *must see* for anyone interested in how pypy makes their code fast!



More information about the pypy-dev mailing list