pypy/module/pypyjit/test_pypy_c/test_misc.py::TestMisc::()::test_f1
self = <pypy.module.pypyjit.test_pypy_c.test_misc.TestMisc object at 0x000000000de38b80>
def test_f1(self):
def f1(n):
"Arbitrary test function."
i = 0
x = 1
while i<n:
j = 0
while j<=i:
j = j + 1
x = x + (i&j)
i = i + 1
return x
log = self.run(f1, [2117])
assert log.result == 1083876708
# we get two loops: in the initial one "i" is only read and thus is
# not virtual, then "i" is written and thus we get a new loop where
# "i" is virtual. However, in this specific case the two loops happen
# to contain the very same operations
loop0, loop1 = log.loops_by_filename(self.filepath)
expected = """
i9 = int_le(i7, i8)
guard_true(i9, descr=...)
i11 = int_add_ovf(i7, 1)
guard_no_overflow(descr=...)
i12 = int_and(i8, i11)
i13 = int_add_ovf(i6, i12)
guard_no_overflow(descr=...)
--TICK--
jump(..., descr=...)
"""
> assert loop0.match(expected)
pypy/module/pypyjit/test_pypy_c/test_misc.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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 0x000000000f39c2c0>
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:
===== HERE =====
guard_not_invalidated(descr=<Guard0x7f8fde313970>)
i38 = int_le(i29, i26)
guard_true(i38, descr=<Guard0x7f8fde1924f0>)
i40 = int_add_ovf(i29, 1)
guard_no_overflow(descr=<Guard0x7f8fde192528>)
i41 = int_and(i26, i40)
i42 = int_add_ovf(i33, i41)
guard_no_overflow(descr=<Guard0x7f8fde192560>)
i44 = getfield_raw_i(140255881923232, descr=<FieldS pypysig_long_struct_inner.c_value 0>)
i46 = int_lt(i44, 0)
guard_false(i46, descr=<Guard0x7f8fde1925d0>)
jump(p0, p1, p8, p10, i42, i40, i26, descr=TargetToken(140255883231968))
Expected:
i9 = int_le(i7, i8)
guard_true(i9, descr=...)
i11 = int_add_ovf(i7, 1)
guard_no_overflow(descr=...)
i12 = int_and(i8, i11)
i13 = int_add_ovf(i6, i12)
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_f1