[pypy-issue] Issue #1921: Problematic introduction of promote in presence of int switches (pypy/pypy)

Carl Friedrich Bolz issues-reply at bitbucket.org
Tue Nov 4 11:42:31 CET 2014

New issue 1921: Problematic introduction of promote in presence of int switches

Carl Friedrich Bolz:

The following code lead to very confusing behaviour on Pycket recently:


from rpython.rtyper.raisingops import int_floordiv_ovf

        if y == 0:
            raise SchemeException("zero_divisor")
            res = int_floordiv_ovf(x, y) # misnomer, should be int_truncdiv or so
        except OverflowError:
            return self.arith_quotient(values.W_Bignum(rbigint.fromint(other.value)))


(we were intentionally using int_floordiv_ovf, to get the C integer division behaviour). What happened was that int_floordiv_ovf was inlined. That function starts with ``if y == -1: ...``. The two conditions on y were turned into a switch, which lead to the JIT introducing a promote just before it. This is clearly nonsense.

How do we solve this? do the if-to-switch conversion before inlining? require an explicit promote before switches where that is safe (probably breaks some existing code)?

More information about the pypy-issue mailing list