Home - Summaries: (main) : (py3.11) : (py3.12) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_range_iter_normal

self = <pypy.module.pypyjit.test_pypy_c.test_misc.TestMisc object at 0x00000000070c6790>

    def test_range_iter_normal(self):
        # Difference: range(n) => range(1, n).
        # This difference doesn't really change anything in pypy3.5,
        # but it used to in pypy2.7.
        def main(n):
            def g(n):
                return range(n)
            s = 0
            for i in range(1, n):  # ID: for
                tmp = g(n)
                s += tmp[i]     # ID: getitem
                a = 0
            return s
        #
        log = self.run(main, [1000])
        assert log.result == 1000 * 999 / 2
        loop, = log.loops_by_filename(self.filepath)
>       assert loop.match(self.RANGE_ITER_STEP_1)

pypy/module/pypyjit/test_pypy_c/test_misc.py:191: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pypy/module/pypyjit/test_pypy_c/model.py:177: in match
    return matcher.match(expected_src, **kwds)
pypy/module/pypyjit/test_pypy_c/model.py:524: in match
    self.match_loop(expected_ops, ignore_ops)
pypy/module/pypyjit/test_pypy_c/model.py:500: in match_loop
    self.match_op(op, exp_op)
pypy/module/pypyjit/test_pypy_c/model.py:409: in match_op
    self._assert(op.name == exp_opname, "operation mismatch")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pypy.module.pypyjit.test_pypy_c.model.OpMatcher object at 0x00000000061c8c28>
cond = False, message = 'operation mismatch'

    def _assert(self, cond, message):
        if not cond:
>           raise InvalidMatch(message, frame=sys._getframe(1))
E           InvalidMatch: operation mismatch

pypy/module/pypyjit/test_pypy_c/model.py:402: InvalidMatch
---------- Captured stdout call ----------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Loops don't match
=================
loop id = None
('operation mismatch',)
<could not determine information>

Ignore ops: []
Got:
    guard_not_invalidated(descr=<Guard0x7f80db5e3970>)
    i73 = int_lt(i71, i31)
    guard_true(i73, descr=<Guard0x7f80db5139b8>)
    i75 = int_add(i71, 1)

	===== HERE =====
    p76 = force_token()
    setfield_gc(p20, i75, descr=<FieldS pypy.module.__builtin__.functional.W_IntRangeIterator.inst_current 8>)
    i80 = int_lt(0, i72)
    guard_true(i80, descr=<Guard0x7f80db5e39c0>)
    i83 = int_add(i72, -1)
    i86 = int_lt(i71, 0)
    guard_false(i86, descr=<Guard0x7f80db513a60>)
    i87 = int_ge(i71, i72)
    guard_false(i87, descr=<Guard0x7f80db513ad0>)
    i88 = int_add_ovf(i66, i71)
    guard_no_overflow(descr=<Guard0x7f80db513b08>)
    i90 = getfield_raw_i(140191474191008, descr=<FieldS pypysig_long_struct_inner.c_value 0>)
    i92 = int_lt(i90, 0)
    guard_false(i92, descr=<Guard0x7f80db520170>)
    jump(p0, p1, p8, p10, i88, i71, i72, p20, i75, i31, p46, i72, p47, descr=TargetToken(140191412087136))

Expected:
    
    guard_not_invalidated?
    # W_IntRangeStepOneIterator.next()
    i16 = int_lt(i11, i12)
    guard_true(i16, descr=...)
    i20 = int_add(i11, 1)
    setfield_gc(p4, i20, descr=<.* .*W_IntRangeIterator.inst_current .*>)
    guard_not_invalidated?
    i21 = force_token()
    i89 = int_lt(0, i9)
    guard_true(i89, descr=...)
    i88 = int_add(i9, -1)
    
    # Compared with pypy2, we get these two operations extra.
    # I think the reason is that W_IntRangeStepOneIterator is used
    # for any 'start' value, which might be negative.
    i89 = int_lt(i11, 0)
    guard_false(i89, descr=...)
    i25 = int_ge(i11, i9)
    guard_false(i25, descr=...)
    i27 = int_add_ovf(i7, i11)
    guard_no_overflow(descr=...)
    
    guard_not_invalidated?
    ticker0 = getfield_raw_i(#, descr=<FieldS pypysig_long_struct_inner.c_value .*>)
    ticker_cond0 = int_lt(ticker0, 0)
    guard_false(ticker_cond0, descr=...)
    
    jump(..., descr=...)
builder: pypy-c-jit-linux-x86-64 build #11971+
test: pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_range_iter_normal