pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_range_iter_simple
self = <pypy.module.pypyjit.test_pypy_c.test_misc.TestMisc object at 0x0cc98eb0>
def test_range_iter_simple(self):
def main(n):
def g(n):
return range(n)
s = 0
for i in range(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:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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 0x0cd24ab0>
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=<Guard0xf482fc68>)
===== HERE =====
i73 = int_lt(i71, i31)
guard_true(i73, descr=<Guard0xf47dbaac>)
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=<Guard0xf482fc90>)
i83 = int_add(i72, -1)
i86 = int_lt(i71, 0)
guard_false(i86, descr=<Guard0xf47dbb00>)
i87 = int_ge(i71, i72)
guard_false(i87, descr=<Guard0xf47dbb38>)
i88 = int_add_ovf(i66, i71)
guard_no_overflow(descr=<Guard0xf47dbb54>)
i90 = getfield_raw_i(-135518464, descr=<FieldS pypysig_long_struct_inner.c_value 0>)
i92 = int_lt(i90, 0)
guard_false(i92, descr=<Guard0xf47dbb8c>)
jump(p0, p1, p8, p10, i88, i71, i72, p20, i75, i31, p46, i72, p47, descr=TargetToken(-192308040))
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-32 build #8500+
test: pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_range_iter_simple