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 0x0000000022d29b40>

    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:194: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
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:522: in match
    self.match_loop(expected_ops, ignore_ops)
pypy/module/pypyjit/test_pypy_c/model.py:498: in match_loop
    self.match_op(op, exp_op)
pypy/module/pypyjit/test_pypy_c/model.py:407: in match_op
    self._assert(op.name == exp_opname, "operation mismatch")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pypy.module.pypyjit.test_pypy_c.model.OpMatcher object at 0x000000001ddb4528>
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:400: InvalidMatch
---------- Captured stdout call ----------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Loops don't match
=================
loop id = None
('operation mismatch',)
<could not determine information>

Ignore ops: []
Got:
    guard_not_invalidated(descr=<Guard0x7f20ba4d1970>)

	===== HERE =====
    i73 = int_lt(i71, i31)
    guard_true(i73, descr=<Guard0x7f20b6793a28>)
    i75 = int_add(i71, 1)
    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=<Guard0x7f20ba4d19c0>)
    i83 = int_add(i72, -1)
    i86 = int_lt(i71, 0)
    guard_false(i86, descr=<Guard0x7f20b6793ad0>)
    i87 = int_ge(i71, i72)
    guard_false(i87, descr=<Guard0x7f20b6793b40>)
    i88 = int_add_ovf(i66, i71)
    guard_no_overflow(descr=<Guard0x7f20b6793b78>)
    i90 = getfield_raw_i(139778538995328, descr=<FieldS pypysig_long_struct_inner.c_value 0>)
    i92 = int_lt(i90, 0)
    guard_false(i92, descr=<Guard0x7f20b67a01a8>)
    jump(p0, p1, p8, p10, i88, i71, i72, p20, i75, i31, p46, i72, p47, descr=TargetToken(139778477091168))

Expected:
    
    guard_not_invalidated(descr=...)
    # W_IntRangeStepOneIterator.next()
    i16 = int_ge(i11, i12)
    guard_false(i16, descr=...)
    i20 = int_add(i11, 1)
    i21 = force_token()
    setfield_gc(p4, i20, descr=<.* .*W_IntRangeIterator.inst_current .*>)
    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=...)
    
    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 #11989+
test: pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_range_iter_normal