pypy/module/pypyjit/test_pypy_c/test_array.py::TestArray::()::test_array_intimg
self = <pypy.module.pypyjit.test_pypy_c.test_array.TestArray object at 0x000000000a9050c0>
def test_array_intimg(self):
def main():
from array import array
img = array('i', range(3)) * (350 * 480)
intimg = array('i', (0,)) * (640 * 480)
l, i = 0, 640
while i < 640 * 480:
assert len(img) == 3*350*480
assert len(intimg) == 640*480
l = l + img[i]
intimg[i] = (intimg[i-640] + l)
i += 1
return intimg[i - 1]
#
log = self.run(main, [])
assert log.result == 73574560
loop, = log.loops_by_filename(self.filepath)
if sys.maxint == 2 ** 31 - 1:
assert loop.match("""
i13 = int_lt(i8, 307200)
guard_true(i13, descr=...)
guard_not_invalidated(descr=...)
# the bound check guard on img has been killed (thanks to the asserts)
i14 = getarrayitem_raw_i(i10, i8, descr=<ArrayS .>)
i15 = int_add_ovf(i9, i14)
guard_no_overflow(descr=...)
i17 = int_add(i8, -640)
# the bound check guard on intimg has been killed (thanks to the asserts)
i18 = getarrayitem_raw_i(i11, i17, descr=<ArrayS .>)
i19 = int_add_ovf(i18, i15)
guard_no_overflow(descr=...)
setarrayitem_raw(i11, i8, _, descr=<ArrayS .>)
i28 = int_add(i8, 1)
--TICK--
jump(..., descr=...)
""")
elif sys.maxint == 2 ** 63 - 1:
> assert loop.match("""
i13 = int_lt(i8, 307200)
guard_true(i13, descr=...)
guard_not_invalidated(descr=...)
# the bound check guard on img has been killed (thanks to the asserts)
i14 = getarrayitem_raw_i(i10, i8, descr=<ArrayS .>)
# advanced: the following int_add cannot overflow, because:
# - i14 fits inside 32 bits
# - i9 fits inside 33 bits, because:
# - it comes from the previous iteration's i15
# - prev i19 = prev i18 + prev i15
# - prev i18 fits inside 32 bits
# - prev i19 is guarded to fit inside 32 bits
# - so as a consequence, prev i15 fits inside 33 bits
# the new i15 thus fits inside "33.5" bits, which is enough to
# guarantee that the next int_add(i18, i15) cannot overflow either...
i15 = int_add(i9, i14)
i17 = int_add(i8, -640)
# the bound check guard on intimg has been killed (thanks to the asserts)
i18 = getarrayitem_raw_i(i11, i17, descr=<ArrayS .>)
i19 = int_add(i18, i15)
# guard checking that i19 actually fits into 32bit
i20 = int_signext(i19, 4)
i65 = int_ne(i20, i19)
guard_false(i65, descr=...)
setarrayitem_raw(i11, i8, _, descr=<ArrayS .>)
i28 = int_add(i8, 1)
--TICK--
jump(..., descr=...)
""")
pypy/module/pypyjit/test_pypy_c/test_array.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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 0x000000000d39ce90>
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=<Guard0x7f290a7e1d30>)
i67 = int_lt(i61, 307200)
guard_true(i67, descr=<Guard0x7f290a7119f0>)
i68 = getarrayitem_raw_i(i46, i61, descr=<ArrayS 4>)
i69 = int_add(i49, i68)
i71 = int_add(i61, -640)
i72 = getarrayitem_raw_i(i54, i71, descr=<ArrayS 4>)
i73 = int_add(i72, i69)
i75 = int_signext(i73, 4)
i76 = int_ne(i75, i73)
guard_false(i76, descr=<Guard0x7f290a7119b8>)
setarrayitem_raw(i54, i61, i75, descr=<ArrayS 4>)
i78 = int_add(i61, 1)
i80 = getfield_raw_i(139814307695264, descr=<FieldS pypysig_long_struct_inner.c_value 0>)
i82 = int_lt(i80, 0)
guard_false(i82, descr=<Guard0x7f290a7e1c40>)
jump(p0, p1, p8, p10, p12, i78, i69, p24, i46, i54, descr=TargetToken(139814245582176))
Expected:
i13 = int_lt(i8, 307200)
guard_true(i13, descr=...)
guard_not_invalidated(descr=...)
# the bound check guard on img has been killed (thanks to the asserts)
i14 = getarrayitem_raw_i(i10, i8, descr=<ArrayS .>)
# advanced: the following int_add cannot overflow, because:
# - i14 fits inside 32 bits
# - i9 fits inside 33 bits, because:
# - it comes from the previous iteration's i15
# - prev i19 = prev i18 + prev i15
# - prev i18 fits inside 32 bits
# - prev i19 is guarded to fit inside 32 bits
# - so as a consequence, prev i15 fits inside 33 bits
# the new i15 thus fits inside "33.5" bits, which is enough to
# guarantee that the next int_add(i18, i15) cannot overflow either...
i15 = int_add(i9, i14)
i17 = int_add(i8, -640)
# the bound check guard on intimg has been killed (thanks to the asserts)
i18 = getarrayitem_raw_i(i11, i17, descr=<ArrayS .>)
i19 = int_add(i18, i15)
# guard checking that i19 actually fits into 32bit
i20 = int_signext(i19, 4)
i65 = int_ne(i20, i19)
guard_false(i65, descr=...)
setarrayitem_raw(i11, i8, _, descr=<ArrayS .>)
i28 = int_add(i8, 1)
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_array.py::TestArray::()::test_array_intimg